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

Side by Side Diff: chrome/installer/launcher_support/chrome_launcher_support.cc

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 years 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/installer/launcher_support/chrome_launcher_support.h" 5 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <tchar.h> 8 #include <tchar.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const char kChromeAppLauncher[] = "app-launcher"; 43 const char kChromeAppLauncher[] = "app-launcher";
44 const wchar_t kChromeExe[] = L"chrome.exe"; 44 const wchar_t kChromeExe[] = L"chrome.exe";
45 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; 45 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
46 const wchar_t kUninstallStringField[] = L"UninstallString"; 46 const wchar_t kUninstallStringField[] = L"UninstallString";
47 47
48 // Reads a string value from the specified product's "ClientState" registry key. 48 // Reads a string value from the specified product's "ClientState" registry key.
49 // Returns true iff the value is present and successfully read. 49 // Returns true iff the value is present and successfully read.
50 bool GetClientStateValue(InstallationLevel level, 50 bool GetClientStateValue(InstallationLevel level,
51 const wchar_t* app_guid, 51 const wchar_t* app_guid,
52 const wchar_t* value_name, 52 const wchar_t* value_name,
53 string16* value) { 53 base::string16* value) {
54 HKEY root_key = (level == USER_LEVEL_INSTALLATION) ? 54 HKEY root_key = (level == USER_LEVEL_INSTALLATION) ?
55 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 55 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
56 string16 subkey(kGoogleRegClientStateKey); 56 base::string16 subkey(kGoogleRegClientStateKey);
57 subkey.append(1, L'\\').append(app_guid); 57 subkey.append(1, L'\\').append(app_guid);
58 base::win::RegKey reg_key; 58 base::win::RegKey reg_key;
59 // Google Update always uses 32bit hive. 59 // Google Update always uses 32bit hive.
60 if (reg_key.Open(root_key, subkey.c_str(), 60 if (reg_key.Open(root_key, subkey.c_str(),
61 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { 61 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
62 if (reg_key.ReadValue(value_name, value) == ERROR_SUCCESS) { 62 if (reg_key.ReadValue(value_name, value) == ERROR_SUCCESS) {
63 return true; 63 return true;
64 } 64 }
65 } 65 }
66 return false; 66 return false;
67 } 67 }
68 68
69 // Determines whether the specified product has a key in "Clients". This 69 // Determines whether the specified product has a key in "Clients". This
70 // indicates whether the product is installed at the given level. 70 // indicates whether the product is installed at the given level.
71 bool IsProductInstalled(InstallationLevel level, const wchar_t* app_guid) { 71 bool IsProductInstalled(InstallationLevel level, const wchar_t* app_guid) {
72 HKEY root_key = (level == USER_LEVEL_INSTALLATION) ? 72 HKEY root_key = (level == USER_LEVEL_INSTALLATION) ?
73 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 73 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
74 string16 subkey(kGoogleRegClientsKey); 74 base::string16 subkey(kGoogleRegClientsKey);
75 subkey.append(1, L'\\').append(app_guid); 75 subkey.append(1, L'\\').append(app_guid);
76 base::win::RegKey reg_key; 76 base::win::RegKey reg_key;
77 // Google Update always uses 32bit hive. 77 // Google Update always uses 32bit hive.
78 return reg_key.Open(root_key, subkey.c_str(), 78 return reg_key.Open(root_key, subkey.c_str(),
79 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS && 79 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS &&
80 reg_key.HasValue(kRegVersionField); 80 reg_key.HasValue(kRegVersionField);
81 } 81 }
82 82
83 bool IsAppLauncherEnabledAtLevel(InstallationLevel level) { 83 bool IsAppLauncherEnabledAtLevel(InstallationLevel level) {
84 string16 uninstall_arguments; 84 base::string16 uninstall_arguments;
85 if (GetClientStateValue(level, 85 if (GetClientStateValue(level,
86 kAppHostAppId, 86 kAppHostAppId,
87 kUninstallArgumentsField, 87 kUninstallArgumentsField,
88 &uninstall_arguments)) { 88 &uninstall_arguments)) {
89 return CommandLine::FromString(L"dummy.exe " + uninstall_arguments) 89 return CommandLine::FromString(L"dummy.exe " + uninstall_arguments)
90 .HasSwitch(kChromeAppLauncher) && 90 .HasSwitch(kChromeAppLauncher) &&
91 !GetAppHostPathForInstallationLevel(level).empty(); 91 !GetAppHostPathForInstallationLevel(level).empty();
92 } 92 }
93 return false; 93 return false;
94 } 94 }
95 95
96 // Reads the path to setup.exe from the value "UninstallString" within the 96 // Reads the path to setup.exe from the value "UninstallString" within the
97 // specified product's "ClientState" registry key. Returns an empty FilePath if 97 // specified product's "ClientState" registry key. Returns an empty FilePath if
98 // an error occurs or the product is not installed at the specified level. 98 // an error occurs or the product is not installed at the specified level.
99 base::FilePath GetSetupExeFromRegistry(InstallationLevel level, 99 base::FilePath GetSetupExeFromRegistry(InstallationLevel level,
100 const wchar_t* app_guid) { 100 const wchar_t* app_guid) {
101 string16 uninstall; 101 base::string16 uninstall;
102 if (GetClientStateValue(level, app_guid, kUninstallStringField, &uninstall)) { 102 if (GetClientStateValue(level, app_guid, kUninstallStringField, &uninstall)) {
103 base::FilePath setup_exe_path(uninstall); 103 base::FilePath setup_exe_path(uninstall);
104 if (base::PathExists(setup_exe_path)) 104 if (base::PathExists(setup_exe_path))
105 return setup_exe_path; 105 return setup_exe_path;
106 } 106 }
107 return base::FilePath(); 107 return base::FilePath();
108 } 108 }
109 109
110 // Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe) 110 // Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe)
111 // at the specified level, given |setup_exe_path| from Omaha client state. 111 // at the specified level, given |setup_exe_path| from Omaha client state.
(...skipping 16 matching lines...) Expand all
128 } 128 }
129 return base::FilePath(); 129 return base::FilePath();
130 } 130 }
131 131
132 } // namespace 132 } // namespace
133 133
134 void UninstallLegacyAppLauncher(InstallationLevel level) { 134 void UninstallLegacyAppLauncher(InstallationLevel level) {
135 base::FilePath setup_exe(GetSetupExeFromRegistry(level, kAppHostAppId)); 135 base::FilePath setup_exe(GetSetupExeFromRegistry(level, kAppHostAppId));
136 if (setup_exe.empty()) 136 if (setup_exe.empty())
137 return; 137 return;
138 string16 uninstall_arguments; 138 base::string16 uninstall_arguments;
139 if (GetClientStateValue(level, 139 if (GetClientStateValue(level,
140 kAppHostAppId, 140 kAppHostAppId,
141 kUninstallArgumentsField, 141 kUninstallArgumentsField,
142 &uninstall_arguments)) { 142 &uninstall_arguments)) {
143 CommandLine uninstall_cmd = CommandLine::FromString( 143 CommandLine uninstall_cmd = CommandLine::FromString(
144 L"\"" + setup_exe.value() + L"\" " + uninstall_arguments); 144 L"\"" + setup_exe.value() + L"\" " + uninstall_arguments);
145 145
146 VLOG(1) << "Uninstalling legacy app launcher with command line: " 146 VLOG(1) << "Uninstalling legacy app launcher with command line: "
147 << uninstall_cmd.GetCommandLineString(); 147 << uninstall_cmd.GetCommandLineString();
148 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL); 148 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 bool IsAppLauncherPresent() { 208 bool IsAppLauncherPresent() {
209 return GetAppLauncherInstallationState() != NOT_INSTALLED; 209 return GetAppLauncherInstallationState() != NOT_INSTALLED;
210 } 210 }
211 211
212 bool IsChromeBrowserPresent() { 212 bool IsChromeBrowserPresent() {
213 return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) || 213 return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) ||
214 IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid); 214 IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid);
215 } 215 }
216 216
217 } // namespace chrome_launcher_support 217 } // namespace chrome_launcher_support
OLDNEW
« no previous file with comments | « chrome/installer/gcapi/gcapi_reactivation_test.cc ('k') | chrome/installer/setup/archive_patch_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698