diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 02:26:37 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 02:26:37 +0000 |
commit | 968d2c518c9073e24ef3724886427481e68ae3e7 (patch) | |
tree | 371cd9ebde8b59cd6966ed42868c83672f8f9ec7 | |
parent | 958fcc78b62c9a2afdfeaf8730658d18fe3cca70 (diff) | |
download | chromium_src-968d2c518c9073e24ef3724886427481e68ae3e7.zip chromium_src-968d2c518c9073e24ef3724886427481e68ae3e7.tar.gz chromium_src-968d2c518c9073e24ef3724886427481e68ae3e7.tar.bz2 |
Cleanup our Registry API.
- Use wchar_t instead of TCHAR.
- Use DCHECK instead of assert.
- Remove this keyword (we don't use it on chromium).
- Add DISALLOW_COPY_AND_ASSIGN to the classes.
- Make it more compliant with chromium code style.
- Remove ununsed methods.
- Use arraysize macro for array size calculation instead of doing it manually.
BUG=44644
TEST=trybots
TODO: Write unittests for this API.
TODO: Remove all the default arguments from the methods in this API. They aren't allowed by our style guide.
Review URL: http://codereview.chromium.org/3007037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55375 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/registry.cc | 226 | ||||
-rw-r--r-- | base/registry.h | 152 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_importer_utils_win.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_plugin_lib.cc | 8 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings_unittest.cc | 6 |
5 files changed, 170 insertions, 226 deletions
diff --git a/base/registry.cc b/base/registry.cc index bdd3089..d4158df 100644 --- a/base/registry.cc +++ b/base/registry.cc @@ -1,27 +1,17 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// All Rights Reserved. #include "base/registry.h" -#include <assert.h> #include <shlwapi.h> -#include <windows.h> -#pragma comment(lib, "shlwapi.lib") // for SHDeleteKey - -// local types (see the same declarations in the header file) -#define tchar TCHAR -#define CTP const tchar* -#define tstr std::basic_string<tchar> +#include "base/logging.h" -// -// RegistryValueIterator -// +#pragma comment(lib, "shlwapi.lib") // for SHDeleteKey RegistryValueIterator::RegistryValueIterator(HKEY root_key, - LPCTSTR folder_key) { + const wchar_t* folder_key) { LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); if (result != ERROR_SUCCESS) { key_ = NULL; @@ -47,19 +37,17 @@ RegistryValueIterator::~RegistryValueIterator() { } bool RegistryValueIterator::Valid() const { - // true while the iterator is valid return key_ != NULL && index_ >= 0; } void RegistryValueIterator::operator++() { - // advance to the next entry in the folder --index_; Read(); } bool RegistryValueIterator::Read() { if (Valid()) { - DWORD ncount = sizeof(name_)/sizeof(*name_); + DWORD ncount = arraysize(name_); value_size_ = sizeof(value_); LRESULT r = ::RegEnumValue(key_, index_, name_, &ncount, NULL, &type_, reinterpret_cast<BYTE*>(value_), &value_size_); @@ -74,7 +62,6 @@ bool RegistryValueIterator::Read() { } DWORD RegistryValueIterator::ValueCount() const { - DWORD count = 0; HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL); @@ -85,12 +72,8 @@ DWORD RegistryValueIterator::ValueCount() const { return count; } -// -// RegistryKeyIterator -// - RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, - LPCTSTR folder_key) { + const wchar_t* folder_key) { LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); if (result != ERROR_SUCCESS) { key_ = NULL; @@ -116,19 +99,17 @@ RegistryKeyIterator::~RegistryKeyIterator() { } bool RegistryKeyIterator::Valid() const { - // true while the iterator is valid return key_ != NULL && index_ >= 0; } void RegistryKeyIterator::operator++() { - // advance to the next entry in the folder --index_; Read(); } bool RegistryKeyIterator::Read() { if (Valid()) { - DWORD ncount = sizeof(name_)/sizeof(*name_); + DWORD ncount = arraysize(name_); FILETIME written; LRESULT r = ::RegEnumKeyEx(key_, index_, name_, &ncount, NULL, NULL, NULL, &written); @@ -141,7 +122,6 @@ bool RegistryKeyIterator::Read() { } DWORD RegistryKeyIterator::SubkeyCount() const { - DWORD count = 0; HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL, NULL, NULL, NULL, NULL, NULL); @@ -152,19 +132,16 @@ DWORD RegistryKeyIterator::SubkeyCount() const { return count; } -// -// RegKey -// - -RegKey::RegKey(HKEY rootkey, const tchar* subkey, REGSAM access) - : key_(NULL), watch_event_(0) { +RegKey::RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access) + : key_(NULL), + watch_event_(0) { if (rootkey) { if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK)) - this->Create(rootkey, subkey, access); + Create(rootkey, subkey, access); else - this->Open(rootkey, subkey, access); + Open(rootkey, subkey, access); } else { - assert(!subkey); + DCHECK(!subkey); } } @@ -176,25 +153,25 @@ void RegKey::Close() { } } -bool RegKey::Create(HKEY rootkey, const tchar* subkey, REGSAM access) { +bool RegKey::Create(HKEY rootkey, const wchar_t* subkey, REGSAM access) { DWORD disposition_value; return CreateWithDisposition(rootkey, subkey, &disposition_value, access); } -bool RegKey::CreateWithDisposition(HKEY rootkey, const tchar* subkey, +bool RegKey::CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, DWORD* disposition, REGSAM access) { - assert(rootkey && subkey && access && disposition); - this->Close(); - - LONG const result = RegCreateKeyEx(rootkey, - subkey, - 0, - NULL, - REG_OPTION_NON_VOLATILE, - access, - NULL, - &key_, - disposition ); + DCHECK(rootkey && subkey && access && disposition); + Close(); + + LONG result = RegCreateKeyEx(rootkey, + subkey, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + access, + NULL, + &key_, + disposition); if (result != ERROR_SUCCESS) { key_ = NULL; return false; @@ -203,40 +180,37 @@ bool RegKey::CreateWithDisposition(HKEY rootkey, const tchar* subkey, return true; } -bool RegKey::Open(HKEY rootkey, const tchar* subkey, REGSAM access) { - assert(rootkey && subkey && access); - this->Close(); +bool RegKey::Open(HKEY rootkey, const wchar_t* subkey, REGSAM access) { + DCHECK(rootkey && subkey && access); + Close(); - LONG const result = RegOpenKeyEx(rootkey, subkey, 0, - access, &key_ ); + LONG result = RegOpenKeyEx(rootkey, subkey, 0, access, &key_); if (result != ERROR_SUCCESS) { key_ = NULL; return false; } - return true; } -bool RegKey::CreateKey(const tchar* name, REGSAM access) { - assert(name && access); +bool RegKey::CreateKey(const wchar_t* name, REGSAM access) { + DCHECK(name && access); HKEY subkey = NULL; - LONG const result = RegCreateKeyEx(key_, name, 0, NULL, - REG_OPTION_NON_VOLATILE, - access, NULL, &subkey, NULL); - this->Close(); + LONG result = RegCreateKeyEx(key_, name, 0, NULL, REG_OPTION_NON_VOLATILE, + access, NULL, &subkey, NULL); + Close(); key_ = subkey; return (result == ERROR_SUCCESS); } -bool RegKey::OpenKey(const tchar* name, REGSAM access) { - assert(name && access); +bool RegKey::OpenKey(const wchar_t* name, REGSAM access) { + DCHECK(name && access); HKEY subkey = NULL; - LONG const result = RegOpenKeyEx(key_, name, 0, access, &subkey); + LONG result = RegOpenKeyEx(key_, name, 0, access, &subkey); - this->Close(); + Close(); key_ = subkey; return (result == ERROR_SUCCESS); @@ -244,14 +218,14 @@ bool RegKey::OpenKey(const tchar* name, REGSAM access) { DWORD RegKey::ValueCount() { DWORD count = 0; - HRESULT const result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, - NULL, &count, NULL, NULL, NULL, NULL); + HRESULT result = RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, + NULL, &count, NULL, NULL, NULL, NULL); return (result != ERROR_SUCCESS) ? 0 : count; } -bool RegKey::ReadName(int index, tstr* name) { - tchar buf[256]; - DWORD bufsize = sizeof(buf)/sizeof(*buf); +bool RegKey::ReadName(int index, std::wstring* name) { + wchar_t buf[256]; + DWORD bufsize = arraysize(buf); LRESULT r = ::RegEnumValue(key_, index, buf, &bufsize, NULL, NULL, NULL, NULL); if (r != ERROR_SUCCESS) @@ -261,34 +235,35 @@ bool RegKey::ReadName(int index, tstr* name) { return true; } -bool RegKey::ValueExists(const tchar* name) { - if (!key_) return false; - const HRESULT result = RegQueryValueEx(key_, name, 0, NULL, NULL, NULL); +bool RegKey::ValueExists(const wchar_t* name) { + if (!key_) + return false; + HRESULT result = RegQueryValueEx(key_, name, 0, NULL, NULL, NULL); return (result == ERROR_SUCCESS); } -bool RegKey::ReadValue(const tchar* name, void* data, +bool RegKey::ReadValue(const wchar_t* name, void* data, DWORD* dsize, DWORD* dtype) { - if (!key_) return false; - HRESULT const result = RegQueryValueEx(key_, name, 0, dtype, - reinterpret_cast<LPBYTE>(data), - dsize); + if (!key_) + return false; + HRESULT result = RegQueryValueEx(key_, name, 0, dtype, + reinterpret_cast<LPBYTE>(data), dsize); return (result == ERROR_SUCCESS); } -bool RegKey::ReadValue(const tchar* name, tstr * value) { - assert(value); - static const size_t kMaxStringLength = 1024; // This is after expansion. +bool RegKey::ReadValue(const wchar_t* name, std::wstring* value) { + DCHECK(value); + const size_t kMaxStringLength = 1024; // This is after expansion. // Use the one of the other forms of ReadValue if 1024 is too small for you. - TCHAR raw_value[kMaxStringLength]; + wchar_t raw_value[kMaxStringLength]; DWORD type = REG_SZ, size = sizeof(raw_value); - if (this->ReadValue(name, raw_value, &size, &type)) { + if (ReadValue(name, raw_value, &size, &type)) { if (type == REG_SZ) { *value = raw_value; } else if (type == REG_EXPAND_SZ) { - TCHAR expanded[kMaxStringLength]; + wchar_t expanded[kMaxStringLength]; size = ExpandEnvironmentStrings(raw_value, expanded, kMaxStringLength); - // Success: returns the number of TCHARs copied + // Success: returns the number of wchar_t's copied // Fail: buffer too small, returns the size required // Fail: other, returns 0 if (size == 0 || size > kMaxStringLength) @@ -304,12 +279,14 @@ bool RegKey::ReadValue(const tchar* name, tstr * value) { return false; } -bool RegKey::ReadValueDW(const tchar* name, DWORD * value) { - assert(value); - DWORD type = REG_DWORD, size = sizeof(DWORD), result = 0; - if (this->ReadValue(name, &result, &size, &type) - && (type == REG_DWORD || type == REG_BINARY) - && size == sizeof(DWORD)) { +bool RegKey::ReadValueDW(const wchar_t* name, DWORD* value) { + DCHECK(value); + DWORD type = REG_DWORD; + DWORD size = sizeof(DWORD); + DWORD result = 0; + if (ReadValue(name, &result, &size, &type) && + (type == REG_DWORD || type == REG_BINARY) && + size == sizeof(DWORD)) { *value = result; return true; } @@ -317,13 +294,14 @@ bool RegKey::ReadValueDW(const tchar* name, DWORD * value) { return false; } -bool RegKey::WriteValue(const tchar* name, - const void * data, - DWORD dsize, - DWORD dtype) { - assert(data); - if (!key_) return false; - HRESULT const result = RegSetValueEx( +bool RegKey::WriteValue(const wchar_t* name, const void * data, + DWORD dsize, DWORD dtype) { + DCHECK(data); + + if (!key_) + return false; + + HRESULT result = RegSetValueEx( key_, name, 0, @@ -333,25 +311,23 @@ bool RegKey::WriteValue(const tchar* name, return (result == ERROR_SUCCESS); } -bool RegKey::WriteValue(const tchar * name, const tchar * value) { - return this->WriteValue(name, value, - static_cast<DWORD>(sizeof(*value) * (_tcslen(value) + 1)), REG_SZ); +bool RegKey::WriteValue(const wchar_t * name, const wchar_t* value) { + return WriteValue(name, value, + static_cast<DWORD>(sizeof(*value) * (wcslen(value) + 1)), REG_SZ); } -bool RegKey::WriteValue(const tchar * name, DWORD value) { - return this->WriteValue(name, &value, - static_cast<DWORD>(sizeof(value)), REG_DWORD); +bool RegKey::WriteValue(const wchar_t* name, DWORD value) { + return WriteValue(name, &value, + static_cast<DWORD>(sizeof(value)), REG_DWORD); } -bool RegKey::DeleteKey(const tchar * name) { - if (!key_) return false; - return (ERROR_SUCCESS == SHDeleteKey(key_, name)); +bool RegKey::DeleteKey(const wchar_t* name) { + return (!key_) ? false : (ERROR_SUCCESS == SHDeleteKey(key_, name)); } - -bool RegKey::DeleteValue(const tchar * value_name) { - assert(value_name); - HRESULT const result = RegDeleteValue(key_, value_name); +bool RegKey::DeleteValue(const wchar_t* value_name) { + DCHECK(value_name); + HRESULT result = RegDeleteValue(key_, value_name); return (result == ERROR_SUCCESS); } @@ -394,29 +370,3 @@ bool RegKey::HasChanged() { } return false; } - -// Register a COM object with the most usual properties. -bool RegisterCOMServer(const tchar* guid, - const tchar* name, - const tchar* path) { - RegKey key(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_WRITE); - key.CreateKey(guid, KEY_WRITE); - key.WriteValue(NULL, name); - key.CreateKey(_T("InprocServer32"), KEY_WRITE); - key.WriteValue(NULL, path); - key.WriteValue(_T("ThreadingModel"), _T("Apartment")); - return true; -} - -bool RegisterCOMServer(const tchar* guid, const tchar* name, HINSTANCE module) { - tchar module_path[MAX_PATH]; - ::GetModuleFileName(module, module_path, MAX_PATH); - _tcslwr_s(module_path, MAX_PATH); - return RegisterCOMServer(guid, name, module_path); -} - -bool UnregisterCOMServer(const tchar* guid) { - RegKey key(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_WRITE); - key.DeleteKey(guid); - return true; -} diff --git a/base/registry.h b/base/registry.h index e35af35..a9a6997 100644 --- a/base/registry.h +++ b/base/registry.h @@ -1,80 +1,73 @@ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// All Rights Reserved. #ifndef BASE_REGISTRY_H_ #define BASE_REGISTRY_H_ #pragma once #include <windows.h> -#include <tchar.h> -#include <shlwapi.h> + #include <string> -// The shared file uses a bunch of header files that define types that we don't. -// To avoid changing much code from the standard version, and also to avoid -// polluting our namespace with extra types we don't want, we define these types -// here with the preprocessor and undefine them at the end of the file. -#define tchar TCHAR -#define CTP const tchar* -#define tstr std::basic_string<tchar> +#include "base/basictypes.h" -// RegKey -// Utility class to read from and manipulate the registry. -// Registry vocabulary primer: a "key" is like a folder, in which there -// are "values", which are <name,data> pairs, with an associated data type. +// TODO(tfarina): Get rid of all the default arguments used in this file. +// They are not allowed by our style guide. +// Utility class to read, write and manipulate the Windows Registry. +// Registry vocabulary primer: a "key" is like a folder, in which there +// are "values", which are <name, data> pairs, with an associated data type. class RegKey { public: - RegKey(HKEY rootkey = NULL, CTP subkey = NULL, REGSAM access = KEY_READ); - + RegKey(HKEY rootkey = NULL, const wchar_t* subkey = NULL, + REGSAM access = KEY_READ); ~RegKey() { Close(); } - bool Create(HKEY rootkey, CTP subkey, REGSAM access = KEY_READ); + bool Create(HKEY rootkey, const wchar_t* subkey, REGSAM access = KEY_READ); - bool CreateWithDisposition(HKEY rootkey, CTP subkey, DWORD* disposition, - REGSAM access = KEY_READ); + bool CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, + DWORD* disposition, REGSAM access = KEY_READ); - bool Open(HKEY rootkey, CTP subkey, REGSAM access = KEY_READ); + bool Open(HKEY rootkey, const wchar_t* subkey, REGSAM access = KEY_READ); - // Create a subkey (or open if exists). - bool CreateKey(CTP name, REGSAM access); + // Creates a subkey or open it if it already exists. + bool CreateKey(const wchar_t* name, REGSAM access); - // Open a subkey - bool OpenKey(CTP name, REGSAM access); + // Opens a subkey + bool OpenKey(const wchar_t* name, REGSAM access); - // all done, eh? void Close(); - // Count of the number of value extant. DWORD ValueCount(); - // Determine the Nth value's name. - bool ReadName(int index, tstr* name); + // Determine the nth value's name. + bool ReadName(int index, std::wstring* name); // True while the key is valid. bool Valid() const { return key_ != NULL; } - // Kill key and everything that liveth below it; please be careful out there. - bool DeleteKey(CTP name); + // Kill a key and everything that live below it; please be careful when using + // it. + bool DeleteKey(const wchar_t* name); - // Delete a single value within the key. - bool DeleteValue(CTP name); + // Deletes a single value within the key. + bool DeleteValue(const wchar_t* name); - bool ValueExists(CTP name); - bool ReadValue(CTP name, void* data, DWORD* dsize, DWORD* dtype = NULL); - bool ReadValue(CTP name, tstr* value); - bool ReadValueDW(CTP name, DWORD* value); // Named to differ from tstr* + bool ValueExists(const wchar_t* name); - bool WriteValue(CTP name, const void* data, DWORD dsize, + bool ReadValue(const wchar_t* name, void* data, DWORD* dsize, + DWORD* dtype = NULL); + bool ReadValue(const wchar_t* name, std::wstring* value); + bool ReadValueDW(const wchar_t* name, DWORD* value); + + bool WriteValue(const wchar_t* name, const void* data, DWORD dsize, DWORD dtype = REG_BINARY); - bool WriteValue(CTP name, CTP value); - bool WriteValue(CTP name, DWORD value); + bool WriteValue(const wchar_t* name, const wchar_t* value); + bool WriteValue(const wchar_t* name, DWORD value); - // Start watching the key to see if any of its values have changed. - // The key must have been opened with the KEY_NOTIFY access - // privelege. + // Starts watching the key to see if any of its values have changed. + // The key must have been opened with the KEY_NOTIFY access privelege. bool StartWatching(); // If StartWatching hasn't been called, always returns false. @@ -93,6 +86,8 @@ class RegKey { private: HKEY key_; // The registry key being iterated. HANDLE watch_event_; + + DISALLOW_COPY_AND_ASSIGN(RegKey); }; // Iterates the entries found in a particular folder on the registry. @@ -101,78 +96,75 @@ class RegKey { // adequate. class RegistryValueIterator { public: - // Specify a key in construction. - RegistryValueIterator(HKEY root_key, LPCTSTR folder_key); + RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); ~RegistryValueIterator(); - DWORD ValueCount() const; // Count of the number of subkeys extant. + DWORD ValueCount() const; - bool Valid() const; // True while the iterator is valid. + // True while the iterator is valid. + bool Valid() const; - void operator++(); // Advance to the next entry in the folder. + // Advances to the next registry entry. + void operator++(); - // The pointers returned by these functions are statics owned by the - // Name and Value functions. - CTP Name() const { return name_; } - CTP Value() const { return value_; } + const wchar_t* Name() const { return name_; } + const wchar_t* Value() const { return value_; } DWORD ValueSize() const { return value_size_; } DWORD Type() const { return type_; } int Index() const { return index_; } private: - bool Read(); // Read in the current values. + // Read in the current values. + bool Read(); + + // The registry key being iterated. + HKEY key_; - HKEY key_; // The registry key being iterated. - int index_; // Current index of the iteration. + // Current index of the iteration. + int index_; // Current values. - TCHAR name_[MAX_PATH]; - TCHAR value_[MAX_PATH]; + wchar_t name_[MAX_PATH]; + wchar_t value_[MAX_PATH]; DWORD value_size_; DWORD type_; -}; + DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator); +}; class RegistryKeyIterator { public: - // Specify a parent key in construction. - RegistryKeyIterator(HKEY root_key, LPCTSTR folder_key); + RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key); ~RegistryKeyIterator(); - DWORD SubkeyCount() const; // Count of the number of subkeys extant. + DWORD SubkeyCount() const; - bool Valid() const; // True while the iterator is valid. + // True while the iterator is valid. + bool Valid() const; - void operator++(); // Advance to the next entry in the folder. + // Advances to the next entry in the folder. + void operator++(); - // The pointer returned by Name() is a static owned by the function. - CTP Name() const { return name_; } + const wchar_t* Name() const { return name_; } int Index() const { return index_; } private: - bool Read(); // Read in the current values. - - HKEY key_; // The registry key being iterated. - int index_; // Current index of the iteration. + // Read in the current values. + bool Read(); - // Current values. - TCHAR name_[MAX_PATH]; -}; + // The registry key being iterated. + HKEY key_; + // Current index of the iteration. + int index_; -// Register a COM object with the most usual properties. -bool RegisterCOMServer(const tchar* guid, const tchar* name, - const tchar* modulepath); -bool RegisterCOMServer(const tchar* guid, const tchar* name, HINSTANCE module); -bool UnregisterCOMServer(const tchar* guid); + wchar_t name_[MAX_PATH]; -// undo the local types defined above -#undef tchar -#undef CTP -#undef tstr + DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); +}; #endif // BASE_REGISTRY_H_ diff --git a/chrome/browser/importer/firefox_importer_utils_win.cc b/chrome/browser/importer/firefox_importer_utils_win.cc index 77e3fcb..6887067 100644 --- a/chrome/browser/importer/firefox_importer_utils_win.cc +++ b/chrome/browser/importer/firefox_importer_utils_win.cc @@ -43,7 +43,7 @@ int GetCurrentFirefoxMajorVersionFromRegistry() { std::wstring GetFirefoxInstallPathFromRegistry() { // Detects the path that Firefox is installed in. std::wstring registry_path = L"Software\\Mozilla\\Mozilla Firefox"; - TCHAR buffer[MAX_PATH]; + wchar_t buffer[MAX_PATH]; DWORD buffer_length = sizeof(buffer); RegKey reg_key(HKEY_LOCAL_MACHINE, registry_path.c_str()); bool result = reg_key.ReadValue(L"CurrentVersion", buffer, @@ -52,7 +52,7 @@ std::wstring GetFirefoxInstallPathFromRegistry() { return std::wstring(); registry_path += L"\\" + std::wstring(buffer) + L"\\Main"; buffer_length = sizeof(buffer); - RegKey reg_key_directory = RegKey(HKEY_LOCAL_MACHINE, registry_path.c_str()); + RegKey reg_key_directory(HKEY_LOCAL_MACHINE, registry_path.c_str()); result = reg_key_directory.ReadValue(L"Install Directory", buffer, &buffer_length, NULL); if (!result) diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc index daf6bb7..1e74f4c 100644 --- a/chrome/common/chrome_plugin_lib.cc +++ b/chrome/common/chrome_plugin_lib.cc @@ -25,10 +25,10 @@ using base::TimeDelta; // TODO(port): revisit when plugins happier #if defined(OS_WIN) -const TCHAR ChromePluginLib::kRegistryChromePlugins[] = - _T("Software\\Google\\Chrome\\Plugins"); -static const TCHAR kRegistryLoadOnStartup[] = _T("LoadOnStartup"); -static const TCHAR kRegistryPath[] = _T("Path"); +const wchar_t ChromePluginLib::kRegistryChromePlugins[] = + L"Software\\Google\\Chrome\\Plugins"; +static const wchar_t kRegistryLoadOnStartup[] = L"LoadOnStartup"; +static const wchar_t kRegistryPath[] = L"Path"; #endif typedef base::hash_map<FilePath, scoped_refptr<ChromePluginLib> > diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index e670a8e..11bd1fa 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include <windows.h> +#include <shlwapi.h> // For SHDeleteKey. #include "base/registry.h" #include "base/scoped_ptr.h" @@ -13,9 +14,10 @@ #include "testing/gtest/include/gtest/gtest.h" namespace { -const wchar_t* kHKCUReplacement = + +const wchar_t kHKCUReplacement[] = L"Software\\Google\\InstallUtilUnittest\\HKCU"; -const wchar_t* kHKLMReplacement = +const wchar_t kHKLMReplacement[] = L"Software\\Google\\InstallUtilUnittest\\HKLM"; const wchar_t kTestProductGuid[] = L"{89F1B351-B15D-48D4-8F10-1298721CF13D}"; |