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

Side by Side Diff: win8/delegate_execute/chrome_util.cc

Issue 119733002: Add base:: to string16s in win8/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge 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
« no previous file with comments | « no previous file | win8/delegate_execute/command_execute_impl.h » ('j') | 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 "win8/delegate_execute/chrome_util.h" 5 #include "win8/delegate_execute/chrome_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
(...skipping 27 matching lines...) Expand all
38 const base::FilePath::CharType kNewChromeExe[] = 38 const base::FilePath::CharType kNewChromeExe[] =
39 FILE_PATH_LITERAL("new_chrome.exe"); 39 FILE_PATH_LITERAL("new_chrome.exe");
40 const wchar_t kRenameCommandValue[] = L"cmd"; 40 const wchar_t kRenameCommandValue[] = L"cmd";
41 const wchar_t kRegPathChromeClientBase[] = 41 const wchar_t kRegPathChromeClientBase[] =
42 L"Software\\Google\\Update\\Clients\\"; 42 L"Software\\Google\\Update\\Clients\\";
43 43
44 // Returns the name of the global event used to detect if |chrome_exe| is in 44 // Returns the name of the global event used to detect if |chrome_exe| is in
45 // use by a browser process. 45 // use by a browser process.
46 // TODO(grt): Move this somewhere central so it can be used by both this 46 // TODO(grt): Move this somewhere central so it can be used by both this
47 // IsBrowserRunning (below) and IsBrowserAlreadyRunning (browser_util_win.cc). 47 // IsBrowserRunning (below) and IsBrowserAlreadyRunning (browser_util_win.cc).
48 string16 GetEventName(const base::FilePath& chrome_exe) { 48 base::string16 GetEventName(const base::FilePath& chrome_exe) {
49 static wchar_t const kEventPrefix[] = L"Global\\"; 49 static wchar_t const kEventPrefix[] = L"Global\\";
50 const size_t prefix_len = arraysize(kEventPrefix) - 1; 50 const size_t prefix_len = arraysize(kEventPrefix) - 1;
51 string16 name; 51 base::string16 name;
52 name.reserve(prefix_len + chrome_exe.value().size()); 52 name.reserve(prefix_len + chrome_exe.value().size());
53 name.assign(kEventPrefix, prefix_len); 53 name.assign(kEventPrefix, prefix_len);
54 name.append(chrome_exe.value()); 54 name.append(chrome_exe.value());
55 std::replace(name.begin() + prefix_len, name.end(), '\\', '!'); 55 std::replace(name.begin() + prefix_len, name.end(), '\\', '!');
56 std::transform(name.begin() + prefix_len, name.end(), 56 std::transform(name.begin() + prefix_len, name.end(),
57 name.begin() + prefix_len, tolower); 57 name.begin() + prefix_len, tolower);
58 return name; 58 return name;
59 } 59 }
60 60
61 // Returns true if |chrome_exe| is in use by a browser process. In this case, 61 // Returns true if |chrome_exe| is in use by a browser process. In this case,
(...skipping 11 matching lines...) Expand all
73 return false; 73 return false;
74 } 74 }
75 75
76 // Returns true if the file new_chrome.exe exists in the same directory as 76 // Returns true if the file new_chrome.exe exists in the same directory as
77 // |chrome_exe|. 77 // |chrome_exe|.
78 bool NewChromeExeExists(const base::FilePath& chrome_exe) { 78 bool NewChromeExeExists(const base::FilePath& chrome_exe) {
79 base::FilePath new_chrome_exe(chrome_exe.DirName().Append(kNewChromeExe)); 79 base::FilePath new_chrome_exe(chrome_exe.DirName().Append(kNewChromeExe));
80 return base::PathExists(new_chrome_exe); 80 return base::PathExists(new_chrome_exe);
81 } 81 }
82 82
83 bool GetUpdateCommand(bool is_per_user, string16* update_command) { 83 bool GetUpdateCommand(bool is_per_user, base::string16* update_command) {
84 const HKEY root = is_per_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 84 const HKEY root = is_per_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
85 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 85 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
86 string16 reg_path_chrome_client = kRegPathChromeClientBase; 86 base::string16 reg_path_chrome_client = kRegPathChromeClientBase;
87 reg_path_chrome_client.append(dist->GetAppGuid()); 87 reg_path_chrome_client.append(dist->GetAppGuid());
88 base::win::RegKey key(root, reg_path_chrome_client.c_str(), KEY_QUERY_VALUE); 88 base::win::RegKey key(root, reg_path_chrome_client.c_str(), KEY_QUERY_VALUE);
89 89
90 return key.ReadValue(kRenameCommandValue, update_command) == ERROR_SUCCESS; 90 return key.ReadValue(kRenameCommandValue, update_command) == ERROR_SUCCESS;
91 } 91 }
92 92
93 #endif // GOOGLE_CHROME_BUILD 93 #endif // GOOGLE_CHROME_BUILD
94 94
95 } // namespace 95 } // namespace
96 96
97 namespace delegate_execute { 97 namespace delegate_execute {
98 98
99 void UpdateChromeIfNeeded(const base::FilePath& chrome_exe) { 99 void UpdateChromeIfNeeded(const base::FilePath& chrome_exe) {
100 #if defined(GOOGLE_CHROME_BUILD) 100 #if defined(GOOGLE_CHROME_BUILD)
101 // Nothing to do if a browser is already running or if there's no 101 // Nothing to do if a browser is already running or if there's no
102 // new_chrome.exe. 102 // new_chrome.exe.
103 if (IsBrowserRunning(chrome_exe) || !NewChromeExeExists(chrome_exe)) 103 if (IsBrowserRunning(chrome_exe) || !NewChromeExeExists(chrome_exe))
104 return; 104 return;
105 105
106 base::win::ScopedHandle process_handle; 106 base::win::ScopedHandle process_handle;
107 107
108 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { 108 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) {
109 // Read the update command from the registry. 109 // Read the update command from the registry.
110 string16 update_command; 110 base::string16 update_command;
111 if (!GetUpdateCommand(true, &update_command)) { 111 if (!GetUpdateCommand(true, &update_command)) {
112 AtlTrace("%hs. Failed to read update command from registry.\n", 112 AtlTrace("%hs. Failed to read update command from registry.\n",
113 __FUNCTION__); 113 __FUNCTION__);
114 } else { 114 } else {
115 // Run the update command. 115 // Run the update command.
116 base::LaunchOptions launch_options; 116 base::LaunchOptions launch_options;
117 launch_options.start_hidden = true; 117 launch_options.start_hidden = true;
118 if (!base::LaunchProcess(update_command, launch_options, 118 if (!base::LaunchProcess(update_command, launch_options,
119 &process_handle)) { 119 &process_handle)) {
120 AtlTrace("%hs. Failed to launch command to finalize update; " 120 AtlTrace("%hs. Failed to launch command to finalize update; "
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 AtlTrace("%hs. Failed to finalize update with exit code %d.\n", 155 AtlTrace("%hs. Failed to finalize update with exit code %d.\n",
156 __FUNCTION__, exit_code); 156 __FUNCTION__, exit_code);
157 } else { 157 } else {
158 AtlTrace("%hs. Finalized pending update.\n", __FUNCTION__); 158 AtlTrace("%hs. Finalized pending update.\n", __FUNCTION__);
159 } 159 }
160 } 160 }
161 #endif 161 #endif
162 } 162 }
163 163
164 } // delegate_execute 164 } // delegate_execute
OLDNEW
« no previous file with comments | « no previous file | win8/delegate_execute/command_execute_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698