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

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

Issue 1129733003: Fix detection of restart needed in VersionUpdaterWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/weak_ptr.h" 5 #include "base/memory/weak_ptr.h"
6 #include "base/strings/string16.h" 6 #include "base/strings/string16.h"
7 #include "base/task_runner_util.h"
7 #include "base/win/win_util.h" 8 #include "base/win/win_util.h"
8 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
9 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/first_run/upgrade_util_win.h" 11 #include "chrome/browser/first_run/upgrade_util.h"
11 #include "chrome/browser/google/google_update_win.h" 12 #include "chrome/browser/google/google_update_win.h"
12 #include "chrome/browser/lifetime/application_lifetime.h" 13 #include "chrome/browser/lifetime/application_lifetime.h"
13 #include "chrome/browser/ui/webui/help/version_updater.h" 14 #include "chrome/browser/ui/webui/help/version_updater.h"
14 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/aura/window_tree_host.h" 19 #include "ui/aura/window_tree_host.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
(...skipping 21 matching lines...) Expand all
42 void OnUpgradeComplete(const base::string16& new_version) override; 43 void OnUpgradeComplete(const base::string16& new_version) override;
43 void OnError(GoogleUpdateErrorCode error_code, 44 void OnError(GoogleUpdateErrorCode error_code,
44 const base::string16& error_message, 45 const base::string16& error_message,
45 const base::string16& new_version) override; 46 const base::string16& new_version) override;
46 47
47 private: 48 private:
48 #if defined(GOOGLE_CHROME_BUILD) 49 #if defined(GOOGLE_CHROME_BUILD)
49 void BeginUpdateCheckOnFileThread(bool install_update_if_possible); 50 void BeginUpdateCheckOnFileThread(bool install_update_if_possible);
50 #endif // GOOGLE_CHROME_BUILD 51 #endif // GOOGLE_CHROME_BUILD
51 52
53 // A task run on the UI thread with the result of checking for a pending
54 // restart.
55 void OnPendingRestartCheck(bool is_update_pending_restart);
56
52 // The widget owning the UI for the update check. 57 // The widget owning the UI for the update check.
53 gfx::AcceleratedWidget owner_widget_; 58 gfx::AcceleratedWidget owner_widget_;
54 59
55 // Callback used to communicate update status to the client. 60 // Callback used to communicate update status to the client.
56 StatusCallback callback_; 61 StatusCallback callback_;
57 62
58 // Used for callbacks. 63 // Used for callbacks.
59 base::WeakPtrFactory<VersionUpdaterWin> weak_factory_; 64 base::WeakPtrFactory<VersionUpdaterWin> weak_factory_;
60 65
61 DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin); 66 DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin);
(...skipping 30 matching lines...) Expand all
92 } 97 }
93 98
94 void VersionUpdaterWin::OnUpdateCheckComplete( 99 void VersionUpdaterWin::OnUpdateCheckComplete(
95 const base::string16& new_version) { 100 const base::string16& new_version) {
96 #if defined(GOOGLE_CHROME_BUILD) 101 #if defined(GOOGLE_CHROME_BUILD)
97 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
98 Status status = CHECKING; 103 Status status = CHECKING;
99 if (new_version.empty()) { 104 if (new_version.empty()) {
100 // Google Update says that no new version is available. Check to see if a 105 // Google Update says that no new version is available. Check to see if a
101 // restart is needed for a previously-applied update to take effect. 106 // restart is needed for a previously-applied update to take effect.
102 status = upgrade_util::IsRunningOldChrome() ? NEARLY_UPDATED : UPDATED; 107 if (base::PostTaskAndReplyWithResult(
Peter Kasting 2015/05/15 18:58:18 If this conditional fails, we'll run the callback
grt (UTC plus 2) 2015/05/15 19:57:16 This condition will only fail when Chrome is shutt
108 content::BrowserThread::GetBlockingPool(),
109 FROM_HERE,
110 base::Bind(&upgrade_util::IsUpdatePendingRestart),
111 base::Bind(&VersionUpdaterWin::OnPendingRestartCheck,
112 weak_factory_.GetWeakPtr()))) {
113 // Early exit since callback_ will be Run in OnPendingRestartCheck.
114 return;
115 }
103 } else { 116 } else {
104 // Notify the caller that the update is now beginning and initiate it. 117 // Notify the caller that the update is now beginning and initiate it.
105 status = UPDATING; 118 status = UPDATING;
106 BeginUpdateCheckOnFileThread(true /* install_update_if_possible */); 119 BeginUpdateCheckOnFileThread(true /* install_update_if_possible */);
107 } 120 }
108 callback_.Run(status, 0, base::string16()); 121 callback_.Run(status, 0, base::string16());
109 #endif // GOOGLE_CHROME_BUILD 122 #endif // GOOGLE_CHROME_BUILD
110 } 123 }
111 124
112 void VersionUpdaterWin::OnUpgradeProgress(int progress, 125 void VersionUpdaterWin::OnUpgradeProgress(int progress,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void VersionUpdaterWin::BeginUpdateCheckOnFileThread( 162 void VersionUpdaterWin::BeginUpdateCheckOnFileThread(
150 bool install_update_if_possible) { 163 bool install_update_if_possible) {
151 BeginUpdateCheck(content::BrowserThread::GetMessageLoopProxyForThread( 164 BeginUpdateCheck(content::BrowserThread::GetMessageLoopProxyForThread(
152 content::BrowserThread::FILE), 165 content::BrowserThread::FILE),
153 g_browser_process->GetApplicationLocale(), 166 g_browser_process->GetApplicationLocale(),
154 install_update_if_possible, owner_widget_, 167 install_update_if_possible, owner_widget_,
155 weak_factory_.GetWeakPtr()); 168 weak_factory_.GetWeakPtr());
156 } 169 }
157 #endif // GOOGLE_CHROME_BUILD 170 #endif // GOOGLE_CHROME_BUILD
158 171
172 void VersionUpdaterWin::OnPendingRestartCheck(bool is_update_pending_restart) {
173 callback_.Run(is_update_pending_restart ? NEARLY_UPDATED : UPDATED, 0,
174 base::string16());
175 }
176
159 } // namespace 177 } // namespace
160 178
161 VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) { 179 VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) {
162 // Retrieve the HWND for the browser window that is hosting the update check. 180 // Retrieve the HWND for the browser window that is hosting the update check.
163 // This will be used as the parent for a UAC prompt, if needed. It's possible 181 // This will be used as the parent for a UAC prompt, if needed. It's possible
164 // this this window will no longer have focus by the time UAC is needed. In 182 // this this window will no longer have focus by the time UAC is needed. In
165 // that case, the UAC prompt will appear in the taskbar and will require a 183 // that case, the UAC prompt will appear in the taskbar and will require a
166 // user click. This is the least surprising thing we can do for the user, and 184 // user click. This is the least surprising thing we can do for the user, and
167 // is the intended behavior for Windows applications. It's also possible that 185 // is the intended behavior for Windows applications. It's also possible that
168 // the browser window hosting the update check will have been closed by the 186 // the browser window hosting the update check will have been closed by the
169 // time the UAC prompt is needed. This will behave similarly. 187 // time the UAC prompt is needed. This will behave similarly.
170 return new VersionUpdaterWin(web_contents->GetTopLevelNativeWindow() 188 return new VersionUpdaterWin(web_contents->GetTopLevelNativeWindow()
171 ->GetHost() 189 ->GetHost()
172 ->GetAcceleratedWidget()); 190 ->GetAcceleratedWidget());
173 } 191 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698