Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/webui/help/version_updater_win.cc

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "base/win/win_util.h" 10 #include "base/win/win_util.h"
(...skipping 18 matching lines...) Expand all
29 29
30 // Windows implementation of version update functionality, used by the WebUI 30 // Windows implementation of version update functionality, used by the WebUI
31 // About/Help page. 31 // About/Help page.
32 class VersionUpdaterWin : public VersionUpdater { 32 class VersionUpdaterWin : public VersionUpdater {
33 private: 33 private:
34 friend class VersionReader; 34 friend class VersionReader;
35 friend class VersionUpdater; 35 friend class VersionUpdater;
36 36
37 // Clients must use VersionUpdater::Create(). 37 // Clients must use VersionUpdater::Create().
38 VersionUpdaterWin(); 38 VersionUpdaterWin();
39 virtual ~VersionUpdaterWin(); 39 ~VersionUpdaterWin() override;
40 40
41 // VersionUpdater implementation. 41 // VersionUpdater implementation.
42 virtual void CheckForUpdate(const StatusCallback& callback) override; 42 void CheckForUpdate(const StatusCallback& callback) override;
43 virtual void RelaunchBrowser() const override; 43 void RelaunchBrowser() const override;
44 44
45 // chrome::UpdateCheckCallback. 45 // chrome::UpdateCheckCallback.
46 void OnUpdateCheckResults(GoogleUpdateUpgradeResult result, 46 void OnUpdateCheckResults(GoogleUpdateUpgradeResult result,
47 GoogleUpdateErrorCode error_code, 47 GoogleUpdateErrorCode error_code,
48 const base::string16& error_message, 48 const base::string16& error_message,
49 const base::string16& version); 49 const base::string16& version);
50 50
51 // Update the UI to show the status of the upgrade. 51 // Update the UI to show the status of the upgrade.
52 void UpdateStatus(GoogleUpdateUpgradeResult result, 52 void UpdateStatus(GoogleUpdateUpgradeResult result,
53 GoogleUpdateErrorCode error_code, 53 GoogleUpdateErrorCode error_code,
54 const base::string16& error_message); 54 const base::string16& error_message);
55 55
56 // Got the intalled version so the handling of the UPGRADE_ALREADY_UP_TO_DATE 56 // Got the intalled version so the handling of the UPGRADE_ALREADY_UP_TO_DATE
57 // result case can now be completeb on the UI thread. 57 // result case can now be completeb on the UI thread.
58 void GotInstalledVersion(const Version& version); 58 void GotInstalledVersion(const Version& version);
59 59
60 // Returns a window that can be used for elevation. 60 // Returns a window that can be used for elevation.
61 gfx::AcceleratedWidget GetElevationParent(); 61 gfx::AcceleratedWidget GetElevationParent();
62 62
63 void BeginUpdateCheckOnFileThread(bool install_if_newer); 63 void BeginUpdateCheckOnFileThread(bool install_if_newer);
64 64
65 // Callback used to communicate update status to the client.
66 StatusCallback callback_;
67
65 // Used for callbacks. 68 // Used for callbacks.
66 base::WeakPtrFactory<VersionUpdaterWin> weak_factory_; 69 base::WeakPtrFactory<VersionUpdaterWin> weak_factory_;
67 70
68 // Callback used to communicate update status to the client.
69 StatusCallback callback_;
70
71 DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin); 71 DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin);
72 }; 72 };
73 73
74 // This class is used to read the version on the FILE thread and then call back 74 // This class is used to read the version on the FILE thread and then call back
75 // the version updater in the UI thread. Using a class helps better control 75 // the version updater in the UI thread. Using a class helps better control
76 // the lifespan of the Version independently of the lifespan of the version 76 // the lifespan of the Version independently of the lifespan of the version
77 // updater, which may die while asynchonicity is happening, thus the usage of 77 // updater, which may die while asynchonicity is happening, thus the usage of
78 // the WeakPtr, which can only be used from the thread that created it. 78 // the WeakPtr, which can only be used from the thread that created it.
79 class VersionReader 79 class VersionReader
80 : public base::RefCountedThreadSafe<VersionReader> { 80 : public base::RefCountedThreadSafe<VersionReader> {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 BeginUpdateCheck(task_runner, install_if_newer, GetElevationParent(), 261 BeginUpdateCheck(task_runner, install_if_newer, GetElevationParent(),
262 base::Bind(&VersionUpdaterWin::OnUpdateCheckResults, 262 base::Bind(&VersionUpdaterWin::OnUpdateCheckResults,
263 weak_factory_.GetWeakPtr())); 263 weak_factory_.GetWeakPtr()));
264 } 264 }
265 265
266 } // namespace 266 } // namespace
267 267
268 VersionUpdater* VersionUpdater::Create(content::BrowserContext* /* context */) { 268 VersionUpdater* VersionUpdater::Create(content::BrowserContext* /* context */) {
269 return new VersionUpdaterWin; 269 return new VersionUpdaterWin;
270 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698