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

Side by Side Diff: chrome/installer/gcapi/gcapi.cc

Issue 10546149: Factor out logic to find chrome.exe from Omaha client state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 // NOTE: This code is a legacy utility API for partners to check whether 5 // NOTE: This code is a legacy utility API for partners to check whether
6 // Chrome can be installed and launched. Recent updates are being made 6 // Chrome can be installed and launched. Recent updates are being made
7 // to add new functionality. These updates use code from Chromium, the old 7 // to add new functionality. These updates use code from Chromium, the old
8 // coded against the win32 api directly. If you have an itch to shave a 8 // coded against the win32 api directly. If you have an itch to shave a
9 // yak, feel free to re-write the old code too. 9 // yak, feel free to re-write the old code too.
10 10
(...skipping 13 matching lines...) Expand all
24 #include "base/basictypes.h" 24 #include "base/basictypes.h"
25 #include "base/file_path.h" 25 #include "base/file_path.h"
26 #include "base/file_util.h" 26 #include "base/file_util.h"
27 #include "base/process_util.h" 27 #include "base/process_util.h"
28 #include "base/string_number_conversions.h" 28 #include "base/string_number_conversions.h"
29 #include "base/time.h" 29 #include "base/time.h"
30 #include "base/win/registry.h" 30 #include "base/win/registry.h"
31 #include "base/win/scoped_com_initializer.h" 31 #include "base/win/scoped_com_initializer.h"
32 #include "base/win/scoped_comptr.h" 32 #include "base/win/scoped_comptr.h"
33 #include "base/win/scoped_handle.h" 33 #include "base/win/scoped_handle.h"
34 #include "chrome/tools/launcher_support/chrome_launcher_support.h"
Vitaly Buka (NO REVIEWS) 2012/06/13 18:01:36 invalid order
robertshield 2012/06/13 18:01:53 move this include down to line 39
erikwright (departed) 2012/06/13 19:43:43 Done.
erikwright (departed) 2012/06/13 19:43:43 Done.
34 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" 35 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h"
35 #include "chrome/installer/gcapi/gcapi_reactivation.h" 36 #include "chrome/installer/gcapi/gcapi_reactivation.h"
36 #include "chrome/installer/util/google_update_constants.h" 37 #include "chrome/installer/util/google_update_constants.h"
37 #include "chrome/installer/util/util_constants.h" 38 #include "chrome/installer/util/util_constants.h"
38 #include "google_update/google_update_idl.h" 39 #include "google_update/google_update_idl.h"
39 40
40 using base::Time; 41 using base::Time;
41 using base::TimeDelta; 42 using base::TimeDelta;
42 using base::win::RegKey; 43 using base::win::RegKey;
43 using base::win::ScopedCOMInitializer; 44 using base::win::ScopedCOMInitializer;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 HKEY install_key = HKEY_LOCAL_MACHINE; 367 HKEY install_key = HKEY_LOCAL_MACHINE;
367 if (!IsChromeInstalled(install_key)) { 368 if (!IsChromeInstalled(install_key)) {
368 install_key = HKEY_CURRENT_USER; 369 install_key = HKEY_CURRENT_USER;
369 if (!IsChromeInstalled(install_key)) { 370 if (!IsChromeInstalled(install_key)) {
370 return false; 371 return false;
371 } 372 }
372 } 373 }
373 374
374 // Now grab the uninstall string from the appropriate ClientState key 375 // Now grab the uninstall string from the appropriate ClientState key
375 // and use that as the base for a path to chrome.exe. 376 // and use that as the base for a path to chrome.exe.
376 FilePath chrome_exe_path; 377 FilePath chrome_exe_path = chrome_launcher_support::GetAnyChromePath();
robertshield 2012/06/13 18:01:53 prefer constructor syntax
erikwright (departed) 2012/06/13 19:43:43 Done.
377 RegKey client_state(install_key, kChromeRegClientStateKey, KEY_QUERY_VALUE); 378 if (chrome_exe_path.empty()) {
378 if (client_state.Valid()) {
379 std::wstring uninstall_string;
380 if (client_state.ReadValue(installer::kUninstallStringField,
381 &uninstall_string) == ERROR_SUCCESS) {
382 // The uninstall path contains the path to setup.exe which is two levels
383 // down from chrome.exe. Move up two levels (plus one to drop the file
384 // name) and look for chrome.exe from there.
385 FilePath uninstall_path(uninstall_string);
386 chrome_exe_path = uninstall_path.DirName()
387 .DirName()
388 .DirName()
389 .Append(installer::kChromeExe);
390 if (!file_util::PathExists(chrome_exe_path)) {
391 // By way of mild future proofing, look up one to see if there's a
392 // chrome.exe in the version directory
393 chrome_exe_path =
394 uninstall_path.DirName().DirName().Append(installer::kChromeExe);
395 }
396 }
397 }
398
399 if (!file_util::PathExists(chrome_exe_path)) {
400 return false; 379 return false;
401 } 380 }
402 381
403 ScopedCOMInitializer com_initializer; 382 ScopedCOMInitializer com_initializer;
404 if (::CoInitializeSecurity(NULL, -1, NULL, NULL, 383 if (::CoInitializeSecurity(NULL, -1, NULL, NULL,
405 RPC_C_AUTHN_LEVEL_PKT_PRIVACY, 384 RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
406 RPC_C_IMP_LEVEL_IDENTIFY, NULL, 385 RPC_C_IMP_LEVEL_IDENTIFY, NULL,
407 EOAC_DYNAMIC_CLOAKING, NULL) != S_OK) { 386 EOAC_DYNAMIC_CLOAKING, NULL) != S_OK) {
408 return false; 387 return false;
409 } 388 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 result = TRUE; 591 result = TRUE;
613 } else { 592 } else {
614 if (error_code) 593 if (error_code)
615 *error_code = REACTIVATE_ERROR_REACTIVATION_FAILED; 594 *error_code = REACTIVATE_ERROR_REACTIVATION_FAILED;
616 } 595 }
617 } 596 }
618 597
619 return result; 598 return result;
620 } 599 }
621 600
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698