1 // Copyright 2015 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 // Windows implementation of version update functionality, used by the WebUI
6 // About/Help page.
7 
8 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_WIN_H_
9 #define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_WIN_H_
10 
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/google/google_update_win.h"
15 #include "chrome/browser/ui/webui/help/version_updater.h"
16 
17 class VersionUpdaterWin : public VersionUpdater,
18                           public UpdateCheckDelegate {
19  public:
20   // |owner_widget| is the parent widget hosting the update check UI. Any UI
21   // needed to install an update (e.g., a UAC prompt for a system-level install)
22   // will be parented to this widget. |owner_widget| may be given a value of
23   // nullptr in which case the UAC prompt will be parented to the desktop.
24   explicit VersionUpdaterWin(gfx::AcceleratedWidget owner_widget);
25   ~VersionUpdaterWin() override;
26 
27   // VersionUpdater:
28   void CheckForUpdate(const StatusCallback& callback,
29                       const PromoteCallback&) override;
30 
31   // UpdateCheckDelegate:
32   void OnUpdateCheckComplete(const base::string16& new_version) override;
33   void OnUpgradeProgress(int progress,
34                          const base::string16& new_version) override;
35   void OnUpgradeComplete(const base::string16& new_version) override;
36   void OnError(GoogleUpdateErrorCode error_code,
37                const base::string16& html_error_message,
38                const base::string16& new_version) override;
39 
40  private:
41   void DoBeginUpdateCheck(bool install_update_if_possible);
42 
43   // A task run on the UI thread with the result of checking for a pending
44   // restart.
45   void OnPendingRestartCheck(bool is_update_pending_restart);
46 
47   // The widget owning the UI for the update check.
48   gfx::AcceleratedWidget owner_widget_;
49 
50   // Callback used to communicate update status to the client.
51   StatusCallback callback_;
52 
53   // Used for callbacks.
54   base::WeakPtrFactory<VersionUpdaterWin> weak_factory_;
55 
56   DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin);
57 };
58 
59 #endif  // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_WIN_H_
60