1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_MAC_H_
6 #define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_MAC_H_
7 
8 #import <AppKit/AppKit.h>
9 
10 #include "base/compiler_specific.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_refptr.h"
14 #include "chrome/browser/buildflags.h"
15 #include "chrome/browser/ui/webui/help/version_updater.h"
16 
17 #if BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
18 #include "chrome/updater/update_service.h"  // nogncheck
19 
20 class BrowserUpdaterClient;
21 #endif  // BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
22 
23 @class KeystoneObserver;
24 
25 // OS X implementation of version update functionality, used by the WebUI
26 // About/Help page.
27 class VersionUpdaterMac : public VersionUpdater {
28  public:
29   // VersionUpdater implementation.
30   void CheckForUpdate(const StatusCallback& status_callback,
31                       const PromoteCallback& promote_callback) override;
32   void PromoteUpdater() const override;
33 
34   // Process status updates received from Keystone. The dictionary will contain
35   // an AutoupdateStatus value as an intValue at key kAutoupdateStatusStatus. If
36   // a version is available (see AutoupdateStatus), it will be present at key
37   // kAutoupdateStatusVersion.
38   void UpdateStatus(NSDictionary* status);
39 
40  protected:
41   friend class VersionUpdater;
42 
43   // Clients must use VersionUpdater::Create().
44   VersionUpdaterMac();
45   ~VersionUpdaterMac() override;
46 
47  private:
48   // Update the visibility state of promote button.
49   void UpdateShowPromoteButton();
50 
51   // Callback used to communicate update status to the client.
52   StatusCallback status_callback_;
53 
54   // Callback used to show or hide the promote UI elements.
55   PromoteCallback promote_callback_;
56 
57   // The visible state of the promote button.
58   bool show_promote_button_;
59 
60   // The observer that will receive keystone status updates.
61   base::scoped_nsobject<KeystoneObserver> keystone_observer_;
62 
63 #if BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
64   // Instance of the BrowserUpdaterClient used to update the browser with the
65   // new updater.
66   scoped_refptr<BrowserUpdaterClient> update_client_;
67 #endif  // BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
68 
69   DISALLOW_COPY_AND_ASSIGN(VersionUpdaterMac);
70 };
71 
72 #endif  // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_MAC_H_
73 
74