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

Side by Side Diff: ceee/ie/common/ceee_module_util.cc

Issue 5103001: Add shared macros for stringizing and converting ANSI string constants... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | « base/stringize_macros_unittest.cc ('k') | media/base/media_posix.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // CEEE module-wide utilities. 5 // CEEE module-wide utilities.
6 6
7 #include "ceee/ie/common/ceee_module_util.h" 7 #include "ceee/ie/common/ceee_module_util.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stringize_macros.h"
13 #include "base/win/registry.h" 14 #include "base/win/registry.h"
14 #include "ceee/common/process_utils_win.h" 15 #include "ceee/common/process_utils_win.h"
15 #include "chrome/installer/util/google_update_constants.h" 16 #include "chrome/installer/util/google_update_constants.h"
16 17
17 #include "version.h" // NOLINT 18 #include "version.h" // NOLINT
18 19
19 // TODO(joi@chromium.org): would be nice to move these (and non-L counterparts)
20 // to e.g. base/string_util.h
21 #define LSTRINGIZE2(x) L ## #x
22 #define LSTRINGIZE(x) LSTRINGIZE2(x)
23
24 namespace { 20 namespace {
25 21
26 const wchar_t* kRegistryPath = L"SOFTWARE\\Google\\CEEE"; 22 const wchar_t* kRegistryPath = L"SOFTWARE\\Google\\CEEE";
27 const wchar_t* kRegistryValueToolbandIsHidden = L"toolband_is_hidden"; 23 const wchar_t* kRegistryValueToolbandIsHidden = L"toolband_is_hidden";
28 const wchar_t* kRegistryValueToolbandPlaced = L"toolband_placed"; 24 const wchar_t* kRegistryValueToolbandPlaced = L"toolband_placed";
29 const wchar_t* kRegistryValueCrxInstalledPath = L"crx_installed_path"; 25 const wchar_t* kRegistryValueCrxInstalledPath = L"crx_installed_path";
30 const wchar_t* kRegistryValueCrxInstalledTime = L"crx_installed_time"; 26 const wchar_t* kRegistryValueCrxInstalledTime = L"crx_installed_time";
31 const wchar_t* kRegistryValueCrxInstalledByVersion = 27 const wchar_t* kRegistryValueCrxInstalledByVersion =
32 L"crx_installed_runtime_version"; 28 L"crx_installed_runtime_version";
33 29
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return true; 185 return true;
190 } else { 186 } else {
191 // We also check that the current version of Chrome was the one 187 // We also check that the current version of Chrome was the one
192 // that attempted installation; if not, changes such as a change 188 // that attempted installation; if not, changes such as a change
193 // in the location of a profile directory might have occurred, and 189 // in the location of a profile directory might have occurred, and
194 // we might need to retry installation. 190 // we might need to retry installation.
195 std::wstring version_string; 191 std::wstring version_string;
196 base::win::RegKey hkcu(HKEY_CURRENT_USER, kRegistryPath, KEY_READ); 192 base::win::RegKey hkcu(HKEY_CURRENT_USER, kRegistryPath, KEY_READ);
197 success = hkcu.ReadValue( 193 success = hkcu.ReadValue(
198 kRegistryValueCrxInstalledByVersion, &version_string); 194 kRegistryValueCrxInstalledByVersion, &version_string);
199 return !success || version_string != LSTRINGIZE(CHROME_VERSION_STRING); 195 return !success || version_string != TO_L_STRING(CHROME_VERSION_STRING);
200 } 196 }
201 } 197 }
202 198
203 return true; 199 return true;
204 } 200 }
205 201
206 return false; 202 return false;
207 } 203 }
208 204
209 void SetInstalledExtensionPath(const FilePath& path) { 205 void SetInstalledExtensionPath(const FilePath& path) {
210 base::PlatformFileInfo extension_info; 206 base::PlatformFileInfo extension_info;
211 const bool success = file_util::GetFileInfo(path, &extension_info); 207 const bool success = file_util::GetFileInfo(path, &extension_info);
212 const int64 crx_time = success ? 208 const int64 crx_time = success ?
213 extension_info.last_modified.ToInternalValue() : 209 extension_info.last_modified.ToInternalValue() :
214 base::Time::Now().ToInternalValue(); 210 base::Time::Now().ToInternalValue();
215 211
216 base::win::RegKey key(HKEY_CURRENT_USER, kRegistryPath, KEY_WRITE); 212 base::win::RegKey key(HKEY_CURRENT_USER, kRegistryPath, KEY_WRITE);
217 bool write_result = key.WriteValue(kRegistryValueCrxInstalledTime, 213 bool write_result = key.WriteValue(kRegistryValueCrxInstalledTime,
218 &crx_time, 214 &crx_time,
219 sizeof(crx_time), 215 sizeof(crx_time),
220 REG_QWORD); 216 REG_QWORD);
221 DCHECK(write_result); 217 DCHECK(write_result);
222 write_result = key.WriteValue(kRegistryValueCrxInstalledPath, 218 write_result = key.WriteValue(kRegistryValueCrxInstalledPath,
223 path.value().c_str()); 219 path.value().c_str());
224 DCHECK(write_result); 220 DCHECK(write_result);
225 221
226 write_result = key.WriteValue(kRegistryValueCrxInstalledByVersion, 222 write_result = key.WriteValue(kRegistryValueCrxInstalledByVersion,
227 LSTRINGIZE(CHROME_VERSION_STRING)); 223 TO_L_STRING(CHROME_VERSION_STRING));
228 } 224 }
229 225
230 bool IsCrxOrEmpty(const std::wstring& path) { 226 bool IsCrxOrEmpty(const std::wstring& path) {
231 return (path.empty() || 227 return (path.empty() ||
232 (path.substr(std::max(path.size() - 4, 0u)) == L".crx")); 228 (path.substr(std::max(path.size() - 4, 0u)) == L".crx"));
233 } 229 }
234 230
235 void SetOptionToolbandIsHidden(bool is_hidden) { 231 void SetOptionToolbandIsHidden(bool is_hidden) {
236 SetCeeeRegistryBoolean(kRegistryValueToolbandIsHidden, is_hidden); 232 SetCeeeRegistryBoolean(kRegistryValueToolbandIsHidden, is_hidden);
237 } 233 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 DWORD value; 290 DWORD value;
295 if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) { 291 if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) {
296 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); 292 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
297 if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value)) 293 if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value))
298 return false; 294 return false;
299 } 295 }
300 return (1 == value); 296 return (1 == value);
301 } 297 }
302 298
303 } // namespace ceee_module_util 299 } // namespace ceee_module_util
OLDNEW
« no previous file with comments | « base/stringize_macros_unittest.cc ('k') | media/base/media_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698