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

Side by Side Diff: chrome/browser/google/google_update_win.cc

Issue 10698106: Switch about box to web ui on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: With GoogleUpdate on Windows only. Created 8 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/google/google_update.h" 5 #include "chrome/browser/google/google_update_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 //////////////////////////////////////////////////////////////////////////////// 228 ////////////////////////////////////////////////////////////////////////////////
229 // GoogleUpdate, public: 229 // GoogleUpdate, public:
230 230
231 GoogleUpdate::GoogleUpdate() 231 GoogleUpdate::GoogleUpdate()
232 : listener_(NULL) { 232 : listener_(NULL) {
233 } 233 }
234 234
235 GoogleUpdate::~GoogleUpdate() { 235 GoogleUpdate::~GoogleUpdate() {
236 } 236 }
237 237
238 void GoogleUpdate::CheckForUpdate(bool install_if_newer, 238 void GoogleUpdate::CheckForUpdate(bool install_if_newer, HWND window) {
239 views::Widget* window) {
240 // We need to shunt this request over to InitiateGoogleUpdateCheck and have 239 // We need to shunt this request over to InitiateGoogleUpdateCheck and have
241 // it run in the file thread. 240 // it run in the file thread.
242 BrowserThread::PostTask( 241 BrowserThread::PostTask(
243 BrowserThread::FILE, FROM_HERE, 242 BrowserThread::FILE, FROM_HERE,
244 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this, 243 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this,
245 install_if_newer, window, MessageLoop::current())); 244 install_if_newer, window, MessageLoop::current()));
246 } 245 }
247 246
248 //////////////////////////////////////////////////////////////////////////////// 247 ////////////////////////////////////////////////////////////////////////////////
249 // GoogleUpdate, private: 248 // GoogleUpdate, private:
250 249
251 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, 250 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
252 views::Widget* window, 251 HWND window,
253 MessageLoop* main_loop) { 252 MessageLoop* main_loop) {
254 FilePath chrome_exe; 253 FilePath chrome_exe;
255 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) 254 if (!PathService::Get(base::DIR_EXE, &chrome_exe))
256 NOTREACHED(); 255 NOTREACHED();
257 256
258 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe); 257 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe);
259 if (error_code != GOOGLE_UPDATE_NO_ERROR) { 258 if (error_code != GOOGLE_UPDATE_NO_ERROR) {
260 main_loop->PostTask( 259 main_loop->PostTask(
261 FROM_HERE, 260 FROM_HERE,
262 base::Bind(&GoogleUpdate::ReportResults, this, 261 base::Bind(&GoogleUpdate::ReportResults, this,
(...skipping 25 matching lines...) Expand all
288 287
289 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { 288 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) {
290 hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); 289 hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass);
291 } else { 290 } else {
292 // The Update operation needs Admin privileges for writing 291 // The Update operation needs Admin privileges for writing
293 // to %ProgramFiles%. On Vista we need to elevate before instantiating 292 // to %ProgramFiles%. On Vista we need to elevate before instantiating
294 // the updater instance. 293 // the updater instance.
295 if (!install_if_newer) { 294 if (!install_if_newer) {
296 hr = on_demand.CreateInstance(CLSID_OnDemandMachineAppsClass); 295 hr = on_demand.CreateInstance(CLSID_OnDemandMachineAppsClass);
297 } else { 296 } else {
298 HWND foreground_hwnd = NULL;
299 if (window != NULL) {
300 foreground_hwnd = window->GetNativeWindow();
301 }
302
303 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, 297 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass,
304 IID_IGoogleUpdate, foreground_hwnd, 298 IID_IGoogleUpdate, window,
305 reinterpret_cast<void**>(on_demand.Receive())); 299 reinterpret_cast<void**>(on_demand.Receive()));
306 } 300 }
307 system_level = true; 301 system_level = true;
308 } 302 }
309 303
310 if (hr != S_OK) { 304 if (hr != S_OK) {
311 GoogleUpdateErrorCode error = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; 305 GoogleUpdateErrorCode error = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND;
312 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); 306 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr);
313 if (system_level) 307 if (system_level)
314 error_code += L" -- system level"; 308 error_code += L" -- system level";
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 MessageLoop* main_loop) { 398 MessageLoop* main_loop) {
405 NOTREACHED() << "Communication with Google Update failed: " << hr 399 NOTREACHED() << "Communication with Google Update failed: " << hr
406 << " error: " << error_code 400 << " error: " << error_code
407 << ", message: " << error_message.c_str(); 401 << ", message: " << error_message.c_str();
408 main_loop->PostTask( 402 main_loop->PostTask(
409 FROM_HERE, 403 FROM_HERE,
410 base::Bind(&GoogleUpdate::ReportResults, this, 404 base::Bind(&GoogleUpdate::ReportResults, this,
411 UPGRADE_ERROR, error_code, error_message)); 405 UPGRADE_ERROR, error_code, error_message));
412 return false; 406 return false;
413 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698