OLD | NEW |
---|---|
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/util/google_update_util.h" | 5 #include "chrome/installer/util/google_update_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 const char kEnvVariableUntrustedData[] = "GoogleUpdateUntrustedData"; | 35 const char kEnvVariableUntrustedData[] = "GoogleUpdateUntrustedData"; |
36 const int kEnvVariableUntrustedDataMaxLength = 4096; | 36 const int kEnvVariableUntrustedDataMaxLength = 4096; |
37 | 37 |
38 // Returns true if Google Update is present at the given level. | 38 // Returns true if Google Update is present at the given level. |
39 bool IsGoogleUpdatePresent(bool system_install) { | 39 bool IsGoogleUpdatePresent(bool system_install) { |
40 // Using the existence of version key in the registry to decide. | 40 // Using the existence of version key in the registry to decide. |
41 return GoogleUpdateSettings::GetGoogleUpdateVersion(system_install).IsValid(); | 41 return GoogleUpdateSettings::GetGoogleUpdateVersion(system_install).IsValid(); |
42 } | 42 } |
43 | 43 |
44 // Returns GoogleUpdateSetup.exe's executable path at specified level. | 44 // Returns GoogleUpdate.exe's executable path at specified level. |
45 // or an empty path if none is found. | 45 // or an empty path if none is found. |
46 FilePath GetGoogleUpdateSetupExe(bool system_install) { | 46 FilePath GetGoogleUpdateExe(bool system_install) { |
47 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 47 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
48 RegKey update_key; | 48 RegKey update_key; |
49 | 49 |
50 if (update_key.Open(root_key, kRegPathGoogleUpdate, KEY_QUERY_VALUE) == | 50 if (update_key.Open(root_key, kRegPathGoogleUpdate, KEY_QUERY_VALUE) == |
51 ERROR_SUCCESS) { | 51 ERROR_SUCCESS) { |
52 string16 path_str; | 52 string16 path_str; |
53 string16 version_str; | 53 string16 version_str; |
grt (UTC plus 2)
2013/02/12 18:31:56
unused
| |
54 if ((update_key.ReadValue(kRegPathField, &path_str) == ERROR_SUCCESS) && | 54 if ((update_key.ReadValue(kRegPathField, &path_str) == ERROR_SUCCESS)) { |
grt (UTC plus 2)
2013/02/12 18:31:56
nit: no braces
| |
55 (update_key.ReadValue(kRegGoogleUpdateVersion, &version_str) == | 55 return base::FilePath(path_str); |
56 ERROR_SUCCESS)) { | |
57 return base::FilePath(path_str).DirName().Append(version_str). | |
58 Append(kGoogleUpdateSetupExe); | |
59 } | 56 } |
60 } | 57 } |
61 return base::FilePath(); | 58 return base::FilePath(); |
62 } | 59 } |
63 | 60 |
64 // If Google Update is present at system-level, sets |cmd_string| to the command | 61 // If Google Update is present at system-level, sets |cmd_string| to the command |
65 // line to install Google Update at user-level and returns true. | 62 // line to install Google Update at user-level and returns true. |
66 // Otherwise, clears |cmd_string| and returns false. | 63 // Otherwise, clears |cmd_string| and returns false. |
67 bool GetUserLevelGoogleUpdateInstallCommandLine(string16* cmd_string) { | 64 bool GetUserLevelGoogleUpdateInstallCommandLine(string16* cmd_string) { |
68 cmd_string->clear(); | 65 cmd_string->clear(); |
69 base::FilePath google_update_setup( | 66 base::FilePath google_update_exe(GetGoogleUpdateExe(true)); // system-level. |
70 GetGoogleUpdateSetupExe(true)); // system-level. | 67 if (!google_update_exe.empty()) { |
71 if (!google_update_setup.empty()) { | 68 CommandLine cmd(google_update_exe); |
72 CommandLine cmd(google_update_setup); | |
73 // Appends parameter "/install runtime=true&needsadmin=false /silent" | 69 // Appends parameter "/install runtime=true&needsadmin=false /silent" |
74 // Constants are found in code.google.com/p/omaha/common/const_cmd_line.h. | 70 // Constants are found in code.google.com/p/omaha/common/const_cmd_line.h. |
75 cmd.AppendArg("/install"); | 71 cmd.AppendArg("/install"); |
76 // The "&" can be used in base::LaunchProcess() without quotation | 72 // The "&" can be used in base::LaunchProcess() without quotation |
77 // (this is problematic only if run from command prompt). | 73 // (this is problematic only if run from command prompt). |
78 cmd.AppendArg("runtime=true&needsadmin=false"); | 74 cmd.AppendArg("runtime=true&needsadmin=false"); |
79 cmd.AppendArg("/silent"); | 75 cmd.AppendArg("/silent"); |
80 *cmd_string = cmd.GetCommandLineString(); | 76 *cmd_string = cmd.GetCommandLineString(); |
81 } | 77 } |
82 return !cmd_string->empty(); | 78 return !cmd_string->empty(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 std::map<std::string, std::string>::const_iterator data_it( | 203 std::map<std::string, std::string>::const_iterator data_it( |
208 untrusted_data.find(key)); | 204 untrusted_data.find(key)); |
209 if (data_it != untrusted_data.end()) | 205 if (data_it != untrusted_data.end()) |
210 return data_it->second; | 206 return data_it->second; |
211 } | 207 } |
212 | 208 |
213 return std::string(); | 209 return std::string(); |
214 } | 210 } |
215 | 211 |
216 } // namespace google_update | 212 } // namespace google_update |
OLD | NEW |