diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-17 04:41:54 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-17 04:41:54 +0000 |
commit | 2d650398a9afa1fc3c168aed736daa13901809a8 (patch) | |
tree | 6dc4a48b54cdca7f0946ac097353b5c1ca733b40 | |
parent | df0ca6c858762b101bf424ff6c0522409fa195fc (diff) | |
download | chromium_src-2d650398a9afa1fc3c168aed736daa13901809a8.zip chromium_src-2d650398a9afa1fc3c168aed736daa13901809a8.tar.gz chromium_src-2d650398a9afa1fc3c168aed736daa13901809a8.tar.bz2 |
Move pe_image and registry from base to base/win and use the namespace. It removes windows_message_list which isn't used.
This keeps a stub for registry in the old location until we can update that.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3836005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62888 0039d316-1c4b-4281-b951-d872f2087c98
80 files changed, 598 insertions, 687 deletions
diff --git a/app/win/iat_patch_function.cc b/app/win/iat_patch_function.cc index 3f90d81..a78a357 100644 --- a/app/win/iat_patch_function.cc +++ b/app/win/iat_patch_function.cc @@ -5,6 +5,7 @@ #include "app/win/iat_patch_function.h" #include "base/logging.h" +#include "base/win/pe_image.h" namespace app { namespace win { @@ -79,7 +80,7 @@ DWORD ModifyCode(void* old_code, void* new_code, int length) { return error; } -bool InterceptEnumCallback(const PEImage &image, const char* module, +bool InterceptEnumCallback(const base::win::PEImage& image, const char* module, DWORD ordinal, const char* name, DWORD hint, IMAGE_THUNK_DATA* iat, void* cookie) { InterceptFunctionInformation* intercept_information = @@ -147,7 +148,7 @@ DWORD InterceptImportedFunction(HMODULE module_handle, return ERROR_INVALID_PARAMETER; } - PEImage target_image(module_handle); + base::win::PEImage target_image(module_handle); if (!target_image.VerifyMagic()) { NOTREACHED(); return ERROR_INVALID_PARAMETER; diff --git a/app/win/iat_patch_function.h b/app/win/iat_patch_function.h index 37961dd..4a2aa0c 100644 --- a/app/win/iat_patch_function.h +++ b/app/win/iat_patch_function.h @@ -9,7 +9,6 @@ #include <windows.h> #include "base/basictypes.h" -#include "base/pe_image.h" namespace app { namespace win { diff --git a/base/base.gyp b/base/base.gyp index e432815..5145404 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -113,7 +113,6 @@ 'object_watcher_unittest.cc', 'observer_list_unittest.cc', 'path_service_unittest.cc', - 'pe_image_unittest.cc', 'pickle_unittest.cc', 'platform_file_unittest.cc', 'platform_thread_unittest.cc', @@ -123,7 +122,6 @@ 'process_util_unittest_mac.mm', 'rand_util_unittest.cc', 'ref_counted_unittest.cc', - 'registry_unittest.cc', 'scoped_native_library_unittest.cc', 'scoped_ptr_unittest.cc', 'scoped_temp_dir_unittest.cc', @@ -165,6 +163,8 @@ 'watchdog_unittest.cc', 'weak_ptr_unittest.cc', 'win_util_unittest.cc', + 'win/pe_image_unittest.cc', + 'win/registry_unittest.cc', 'win/scoped_bstr_unittest.cc', 'win/scoped_comptr_unittest.cc', 'win/scoped_variant_unittest.cc', @@ -221,11 +221,6 @@ 'event_trace_controller_win_unittest.cc', 'event_trace_provider_win_unittest.cc', 'object_watcher_unittest.cc', - 'pe_image_unittest.cc', - 'registry_unittest.cc', - 'scoped_bstr_win_unittest.cc', - 'scoped_comptr_win_unittest.cc', - 'scoped_variant_win_unittest.cc', 'system_monitor_unittest.cc', 'time_win_unittest.cc', 'trace_event_win_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index b608e82..b449a89 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -156,8 +156,6 @@ 'observer_list_threadsafe.h', 'path_service.cc', 'path_service.h', - 'pe_image.cc', - 'pe_image.h', 'pickle.cc', 'pickle.h', 'platform_file.h', @@ -189,8 +187,6 @@ 'ref_counted.h', 'ref_counted_memory.cc', 'ref_counted_memory.h', - 'registry.cc', - 'registry.h', 'resource_util.cc', 'resource_util.h', 'safe_strerror_posix.cc', @@ -295,6 +291,10 @@ 'watchdog.h', 'weak_ptr.cc', 'weak_ptr.h', + 'win/pe_image.cc', + 'win/pe_image.h', + 'win/registry.cc', + 'win/registry.h', 'win/scoped_bstr.cc', 'win/scoped_bstr.h', 'win/scoped_comptr.h', diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 213833b..d9f8404 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -15,7 +15,7 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/metrics/histogram.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "base/win/scoped_handle.h" #include "base/string_number_conversions.h" #include "base/string_util.h" @@ -1051,7 +1051,7 @@ bool PreReadImage(const wchar_t* file_path, size_t size_to_read, if (!dll_module) return false; - PEImage pe_image(dll_module); + base::win::PEImage pe_image(dll_module); PIMAGE_NT_HEADERS nt_headers = pe_image.GetNTHeaders(); size_t actual_size_to_read = size_to_read ? size_to_read : nt_headers->OptionalHeader.SizeOfImage; diff --git a/base/registry.h b/base/registry.h index 7584de019..5ef45f2 100644 --- a/base/registry.h +++ b/base/registry.h @@ -6,160 +6,34 @@ #define BASE_REGISTRY_H_ #pragma once -#include <windows.h> -#include <string> +// TODO(brettw) remove this file when all callers are converted to using the +// new location & namespace. +#include "base/win/registry.h" -#include "base/basictypes.h" - -// 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 { +class RegKey : public base::win::RegKey { public: - RegKey(); - RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); - ~RegKey(); - - bool Create(HKEY rootkey, const wchar_t* subkey, REGSAM access); - - bool CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, - DWORD* disposition, REGSAM access); - - bool Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); - - // Creates a subkey or open it if it already exists. - bool CreateKey(const wchar_t* name, REGSAM access); - - // Opens a subkey - bool OpenKey(const wchar_t* name, REGSAM access); - - void Close(); - - DWORD ValueCount(); - - // 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 a key and everything that live below it; please be careful when using - // it. - bool DeleteKey(const wchar_t* name); - - // Deletes a single value within the key. - bool DeleteValue(const wchar_t* name); - - bool ValueExists(const wchar_t* name); - - bool ReadValue(const wchar_t* name, void* data, DWORD* dsize, DWORD* dtype); - 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); - bool WriteValue(const wchar_t* name, const wchar_t* value); - bool WriteValue(const wchar_t* name, DWORD value); - - // 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. - // Otherwise, returns true if anything under the key has changed. - // This can't be const because the |watch_event_| may be refreshed. - bool HasChanged(); - - // Will automatically be called by destructor if not manually called - // beforehand. Returns true if it was watching, false otherwise. - bool StopWatching(); - - inline bool IsWatching() const { return watch_event_ != 0; } - HANDLE watch_event() const { return watch_event_; } - HKEY Handle() const { return key_; } - - private: - HKEY key_; // The registry key being iterated. - HANDLE watch_event_; - - DISALLOW_COPY_AND_ASSIGN(RegKey); + RegKey() {} + RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access) + : base::win::RegKey(rootkey, subkey, access) {} + ~RegKey() { base::win::RegKey::~RegKey(); } }; -// Iterates the entries found in a particular folder on the registry. -// For this application I happen to know I wont need data size larger -// than MAX_PATH, but in real life this wouldn't neccessarily be -// adequate. -class RegistryValueIterator { +class RegistryValueIterator : public base::win::RegistryValueIterator { public: - RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); - - ~RegistryValueIterator(); - - DWORD ValueCount() const; - - // True while the iterator is valid. - bool Valid() const; - - // Advances to the next registry entry. - void operator++(); - - 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: - // Read in the current values. - bool Read(); - - // The registry key being iterated. - HKEY key_; - - // Current index of the iteration. - int index_; - - // Current values. - wchar_t name_[MAX_PATH]; - wchar_t value_[MAX_PATH]; - DWORD value_size_; - DWORD type_; - - DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator); + RegistryValueIterator(HKEY root_key, const wchar_t* folder_key) + : base::win::RegistryValueIterator(root_key, folder_key) {} + ~RegistryValueIterator() { + base::win::RegistryValueIterator::~RegistryValueIterator(); + } }; -class RegistryKeyIterator { +class RegistryKeyIterator : public base::win::RegistryKeyIterator { public: - RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key); - - ~RegistryKeyIterator(); - - DWORD SubkeyCount() const; - - // True while the iterator is valid. - bool Valid() const; - - // Advances to the next entry in the folder. - void operator++(); - - const wchar_t* Name() const { return name_; } - - int Index() const { return index_; } - - private: - // Read in the current values. - bool Read(); - - // The registry key being iterated. - HKEY key_; - - // Current index of the iteration. - int index_; - - wchar_t name_[MAX_PATH]; - - DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); + RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key) + : base::win::RegistryKeyIterator(root_key, folder_key) {} + ~RegistryKeyIterator() { + base::win::RegistryKeyIterator::~RegistryKeyIterator(); + } }; #endif // BASE_REGISTRY_H_ diff --git a/base/pe_image.cc b/base/win/pe_image.cc index 36eb0e4..76fdbcd 100644 --- a/base/pe_image.cc +++ b/base/win/pe_image.cc @@ -1,11 +1,14 @@ -// 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. // This file implements PEImage, a generic class to manipulate PE files. // This file was adapted from GreenBorder's Code. -#include "base/pe_image.h" +#include "base/win/pe_image.h" + +namespace base { +namespace win { #if defined(_WIN64) && !defined(NACL_WIN64) // TODO(rvargas): Bug 27218. Make sure this is ok. @@ -562,3 +565,6 @@ PVOID PEImageAsData::RVAToAddr(DWORD rva) const { return in_memory; } + +} // namespace win +} // namespace base diff --git a/base/pe_image.h b/base/win/pe_image.h index 968d056..e1205e0 100644 --- a/base/pe_image.h +++ b/base/win/pe_image.h @@ -1,4 +1,4 @@ -// 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. @@ -8,13 +8,16 @@ // Win32 Portable Executable File Format" by Matt Pietrek: // http://msdn.microsoft.com/msdnmag/issues/02/02/PE/default.aspx -#ifndef BASE_PE_IMAGE_H_ -#define BASE_PE_IMAGE_H_ +#ifndef BASE_WIN_PE_IMAGE_H_ +#define BASE_WIN_PE_IMAGE_H_ #pragma once #include <windows.h> #include <DelayIMP.h> +namespace base { +namespace win { + // This class is a wrapper for the Portable Executable File Format (PE). // It's main purpose is to provide an easy way to work with imports and exports // from a file, mapped in memory as image. @@ -255,4 +258,7 @@ inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); } -#endif // BASE_PE_IMAGE_H_ +} // namespace win +} // namespace base + +#endif // BASE_WIN_PE_IMAGE_H_ diff --git a/base/pe_image_unittest.cc b/base/win/pe_image_unittest.cc index 6d8875e..899ce94 100644 --- a/base/pe_image_unittest.cc +++ b/base/win/pe_image_unittest.cc @@ -5,9 +5,12 @@ // This file contains unit tests for PEImage. #include "testing/gtest/include/gtest/gtest.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "base/win/windows_version.h" +namespace base { +namespace win { + // Just counts the number of invocations. bool ExportsCallback(const PEImage &image, DWORD ordinal, @@ -211,3 +214,6 @@ TEST(PEImageTest, RetrievesExports) { FreeLibrary(module); } + +} // namespace win +} // namespace base diff --git a/base/registry.cc b/base/win/registry.cc index f8e58b9..545c337 100644 --- a/base/registry.cc +++ b/base/win/registry.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/registry.h" +#include "base/win/registry.h" #include <shlwapi.h> @@ -10,6 +10,9 @@ #pragma comment(lib, "shlwapi.lib") // for SHDeleteKey +namespace base { +namespace win { + RegistryValueIterator::RegistryValueIterator(HKEY root_key, const wchar_t* folder_key) { LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); @@ -379,3 +382,6 @@ bool RegKey::HasChanged() { } return false; } + +} // namespace win +} // namespace base diff --git a/base/win/registry.h b/base/win/registry.h new file mode 100644 index 0000000..d1ef25b --- /dev/null +++ b/base/win/registry.h @@ -0,0 +1,171 @@ +// 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. + +#ifndef BASE_WIN_REGISTRY_H_ +#define BASE_WIN_REGISTRY_H_ +#pragma once + +#include <windows.h> +#include <string> + +#include "base/basictypes.h" + +namespace base { +namespace win { + +// 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(); + RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); + ~RegKey(); + + bool Create(HKEY rootkey, const wchar_t* subkey, REGSAM access); + + bool CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, + DWORD* disposition, REGSAM access); + + bool Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); + + // Creates a subkey or open it if it already exists. + bool CreateKey(const wchar_t* name, REGSAM access); + + // Opens a subkey + bool OpenKey(const wchar_t* name, REGSAM access); + + void Close(); + + DWORD ValueCount(); + + // 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 a key and everything that live below it; please be careful when using + // it. + bool DeleteKey(const wchar_t* name); + + // Deletes a single value within the key. + bool DeleteValue(const wchar_t* name); + + bool ValueExists(const wchar_t* name); + + bool ReadValue(const wchar_t* name, void* data, DWORD* dsize, DWORD* dtype); + 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); + bool WriteValue(const wchar_t* name, const wchar_t* value); + bool WriteValue(const wchar_t* name, DWORD value); + + // 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. + // Otherwise, returns true if anything under the key has changed. + // This can't be const because the |watch_event_| may be refreshed. + bool HasChanged(); + + // Will automatically be called by destructor if not manually called + // beforehand. Returns true if it was watching, false otherwise. + bool StopWatching(); + + inline bool IsWatching() const { return watch_event_ != 0; } + HANDLE watch_event() const { return watch_event_; } + HKEY Handle() const { return key_; } + + 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. +// For this application I happen to know I wont need data size larger +// than MAX_PATH, but in real life this wouldn't neccessarily be +// adequate. +class RegistryValueIterator { + public: + RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); + + ~RegistryValueIterator(); + + DWORD ValueCount() const; + + // True while the iterator is valid. + bool Valid() const; + + // Advances to the next registry entry. + void operator++(); + + 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: + // Read in the current values. + bool Read(); + + // The registry key being iterated. + HKEY key_; + + // Current index of the iteration. + int index_; + + // Current values. + wchar_t name_[MAX_PATH]; + wchar_t value_[MAX_PATH]; + DWORD value_size_; + DWORD type_; + + DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator); +}; + +class RegistryKeyIterator { + public: + RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key); + + ~RegistryKeyIterator(); + + DWORD SubkeyCount() const; + + // True while the iterator is valid. + bool Valid() const; + + // Advances to the next entry in the folder. + void operator++(); + + const wchar_t* Name() const { return name_; } + + int Index() const { return index_; } + + private: + // Read in the current values. + bool Read(); + + // The registry key being iterated. + HKEY key_; + + // Current index of the iteration. + int index_; + + wchar_t name_[MAX_PATH]; + + DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); +}; + +} // namespace win +} // namespace base + +#endif // BASE_WIN_REGISTRY_H_ diff --git a/base/registry_unittest.cc b/base/win/registry_unittest.cc index 2618a75..524612a 100644 --- a/base/registry_unittest.cc +++ b/base/win/registry_unittest.cc @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/registry.h" +#include "base/win/registry.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { +namespace win { + namespace { const wchar_t kRootKey[] = L"Base_Registry_Unittest"; @@ -57,3 +60,6 @@ TEST_F(RegistryTest, ValueTest) { } } // namespace + +} // namespace win +} // namespace base diff --git a/base/win_util.cc b/base/win_util.cc index 70d2829..a576122 100644 --- a/base/win_util.cc +++ b/base/win_util.cc @@ -12,7 +12,7 @@ #include <shlobj.h> #include "base/logging.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "base/scoped_handle.h" #include "base/scoped_ptr.h" #include "base/string_util.h" @@ -127,7 +127,7 @@ std::wstring GetClassName(HWND window) { } bool UserAccountControlIsEnabled() { - RegKey key(HKEY_LOCAL_MACHINE, + base::win::RegKey key(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", KEY_READ); DWORD uac_enabled; @@ -187,12 +187,12 @@ static const char16 kAutoRunKeyPath[] = bool AddCommandToAutoRun(HKEY root_key, const string16& name, const string16& command) { - RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); + base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); return autorun_key.WriteValue(name.c_str(), command.c_str()); } bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) { - RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); + base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); return autorun_key.DeleteValue(name.c_str()); } diff --git a/base/windows_message_list.h b/base/windows_message_list.h deleted file mode 100644 index 3452bab..0000000 --- a/base/windows_message_list.h +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (c) 2006-2008 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. - -// WARNING: DO NOT USE standard header file protection. -// This file may be include several times in its entirety. - -// This file contains a list of all messages supported by Windows as would be -// handled in a message loop. We only list the messages provided in -// <winuser.h>, and do not currently include (the otherwise undefined) -// #define WM_SYSTIMER 0x118 - -// By using various macro tricks, this list can be used to create pretty print -// functions for the messages. See message_loop.cc for an example. - -// Start list of Windows Messages given in <winuser.h> -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NULL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CREATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DESTROY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SIZE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ACTIVATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETFOCUS) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_KILLFOCUS) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ENABLE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETREDRAW) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETTEXT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETTEXT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETTEXTLENGTH) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PAINT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CLOSE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUERYENDSESSION) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUERYOPEN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ENDSESSION) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUIT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ERASEBKGND) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYSCOLORCHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SHOWWINDOW) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_WININICHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETTINGCHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DEVMODECHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ACTIVATEAPP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_FONTCHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_TIMECHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CANCELMODE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETCURSOR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSEACTIVATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CHILDACTIVATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUEUESYNC) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETMINMAXINFO) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PAINTICON) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ICONERASEBKGND) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NEXTDLGCTL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SPOOLERSTATUS) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DRAWITEM) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MEASUREITEM) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DELETEITEM) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_VKEYTOITEM) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CHARTOITEM) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETFONT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETFONT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETHOTKEY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETHOTKEY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUERYDRAGICON) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_COMPAREITEM) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETOBJECT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_COMPACTING) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_COMMNOTIFY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_WINDOWPOSCHANGING) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_WINDOWPOSCHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_POWER) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_COPYDATA) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CANCELJOURNAL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NOTIFY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INPUTLANGCHANGEREQUEST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INPUTLANGCHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_TCARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_HELP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_USERCHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NOTIFYFORMAT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CONTEXTMENU) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_STYLECHANGING) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_STYLECHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DISPLAYCHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETICON) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SETICON) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCCREATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCDESTROY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCCALCSIZE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCHITTEST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCPAINT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCACTIVATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETDLGCODE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYNCPAINT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCMOUSEMOVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCLBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCLBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCLBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCRBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCRBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCRBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCMBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCMBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCMBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCXBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCXBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCXBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INPUT_DEVICE_CHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INPUT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_KEYFIRST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_KEYDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_KEYUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DEADCHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYSKEYDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYSKEYUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYSCHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYSDEADCHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_UNICHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_KEYLAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_KEYLAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_STARTCOMPOSITION) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_ENDCOMPOSITION) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_COMPOSITION) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_KEYLAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INITDIALOG) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_COMMAND) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SYSCOMMAND) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_TIMER) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_HSCROLL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_VSCROLL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INITMENU) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_INITMENUPOPUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MENUSELECT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MENUCHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ENTERIDLE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MENURBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MENUDRAG) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MENUGETOBJECT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_UNINITMENUPOPUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MENUCOMMAND) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CHANGEUISTATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_UPDATEUISTATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUERYUISTATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLORMSGBOX) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLOREDIT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLORLISTBOX) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLORBTN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLORDLG) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLORSCROLLBAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CTLCOLORSTATIC) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSEFIRST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSEMOVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_LBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_LBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_LBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_RBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_RBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_RBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSEWHEEL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_XBUTTONDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_XBUTTONUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_XBUTTONDBLCLK) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSEHWHEEL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSELAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSELAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSELAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSELAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PARENTNOTIFY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ENTERMENULOOP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_EXITMENULOOP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NEXTMENU) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SIZING) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CAPTURECHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOVING) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_POWERBROADCAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DEVICECHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDICREATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIDESTROY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIACTIVATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIRESTORE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDINEXT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIMAXIMIZE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDITILE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDICASCADE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIICONARRANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIGETACTIVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDISETMENU) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ENTERSIZEMOVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_EXITSIZEMOVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DROPFILES) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MDIREFRESHMENU) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_SETCONTEXT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_NOTIFY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_CONTROL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_COMPOSITIONFULL) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_SELECT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_CHAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_REQUEST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_KEYDOWN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_IME_KEYUP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSEHOVER) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_MOUSELEAVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCMOUSEHOVER) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_NCMOUSELEAVE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_WTSSESSION_CHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_TABLET_FIRST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_TABLET_LAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CUT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_COPY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PASTE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CLEAR) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_UNDO) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_RENDERFORMAT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_RENDERALLFORMATS) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DESTROYCLIPBOARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DRAWCLIPBOARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PAINTCLIPBOARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_VSCROLLCLIPBOARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_SIZECLIPBOARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_ASKCBFORMATNAME) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CHANGECBCHAIN) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_HSCROLLCLIPBOARD) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_QUERYNEWPALETTE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PALETTEISCHANGING) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PALETTECHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_HOTKEY) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PRINT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PRINTCLIENT) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_APPCOMMAND) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_THEMECHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_CLIPBOARDUPDATE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DWMCOMPOSITIONCHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DWMNCRENDERINGCHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DWMCOLORIZATIONCOLORCHANGED) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_DWMWINDOWMAXIMIZEDCHANGE) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_GETTITLEBARINFOEX) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_HANDHELDFIRST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_HANDHELDLAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_AFXFIRST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_AFXLAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PENWINFIRST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_PENWINLAST) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_APP) -A_NAMED_MESSAGE_FROM_WINUSER_H(WM_USER) -// End list of Windows Messages given in <winuser.h> diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc index 3f4f862..308678e 100644 --- a/chrome/app/breakpad_win.cc +++ b/chrome/app/breakpad_win.cc @@ -16,12 +16,12 @@ #include "base/environment.h" #include "base/file_util.h" #include "base/file_version_info.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_split.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" +#include "base/win/registry.h" #include "breakpad/src/client/windows/handler/exception_handler.h" #include "chrome/app/hard_error_handler_win.h" #include "chrome/common/child_process_logging.h" @@ -432,13 +432,15 @@ bool ShowRestartDialogIfCrashed(bool* exit_now) { static bool MetricsReportingControlledByPolicy(bool* result) { std::wstring key_name = UTF8ToWide(policy::key::kMetricsReportingEnabled); DWORD value; - RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey, KEY_READ); + base::win::RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, + policy::kRegistrySubKey, KEY_READ); if (hkcu_policy_key.ReadValueDW(key_name.c_str(), &value)) { *result = value != 0; return true; } - RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey, KEY_READ); + base::win::RegKey hklm_policy_key(HKEY_CURRENT_USER, + policy::kRegistrySubKey, KEY_READ); if (hklm_policy_key.ReadValueDW(key_name.c_str(), &value)) { *result = value != 0; return true; diff --git a/chrome/browser/autofill/autofill_ie_toolbar_import_win.cc b/chrome/browser/autofill/autofill_ie_toolbar_import_win.cc index de151e3..dcfe0a5 100644 --- a/chrome/browser/autofill/autofill_ie_toolbar_import_win.cc +++ b/chrome/browser/autofill/autofill_ie_toolbar_import_win.cc @@ -5,14 +5,16 @@ #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" #include "base/basictypes.h" -#include "base/registry.h" #include "base/string16.h" +#include "base/win/registry.h" #include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/credit_card.h" #include "chrome/browser/autofill/field_types.h" #include "chrome/browser/autofill/personal_data_manager.h" #include "chrome/browser/sync/util/data_encryption.h" +using base::win::RegKey; + // Forward declaration. This function is not in unnamed namespace as it // is referenced in the unittest. bool ImportCurrentUserProfiles(std::vector<AutoFillProfile>* profiles, @@ -177,7 +179,8 @@ bool ImportCurrentUserProfiles(std::vector<AutoFillProfile>* profiles, profile_reg_values[i].field_type; } - RegistryKeyIterator iterator_profiles(HKEY_CURRENT_USER, kProfileKey); + base::win::RegistryKeyIterator iterator_profiles(HKEY_CURRENT_USER, + kProfileKey); for (; iterator_profiles.Valid(); ++iterator_profiles) { std::wstring key_name(kProfileKey); key_name.append(L"\\"); @@ -208,7 +211,8 @@ bool ImportCurrentUserProfiles(std::vector<AutoFillProfile>* profiles, // We import CC profiles only if they are not password protected. if (password_hash.empty() && IsEmptySalt(salt)) { - RegistryKeyIterator iterator_cc(HKEY_CURRENT_USER, kCreditCardKey); + base::win::RegistryKeyIterator iterator_cc(HKEY_CURRENT_USER, + kCreditCardKey); for (; iterator_cc.Valid(); ++iterator_cc) { std::wstring key_name(kCreditCardKey); key_name.append(L"\\"); diff --git a/chrome/browser/autofill/autofill_ie_toolbar_import_win_unittest.cc b/chrome/browser/autofill/autofill_ie_toolbar_import_win_unittest.cc index 9aa7649..0512139 100644 --- a/chrome/browser/autofill/autofill_ie_toolbar_import_win_unittest.cc +++ b/chrome/browser/autofill/autofill_ie_toolbar_import_win_unittest.cc @@ -5,14 +5,16 @@ #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" #include "base/basictypes.h" -#include "base/registry.h" #include "base/string16.h" +#include "base/win/registry.h" #include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/credit_card.h" #include "chrome/browser/autofill/field_types.h" #include "chrome/browser/sync/util/data_encryption.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + // Defined in autofill_ie_toolbar_import_win.cc. Not exposed in the header file. bool ImportCurrentUserProfiles(std::vector<AutoFillProfile>* profiles, std::vector<CreditCard>* credit_cards); diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index ef16b49..080e3b2 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -53,7 +53,7 @@ static const char kXdgConfigHome[] = "XDG_CONFIG_HOME"; #endif #if defined(OS_WIN) -#include "base/registry.h" +#include "base/win/registry.h" const HKEY kBackgroundModeRegistryRootKey = HKEY_CURRENT_USER; const wchar_t* kBackgroundModeRegistrySubkey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; @@ -401,10 +401,10 @@ void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) { // TODO(rickcam): Bug 53597: Make RegKey mockable. // TODO(rickcam): Bug 53600: Use distinct registry keys per flavor+profile. const wchar_t* key_name = kBackgroundModeRegistryKeyName; - RegKey read_key(kBackgroundModeRegistryRootKey, - kBackgroundModeRegistrySubkey, KEY_READ); - RegKey write_key(kBackgroundModeRegistryRootKey, - kBackgroundModeRegistrySubkey, KEY_WRITE); + base::win::RegKey read_key(kBackgroundModeRegistryRootKey, + kBackgroundModeRegistrySubkey, KEY_READ); + base::win::RegKey write_key(kBackgroundModeRegistryRootKey, + kBackgroundModeRegistrySubkey, KEY_WRITE); if (should_launch) { FilePath executable; if (!PathService::Get(base::FILE_EXE, &executable)) diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 4360909..73f31c4 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -72,8 +72,7 @@ #include "app/os_exchange_data_provider_win.h" #include "app/win_util.h" #include "base/base_drag_source.h" -#include "base/registry.h" -#include "base/scoped_comptr_win.h" +#include "base/win/scoped_comptr.h" #include "base/win_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/views/frame/browser_view.h" @@ -602,7 +601,7 @@ void UpdateAppIconDownloadProgress(int download_count, if (base::win::GetVersion() < base::win::VERSION_WIN7) return; - ScopedComPtr<ITaskbarList3> taskbar; + base::win::ScopedComPtr<ITaskbarList3> taskbar; HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER); if (FAILED(result)) { diff --git a/chrome/browser/extensions/extension_rlz_apitest.cc b/chrome/browser/extensions/extension_rlz_apitest.cc index ce97ae0f..10bfba6 100644 --- a/chrome/browser/extensions/extension_rlz_apitest.cc +++ b/chrome/browser/extensions/extension_rlz_apitest.cc @@ -4,7 +4,7 @@ #include <map> -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_function.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" @@ -51,8 +51,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Rlz) { rlz_lib::ClearProductState(rlz_lib::DESKTOP, access_points); // Check that the state has really been cleared. - RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\Common\\Rlz\\Events\\N", - KEY_READ); + base::win::RegKey key(HKEY_CURRENT_USER, + L"Software\\Google\\Common\\Rlz\\Events\\N", + KEY_READ); ASSERT_FALSE(key.Valid()); key.Open(HKEY_CURRENT_USER, L"Software\\Google\\Common\\Rlz\\Events\\D", diff --git a/chrome/browser/extensions/external_registry_extension_provider_win.cc b/chrome/browser/extensions/external_registry_extension_provider_win.cc index c18aaa7..02ae850 100644 --- a/chrome/browser/extensions/external_registry_extension_provider_win.cc +++ b/chrome/browser/extensions/external_registry_extension_provider_win.cc @@ -1,14 +1,14 @@ -// Copyright (c) 2009 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. #include "chrome/browser/extensions/external_registry_extension_provider_win.h" #include "base/file_path.h" -#include "base/registry.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/version.h" +#include "base/win/registry.h" // The Registry hive where to look for external extensions. const HKEY kRegRoot = HKEY_LOCAL_MACHINE; @@ -30,10 +30,10 @@ ExternalRegistryExtensionProvider::~ExternalRegistryExtensionProvider() { void ExternalRegistryExtensionProvider::VisitRegisteredExtension( Visitor* visitor, const std::set<std::string>& ids_to_ignore) const { - RegistryKeyIterator iterator(kRegRoot, - ASCIIToWide(kRegistryExtensions).c_str()); + base::win::RegistryKeyIterator iterator( + kRegRoot, ASCIIToWide(kRegistryExtensions).c_str()); while (iterator.Valid()) { - RegKey key; + base::win::RegKey key; std::wstring key_path = ASCIIToWide(kRegistryExtensions); key_path.append(L"\\"); key_path.append(iterator.Name()); @@ -78,7 +78,7 @@ void ExternalRegistryExtensionProvider::VisitRegisteredExtension( Version* ExternalRegistryExtensionProvider::RegisteredVersion( const std::string& id, Extension::Location* location) const { - RegKey key; + base::win::RegKey key; std::wstring key_path = ASCIIToWide(kRegistryExtensions); key_path.append(L"\\"); key_path.append(ASCIIToWide(id)); diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index df3f46d..4f9175d 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -18,12 +18,12 @@ #include "base/file_util.h" #include "base/object_watcher.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_comptr_win.h" #include "base/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/extension_updater.h" @@ -280,7 +280,7 @@ bool Upgrade::SwapNewChromeExeIfPresent() { bool user_install = InstallUtil::IsPerUserInstall(curr_chrome_exe.c_str()); HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; BrowserDistribution *dist = BrowserDistribution::GetDistribution(); - RegKey key; + base::win::RegKey key; std::wstring rename_cmd; if (key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) && key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd)) { diff --git a/chrome/browser/history/history_publisher_win.cc b/chrome/browser/history/history_publisher_win.cc index 3a7a548..39ef521 100644 --- a/chrome/browser/history/history_publisher_win.cc +++ b/chrome/browser/history/history_publisher_win.cc @@ -9,13 +9,13 @@ #include <oleauto.h> #include <wtypes.h> -#include "base/registry.h" #include "base/scoped_bstr_win.h" #include "base/scoped_comptr_win.h" #include "base/scoped_variant_win.h" #include "base/string_util.h" #include "base/time.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "googleurl/src/gurl.h" namespace { @@ -42,7 +42,7 @@ bool CoCreateIndexerFromName(const wchar_t* name, void AddRegisteredIndexers(HKEY root, const wchar_t* path, std::vector< ScopedComPtr<IChromeHistoryIndexer> >* indexers) { IChromeHistoryIndexer* indexer; - RegistryKeyIterator r_iter(root, path); + base::win::RegistryKeyIterator r_iter(root, path); while (r_iter.Valid()) { if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) { indexers->push_back(ScopedComPtr<IChromeHistoryIndexer>(indexer)); diff --git a/chrome/browser/importer/firefox_importer_utils_win.cc b/chrome/browser/importer/firefox_importer_utils_win.cc index 3200eb1..7fc2a41 100644 --- a/chrome/browser/importer/firefox_importer_utils_win.cc +++ b/chrome/browser/importer/firefox_importer_utils_win.cc @@ -7,7 +7,7 @@ #include <shlobj.h> #include "base/file_util.h" -#include "base/registry.h" +#include "base/win/registry.h" // NOTE: Keep these in order since we need test all those paths according // to priority. For example. One machine has multiple users. One non-admin @@ -28,8 +28,8 @@ int GetCurrentFirefoxMajorVersionFromRegistry() { // written under HKLM\Mozilla. Otherwise it the keys will be written under // HKCU\Mozilla. for (int i = 0; i < arraysize(kFireFoxRegistryPaths); ++i) { - RegKey reg_key(kFireFoxRegistryPaths[i], - L"Software\\Mozilla\\Mozilla Firefox", KEY_READ); + base::win::RegKey reg_key(kFireFoxRegistryPaths[i], + L"Software\\Mozilla\\Mozilla Firefox", KEY_READ); bool result = reg_key.ReadValue(L"CurrentVersion", ver_buffer, &ver_buffer_length, NULL); @@ -45,14 +45,16 @@ std::wstring GetFirefoxInstallPathFromRegistry() { std::wstring registry_path = L"Software\\Mozilla\\Mozilla Firefox"; wchar_t buffer[MAX_PATH]; DWORD buffer_length = sizeof(buffer); - RegKey reg_key(HKEY_LOCAL_MACHINE, registry_path.c_str(), KEY_READ); + base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, registry_path.c_str(), + KEY_READ); bool result = reg_key.ReadValue(L"CurrentVersion", buffer, &buffer_length, NULL); if (!result) return std::wstring(); registry_path += L"\\" + std::wstring(buffer) + L"\\Main"; buffer_length = sizeof(buffer); - RegKey reg_key_directory(HKEY_LOCAL_MACHINE, registry_path.c_str(), KEY_READ); + base::win::RegKey reg_key_directory(HKEY_LOCAL_MACHINE, + registry_path.c_str(), KEY_READ); result = reg_key_directory.ReadValue(L"Install Directory", buffer, &buffer_length, NULL); if (!result) diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 2d6d319..07b2d34 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -19,13 +19,13 @@ #include "app/win_util.h" #include "base/file_path.h" #include "base/file_util.h" -#include "base/registry.h" #include "base/scoped_comptr_win.h" #include "base/string_split.h" #include "base/string_util.h" #include "base/time.h" #include "base/values.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/importer/importer_bridge.h" @@ -40,6 +40,8 @@ #include "webkit/glue/password_form.h" using base::Time; +using base::win::RegKey; +using base::win::RegistryValueIterator; using webkit_glue::PasswordForm; namespace { @@ -354,7 +356,8 @@ void IEImporter::ImportSearchEngines() { const TemplateURL* default_search_engine = NULL; std::map<std::string, TemplateURL*> search_engines_map; key.ReadValue(L"DefaultScope", &default_search_engine_name); - RegistryKeyIterator key_iterator(HKEY_CURRENT_USER, kSearchScopePath); + base::win::RegistryKeyIterator key_iterator(HKEY_CURRENT_USER, + kSearchScopePath); while (key_iterator.Valid()) { std::wstring sub_key_name = kSearchScopePath; sub_key_name.append(L"\\").append(key_iterator.Name()); diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index a807a42..c20c925 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -14,10 +14,10 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/logging.h" -#include "base/registry.h" #include "base/scoped_comptr_win.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/install_util.h" @@ -110,7 +110,7 @@ void OpenExternal(const GURL& url) { return; } - RegKey key; + base::win::RegKey key; std::wstring registry_path = ASCIIToWide(url.scheme()) + L"\\shell\\open\\command"; key.Open(HKEY_CLASSES_ROOT, registry_path.c_str(), KEY_READ); diff --git a/chrome/browser/plugin_service.h b/chrome/browser/plugin_service.h index 9ff7988..abb55a1 100644 --- a/chrome/browser/plugin_service.h +++ b/chrome/browser/plugin_service.h @@ -21,8 +21,8 @@ #include "googleurl/src/gurl.h" #if defined(OS_WIN) -#include "base/registry.h" #include "base/scoped_ptr.h" +#include "base/win/registry.h" #endif #if defined(OS_CHROMEOS) @@ -168,8 +168,8 @@ class PluginService #if defined(OS_WIN) // Registry keys for getting notifications when new plugins are installed. - RegKey hkcu_key_; - RegKey hklm_key_; + base::win::RegKey hkcu_key_; + base::win::RegKey hklm_key_; scoped_ptr<base::WaitableEvent> hkcu_event_; scoped_ptr<base::WaitableEvent> hklm_event_; base::WaitableEventWatcher hkcu_watcher_; diff --git a/chrome/browser/policy/configuration_policy_provider_win.cc b/chrome/browser/policy/configuration_policy_provider_win.cc index 18edc88..c1ae3705 100644 --- a/chrome/browser/policy/configuration_policy_provider_win.cc +++ b/chrome/browser/policy/configuration_policy_provider_win.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/object_watcher.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_piece.h" @@ -18,10 +17,39 @@ #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "base/win/registry.h" #include "chrome/common/policy_constants.h" +using base::win::RegKey; + namespace policy { +namespace { + +bool ReadRegistryStringValue(RegKey* key, const string16& name, + string16* result) { + DWORD value_size = 0; + DWORD key_type = 0; + scoped_array<uint8> buffer; + + if (!key->ReadValue(name.c_str(), 0, &value_size, &key_type)) + return false; + if (key_type != REG_SZ) + return false; + + // According to the Microsoft documentation, the string + // buffer may not be explicitly 0-terminated. Allocate a + // slightly larger buffer and pre-fill to zeros to guarantee + // the 0-termination. + buffer.reset(new uint8[value_size + 2]); + memset(buffer.get(), 0, value_size + 2); + key->ReadValue(name.c_str(), buffer.get(), &value_size, NULL); + result->assign(reinterpret_cast<const wchar_t*>(buffer.get())); + return true; +} + +} // namespace + // Period at which to run the reload task in case the group policy change // watchers fail. const int kReloadIntervalMinutes = 15; @@ -155,28 +183,6 @@ bool ConfigurationPolicyProviderWin::GetRegistryPolicyString( return ReadRegistryStringValue(&policy_key, name, result); } -bool ConfigurationPolicyProviderWin::ReadRegistryStringValue( - RegKey* key, const string16& name, string16* result) { - DWORD value_size = 0; - DWORD key_type = 0; - scoped_array<uint8> buffer; - - if (!key->ReadValue(name.c_str(), 0, &value_size, &key_type)) - return false; - if (key_type != REG_SZ) - return false; - - // According to the Microsoft documentation, the string - // buffer may not be explicitly 0-terminated. Allocate a - // slightly larger buffer and pre-fill to zeros to guarantee - // the 0-termination. - buffer.reset(new uint8[value_size + 2]); - memset(buffer.get(), 0, value_size + 2); - key->ReadValue(name.c_str(), buffer.get(), &value_size, NULL); - result->assign(reinterpret_cast<const wchar_t*>(buffer.get())); - return true; -} - bool ConfigurationPolicyProviderWin::GetRegistryPolicyStringList( const string16& key, ListValue* result) { string16 path = string16(kRegistrySubKey); diff --git a/chrome/browser/policy/configuration_policy_provider_win.h b/chrome/browser/policy/configuration_policy_provider_win.h index e0d797f..26bc3e6 100644 --- a/chrome/browser/policy/configuration_policy_provider_win.h +++ b/chrome/browser/policy/configuration_policy_provider_win.h @@ -14,7 +14,11 @@ #include "chrome/browser/policy/configuration_policy_store.h" #include "chrome/browser/policy/configuration_policy_provider.h" +namespace base { +namespace win { class RegKey; +} // namespace win +} // namespace base namespace policy { @@ -99,8 +103,6 @@ class ConfigurationPolicyProviderWin // Reads a string registry value |name| at the specified |key| and puts the // resulting string in |result|. - bool ReadRegistryStringValue(RegKey* key, const string16& name, - string16* result); bool GetRegistryPolicyString(const string16& name, string16* result); // Gets a list value contained under |key| one level below the policy root. diff --git a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc index 0dac818..f7a3524 100644 --- a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc @@ -6,12 +6,12 @@ #include <windows.h> -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/stl_util-inl.h" #include "base/string_number_conversions.h" #include "base/string_piece.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/configuration_policy_provider_win.h" #include "chrome/browser/policy/mock_configuration_policy_store.h" @@ -19,6 +19,8 @@ #include "chrome/common/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace policy { const wchar_t kUnitTestRegistrySubKey[] = L"SOFTWARE\\Chromium Unit Tests"; diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc index 8680de6..f2ca69f 100644 --- a/chrome/browser/rlz/rlz_unittest.cc +++ b/chrome/browser/rlz/rlz_unittest.cc @@ -4,11 +4,14 @@ #include "chrome/browser/rlz/rlz.h" -#include "base/registry.h" #include "base/path_service.h" +#include "base/win/registry.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { + // Gets rid of registry leftovers from testing. Returns false if there // is nothing to clean. bool CleanValue(const wchar_t* key_name, const wchar_t* value) { diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 98e6729..2d53d28 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -13,12 +13,12 @@ #include "base/file_util.h" #include "base/message_loop.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_comptr_win.h" #include "base/string_util.h" #include "base/task.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/web_applications/web_app.h" @@ -340,7 +340,7 @@ ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { HKEY root_key = HKEY_CLASSES_ROOT; // Check <protocol>\shell\open\command std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); - RegKey key(root_key, key_path.c_str(), KEY_READ); + base::win::RegKey key(root_key, key_path.c_str(), KEY_READ); std::wstring value; if (!key.Valid() || !key.ReadValue(L"", &value)) return NOT_DEFAULT_BROWSER; @@ -371,14 +371,15 @@ bool ShellIntegration::IsFirefoxDefaultBrowser() { bool ff_default = false; if (base::win::GetVersion() >= base::win::VERSION_VISTA) { std::wstring app_cmd; - RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); + base::win::RegKey key(HKEY_CURRENT_USER, + ShellUtil::kRegVistaUrlPrefs, KEY_READ); if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && app_cmd == L"FirefoxURL") ff_default = true; } else { std::wstring key_path(L"http"); key_path.append(ShellUtil::kRegShellOpen); - RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); + base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); std::wstring app_cmd; if (key.Valid() && key.ReadValue(L"", &app_cmd) && std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc index 6dda2e3..3022c28 100644 --- a/chrome/browser/views/external_protocol_dialog.cc +++ b/chrome/browser/views/external_protocol_dialog.cc @@ -7,10 +7,10 @@ #include "app/l10n_util.h" #include "app/message_box_flags.h" #include "base/metrics/histogram.h" -#include "base/registry.h" #include "base/string_util.h" #include "base/thread.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -160,7 +160,7 @@ std::wstring ExternalProtocolDialog::GetApplicationForProtocol( std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec()); std::wstring cmd_key_path = ASCIIToWide(url.scheme() + "\\shell\\open\\command"); - RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ); + base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ); size_t split_offset = url_spec.find(L':'); if (split_offset == std::wstring::npos) return std::wstring(); diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc index e8ec6e8..d3fe7ae 100644 --- a/chrome/browser/views/shell_dialogs_win.cc +++ b/chrome/browser/views/shell_dialogs_win.cc @@ -14,11 +14,11 @@ #include "app/l10n_util.h" #include "base/file_util.h" #include "base/message_loop.h" -#include "base/registry.h" #include "base/scoped_comptr_win.h" #include "base/string_split.h" #include "base/thread.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "gfx/font.h" @@ -49,7 +49,7 @@ std::wstring AppendExtensionIfNeeded(const std::wstring& filename, std::wstring file_extension(file_util::GetFileExtensionFromPath(filename)); std::wstring key(L"." + file_extension); if (!(filter_selected.empty() || filter_selected == L"*.*") && - !RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).Valid() && + !base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).Valid() && file_extension != suggested_ext) { if (return_value[return_value.length() - 1] != L'.') return_value.append(L"."); @@ -73,10 +73,10 @@ namespace { static bool GetRegistryDescriptionFromExtension(const std::wstring& file_ext, std::wstring* reg_description) { DCHECK(reg_description); - RegKey reg_ext(HKEY_CLASSES_ROOT, file_ext.c_str(), KEY_READ); + base::win::RegKey reg_ext(HKEY_CLASSES_ROOT, file_ext.c_str(), KEY_READ); std::wstring reg_app; if (reg_ext.ReadValue(NULL, ®_app) && !reg_app.empty()) { - RegKey reg_link(HKEY_CLASSES_ROOT, reg_app.c_str(), KEY_READ); + base::win::RegKey reg_link(HKEY_CLASSES_ROOT, reg_app.c_str(), KEY_READ); if (reg_link.ReadValue(NULL, reg_description)) return true; } diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc index 5d1264b..f0dd8c1 100644 --- a/chrome/common/chrome_plugin_lib.cc +++ b/chrome/common/chrome_plugin_lib.cc @@ -12,7 +12,7 @@ #include "base/perftimer.h" #include "base/thread.h" #if defined(OS_WIN) -#include "base/registry.h" +#include "base/win/registry.h" #endif #include "base/string_util.h" #include "chrome/common/chrome_counters.h" @@ -149,7 +149,7 @@ void ChromePluginLib::LoadChromePlugins(const CPBrowserFuncs* bfuncs) { std::wstring reg_path = kRegistryChromePlugins; reg_path.append(L"\\"); reg_path.append(iter.Name()); - RegKey key(HKEY_CURRENT_USER, reg_path.c_str()); + base::win::RegKey key(HKEY_CURRENT_USER, reg_path.c_str()); DWORD is_persistent; if (key.ReadValueDW(kRegistryLoadOnStartup, &is_persistent) && diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 04bca30..3a80634 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/installer/setup/install.h" + #include <shlobj.h> #include <time.h> -#include "chrome/installer/setup/install.h" - #include "base/command_line.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_ptr.h" +#include "base/win/registry.h" #include "chrome/installer/setup/setup_constants.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/create_reg_key_work_item.h" @@ -216,7 +216,7 @@ void DeleteUninstallShortcutsForMSI(bool is_system_install) { // First attempt to delete the old installation's ARP dialog entry. HKEY reg_root = is_system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - RegKey root_key(reg_root, L"", KEY_ALL_ACCESS); + base::win::RegKey root_key(reg_root, L"", KEY_ALL_ACCESS); BrowserDistribution* dist = BrowserDistribution::GetDistribution(); std::wstring uninstall_reg = dist->GetUninstallRegPath(); InstallUtil::DeleteRegistryKey(root_key, uninstall_reg); @@ -604,7 +604,8 @@ installer_util::InstallStatus InstallNewVersion( std::wstring new_chrome_exe = AppendPath(install_path, installer_util::kChromeNewExe); BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); + base::win::RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), + KEY_READ); if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) chrome_key.ReadValue(google_update::kRegOldVersionField, current_version); if (current_version->empty()) diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 9ab8aab..173aea9 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -8,10 +8,10 @@ #include "base/file_util.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/result_codes.h" #include "chrome/common/chrome_constants.h" @@ -30,6 +30,8 @@ // Build-time generated include file. #include "registered_dlls.h" // NOLINT +using base::win::RegKey; + namespace { // This functions checks for any Chrome instances that are diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc index 4220005..baf7031 100644 --- a/chrome/installer/util/browser_distribution.cc +++ b/chrome/installer/util/browser_distribution.cc @@ -11,7 +11,7 @@ #include "base/command_line.h" #include "base/lock.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" #include "chrome/installer/util/chrome_frame_distribution.h" @@ -122,7 +122,7 @@ std::wstring BrowserDistribution::GetStatsServerURL() { return L""; } -std::wstring BrowserDistribution::GetDistributionData(RegKey* key) { +std::wstring BrowserDistribution::GetDistributionData(base::win::RegKey* key) { return L""; } diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h index e829969..39eecdd 100644 --- a/chrome/installer/util/browser_distribution.h +++ b/chrome/installer/util/browser_distribution.h @@ -12,7 +12,11 @@ #include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/version.h" +namespace base { +namespace win { class RegKey; +} // namespace win +} // namespace base class BrowserDistribution { public: @@ -53,7 +57,7 @@ class BrowserDistribution { virtual std::wstring GetStatsServerURL(); - virtual std::wstring GetDistributionData(RegKey* key); + virtual std::wstring GetDistributionData(base::win::RegKey* key); virtual std::wstring GetUninstallLinkName(); diff --git a/chrome/installer/util/compat_checks.cc b/chrome/installer/util/compat_checks.cc index f84a27f..09eb0f2 100644 --- a/chrome/installer/util/compat_checks.cc +++ b/chrome/installer/util/compat_checks.cc @@ -4,10 +4,10 @@ #include "chrome/installer/util/compat_checks.h" -#include "base/registry.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" +#include "base/win/registry.h" namespace { @@ -15,7 +15,7 @@ namespace { std::wstring GetSEPVersion() { const wchar_t kProductKey[] = L"SOFTWARE\\Symantec\\Symantec Endpoint Protection\\SMC"; - RegKey key(HKEY_LOCAL_MACHINE, kProductKey, KEY_READ); + base::win::RegKey key(HKEY_LOCAL_MACHINE, kProductKey, KEY_READ); std::wstring version_str; key.ReadValue(L"ProductVersion", &version_str); return version_str; diff --git a/chrome/installer/util/create_reg_key_work_item.cc b/chrome/installer/util/create_reg_key_work_item.cc index 4c1eb2c..6c4a2a0 100644 --- a/chrome/installer/util/create_reg_key_work_item.cc +++ b/chrome/installer/util/create_reg_key_work_item.cc @@ -6,11 +6,13 @@ #include "base/file_util.h" #include "base/logging.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome/installer/util/create_reg_key_work_item.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/logging_installer.h" +using base::win::RegKey; + namespace { // TODO: refactor this because it is only used once. diff --git a/chrome/installer/util/create_reg_key_work_item_unittest.cc b/chrome/installer/util/create_reg_key_work_item_unittest.cc index 4f8a9ee..c4f9d88 100644 --- a/chrome/installer/util/create_reg_key_work_item_unittest.cc +++ b/chrome/installer/util/create_reg_key_work_item_unittest.cc @@ -5,33 +5,38 @@ #include <windows.h> #include "base/file_util.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "chrome/installer/util/create_reg_key_work_item.h" #include "chrome/installer/util/work_item.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { - wchar_t test_root[] = L"TmpTmp"; - class CreateRegKeyWorkItemTest : public testing::Test { - protected: - virtual void SetUp() { - // Create a temporary key for testing - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - key.DeleteKey(test_root); - ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); - } - virtual void TearDown() { - logging::CloseLogFile(); - // Clean up the temporary key - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - ASSERT_TRUE(key.DeleteKey(test_root)); - } - }; + +wchar_t test_root[] = L"TmpTmp"; + +class CreateRegKeyWorkItemTest : public testing::Test { + protected: + virtual void SetUp() { + // Create a temporary key for testing + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + key.DeleteKey(test_root); + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); + } + virtual void TearDown() { + logging::CloseLogFile(); + // Clean up the temporary key + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + ASSERT_TRUE(key.DeleteKey(test_root)); + } }; +} // namespace + TEST_F(CreateRegKeyWorkItemTest, CreateKey) { RegKey key; diff --git a/chrome/installer/util/delete_after_reboot_helper.cc b/chrome/installer/util/delete_after_reboot_helper.cc index 6806f78..345ba01a 100644 --- a/chrome/installer/util/delete_after_reboot_helper.cc +++ b/chrome/installer/util/delete_after_reboot_helper.cc @@ -16,7 +16,7 @@ #include <vector> #include "base/file_util.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "base/string_util.h" // The moves-pending-reboot is a MULTISZ registry key in the HKLM part of the @@ -245,8 +245,8 @@ HRESULT GetPendingMovesValue( // Get the current value of the key // If the Key is missing, that's totally acceptable. - RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, - KEY_QUERY_VALUE); + base::win::RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, + KEY_QUERY_VALUE); HKEY session_manager_handle = session_manager_key.Handle(); if (!session_manager_handle) { return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); @@ -351,8 +351,8 @@ bool RemoveFromMovesPendingReboot(const wchar_t* directory) { } // Write the key back into a buffer. - RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, - KEY_CREATE_SUB_KEY | KEY_SET_VALUE); + base::win::RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, + KEY_CREATE_SUB_KEY | KEY_SET_VALUE); if (!session_manager_key.Handle()) { // Couldn't open / create the key. LOG(ERROR) << "Failed to open session manager key for writing."; diff --git a/chrome/installer/util/delete_after_reboot_helper_unittest.cc b/chrome/installer/util/delete_after_reboot_helper_unittest.cc index 114825c..5d8adaf 100644 --- a/chrome/installer/util/delete_after_reboot_helper_unittest.cc +++ b/chrome/installer/util/delete_after_reboot_helper_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 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. @@ -6,9 +6,9 @@ #include <shlobj.h> #include "base/file_util.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "chrome/installer/util/delete_after_reboot_helper.h" #include "testing/gtest/include/gtest/gtest.h" @@ -43,8 +43,9 @@ class DeleteAfterRebootHelperTest : public testing::Test { // Try and restore the pending moves value, if we have one. if (IsUserAnAdmin() && original_pending_moves_.size() > 1) { - RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, - KEY_CREATE_SUB_KEY | KEY_SET_VALUE); + base::win::RegKey session_manager_key( + HKEY_LOCAL_MACHINE, kSessionManagerKey, + KEY_CREATE_SUB_KEY | KEY_SET_VALUE); if (!session_manager_key.Handle()) { // Couldn't open / create the key. DLOG(ERROR) << "Failed to open session manager key for writing."; diff --git a/chrome/installer/util/delete_reg_value_work_item.cc b/chrome/installer/util/delete_reg_value_work_item.cc index 7246d52..1c114e2 100644 --- a/chrome/installer/util/delete_reg_value_work_item.cc +++ b/chrome/installer/util/delete_reg_value_work_item.cc @@ -5,9 +5,11 @@ #include "chrome/installer/util/delete_reg_value_work_item.h" #include "base/logging.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome/installer/util/logging_installer.h" +using base::win::RegKey; + DeleteRegValueWorkItem::DeleteRegValueWorkItem(HKEY predefined_root, const std::wstring& key_path, const std::wstring& value_name, diff --git a/chrome/installer/util/delete_reg_value_work_item_unittest.cc b/chrome/installer/util/delete_reg_value_work_item_unittest.cc index c9d5783..fcec35c 100644 --- a/chrome/installer/util/delete_reg_value_work_item_unittest.cc +++ b/chrome/installer/util/delete_reg_value_work_item_unittest.cc @@ -1,37 +1,42 @@ -// 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. #include <windows.h> #include "base/file_util.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "chrome/installer/util/delete_reg_value_work_item.h" #include "chrome/installer/util/work_item.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { - wchar_t test_root[] = L"DeleteRegValueWorkItemTest"; - class DeleteRegValueWorkItemTest : public testing::Test { - protected: - virtual void SetUp() { - // Create a temporary key for testing - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - key.DeleteKey(test_root); - ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); - } - virtual void TearDown() { - logging::CloseLogFile(); - // Clean up the temporary key - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - ASSERT_TRUE(key.DeleteKey(test_root)); - } - }; + +wchar_t test_root[] = L"DeleteRegValueWorkItemTest"; + +class DeleteRegValueWorkItemTest : public testing::Test { + protected: + virtual void SetUp() { + // Create a temporary key for testing + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + key.DeleteKey(test_root); + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); + } + virtual void TearDown() { + logging::CloseLogFile(); + // Clean up the temporary key + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + ASSERT_TRUE(key.DeleteKey(test_root)); + } }; +} // namespace + // Delete a value. The value should get deleted after Do() and should be // recreated after Rollback(). TEST_F(DeleteRegValueWorkItemTest, DeleteExistingValue) { diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index c0fc09dc..90c684c 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -16,11 +16,11 @@ #include "base/file_path.h" #include "base/path_service.h" #include "base/rand_util.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/json_value_serializer.h" @@ -39,6 +39,7 @@ #pragma comment(lib, "wtsapi32.lib") namespace { + const wchar_t kChromeGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; const wchar_t kBrowserAppId[] = L"Chrome"; @@ -437,13 +438,14 @@ std::wstring GoogleChromeDistribution::GetStatsServerURL() { return L"https://clients4.google.com/firefox/metrics/collect"; } -std::wstring GoogleChromeDistribution::GetDistributionData(RegKey* key) { +std::wstring GoogleChromeDistribution::GetDistributionData( + base::win::RegKey* key) { DCHECK(NULL != key); std::wstring sub_key(google_update::kRegPathClientState); sub_key.append(L"\\"); sub_key.append(product_guid()); - RegKey client_state_key(key->Handle(), sub_key.c_str(), KEY_READ); + base::win::RegKey client_state_key(key->Handle(), sub_key.c_str(), KEY_READ); std::wstring result; std::wstring brand_value; if (client_state_key.ReadValue(google_update::kRegRLZBrandField, diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h index a8eb493..53d754b 100644 --- a/chrome/installer/util/google_chrome_distribution.h +++ b/chrome/installer/util/google_chrome_distribution.h @@ -55,7 +55,7 @@ class GoogleChromeDistribution : public BrowserDistribution { // This method reads data from the Google Update ClientState key for // potential use in the uninstall survey. It must be called before the // key returned by GetVersionKey() is deleted. - virtual std::wstring GetDistributionData(RegKey* key); + virtual std::wstring GetDistributionData(base::win::RegKey* key); virtual std::wstring GetUninstallLinkName(); diff --git a/chrome/installer/util/google_chrome_distribution_dummy.cc b/chrome/installer/util/google_chrome_distribution_dummy.cc index b2cafe9..a50dd11 100644 --- a/chrome/installer/util/google_chrome_distribution_dummy.cc +++ b/chrome/installer/util/google_chrome_distribution_dummy.cc @@ -78,7 +78,8 @@ std::wstring GoogleChromeDistribution::GetStatsServerURL() { return std::wstring(); } -std::wstring GoogleChromeDistribution::GetDistributionData(RegKey* key) { +std::wstring GoogleChromeDistribution::GetDistributionData( + base::win::RegKey* key) { NOTREACHED(); return std::wstring(); } diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index 91867f3..747fbb1 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -7,15 +7,17 @@ #include <algorithm> #include "base/command_line.h" -#include "base/registry.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" +#include "base/win/registry.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/install_util.h" +using base::win::RegKey; + namespace { bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index 5b5d1e2..75f15a8 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -5,14 +5,16 @@ #include <windows.h> #include <shlwapi.h> // For SHDeleteKey. -#include "base/registry.h" #include "base/scoped_ptr.h" +#include "base/win/registry.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/work_item_list.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { const wchar_t kHKCUReplacement[] = diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index a0dfad1..601d0eb 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -16,10 +16,10 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_util.h" #include "base/values.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/json_value_serializer.h" #include "chrome/installer/util/browser_distribution.h" @@ -29,6 +29,8 @@ #include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/work_item_list.h" +using base::win::RegKey; + bool InstallUtil::ExecuteExeAsAdmin(const std::wstring& exe, const std::wstring& params, DWORD* exit_code) { diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h index e72cf04..f33bfb6 100644 --- a/chrome/installer/util/install_util.h +++ b/chrome/installer/util/install_util.h @@ -19,7 +19,12 @@ #include "chrome/installer/util/version.h" class WorkItemList; + +namespace base { +namespace win { class RegKey; +} // namespace win +} // namespace base // This is a utility class that provides common installation related // utility methods that can be used by installer and also unit tested @@ -105,7 +110,8 @@ class InstallUtil { WorkItemList* registration_list); // Deletes the registry key at path key_path under the key given by root_key. - static bool DeleteRegistryKey(RegKey& root_key, const std::wstring& key_path); + static bool DeleteRegistryKey(base::win::RegKey& root_key, + const std::wstring& key_path); // Deletes the registry value named value_name at path key_path under the key // given by reg_root. diff --git a/chrome/installer/util/set_reg_value_work_item.cc b/chrome/installer/util/set_reg_value_work_item.cc index 0cf9129..0dae573 100644 --- a/chrome/installer/util/set_reg_value_work_item.cc +++ b/chrome/installer/util/set_reg_value_work_item.cc @@ -5,7 +5,7 @@ #include "chrome/installer/util/set_reg_value_work_item.h" #include "base/logging.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome/installer/util/logging_installer.h" SetRegValueWorkItem::~SetRegValueWorkItem() { @@ -49,7 +49,7 @@ bool SetRegValueWorkItem::Do() { return false; } - RegKey key; + base::win::RegKey key; if (!key.Open(predefined_root_, key_path_.c_str(), KEY_READ | KEY_SET_VALUE)) { LOG(ERROR) << "can not open " << key_path_; @@ -121,7 +121,7 @@ void SetRegValueWorkItem::Rollback() { return; } - RegKey key; + base::win::RegKey key; if (!key.Open(predefined_root_, key_path_.c_str(), KEY_READ | KEY_SET_VALUE)) { status_ = VALUE_ROLL_BACK; diff --git a/chrome/installer/util/set_reg_value_work_item_unittest.cc b/chrome/installer/util/set_reg_value_work_item_unittest.cc index 7e347e2..13faba5 100644 --- a/chrome/installer/util/set_reg_value_work_item_unittest.cc +++ b/chrome/installer/util/set_reg_value_work_item_unittest.cc @@ -5,37 +5,41 @@ #include <windows.h> #include "base/file_util.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "chrome/installer/util/set_reg_value_work_item.h" #include "chrome/installer/util/work_item.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { - wchar_t test_root[] = L"TempTemp"; - wchar_t data_str_1[] = L"data_111"; - wchar_t data_str_2[] = L"data_222"; - DWORD dword1 = 0; - DWORD dword2 = 1; - class SetRegValueWorkItemTest : public testing::Test { - protected: - virtual void SetUp() { - // Create a temporary key for testing - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - key.DeleteKey(test_root); - ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); - } - virtual void TearDown() { - logging::CloseLogFile(); - // Clean up the temporary key - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - ASSERT_TRUE(key.DeleteKey(test_root)); - } - }; + +wchar_t test_root[] = L"TempTemp"; +wchar_t data_str_1[] = L"data_111"; +wchar_t data_str_2[] = L"data_222"; +DWORD dword1 = 0; +DWORD dword2 = 1; +class SetRegValueWorkItemTest : public testing::Test { + protected: + virtual void SetUp() { + // Create a temporary key for testing + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + key.DeleteKey(test_root); + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); + } + virtual void TearDown() { + logging::CloseLogFile(); + // Clean up the temporary key + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + ASSERT_TRUE(key.DeleteKey(test_root)); + } }; +} // namespace + // Write a new value without overwrite flag. The value should be set. TEST_F(SetRegValueWorkItemTest, WriteNewNonOverwrite) { RegKey key; diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 257a78f..212f04b 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -16,7 +16,6 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/stl_util-inl.h" #include "base/string_number_conversions.h" @@ -24,6 +23,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -33,6 +33,8 @@ #include "installer_util_strings.h" +using base::win::RegKey; + namespace { // This class represents a single registry entry. The objective is to @@ -570,7 +572,8 @@ void ShellUtil::GetRegisteredBrowsers(std::map<std::wstring, std::wstring>* browsers) { std::wstring base_key(ShellUtil::kRegStartMenuInternet); HKEY root = HKEY_LOCAL_MACHINE; - for (RegistryKeyIterator iter(root, base_key.c_str()); iter.Valid(); ++iter) { + for (base::win::RegistryKeyIterator iter(root, base_key.c_str()); + iter.Valid(); ++iter) { std::wstring key = base_key + L"\\" + iter.Name(); RegKey capabilities(root, (key + L"\\Capabilities").c_str(), KEY_READ); std::wstring name; diff --git a/chrome/installer/util/work_item_list_unittest.cc b/chrome/installer/util/work_item_list_unittest.cc index 8b91fcd..1ba6e52 100644 --- a/chrome/installer/util/work_item_list_unittest.cc +++ b/chrome/installer/util/work_item_list_unittest.cc @@ -7,49 +7,53 @@ #include "base/base_paths.h" #include "base/file_util.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "chrome/installer/util/work_item.h" #include "chrome/installer/util/work_item_list.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { - wchar_t test_root[] = L"ListList"; - wchar_t data_str[] = L"data_111"; - - class WorkItemListTest : public testing::Test { - protected: - virtual void SetUp() { - // Create a temporary key for testing - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - key.DeleteKey(test_root); - ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); - - // Create a temp directory for test. - ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - test_dir_ = test_dir_.AppendASCII("WorkItemListTest"); - file_util::Delete(test_dir_, true); - ASSERT_FALSE(file_util::PathExists(test_dir_)); - file_util::CreateDirectoryW(test_dir_); - ASSERT_TRUE(file_util::PathExists(test_dir_)); - } - - virtual void TearDown() { - logging::CloseLogFile(); - // Clean up test directory - ASSERT_TRUE(file_util::Delete(test_dir_, true)); - ASSERT_FALSE(file_util::PathExists(test_dir_)); - // Clean up the temporary key - RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); - ASSERT_TRUE(key.DeleteKey(test_root)); - } - - FilePath test_dir_; - }; + +wchar_t test_root[] = L"ListList"; +wchar_t data_str[] = L"data_111"; + +class WorkItemListTest : public testing::Test { + protected: + virtual void SetUp() { + // Create a temporary key for testing + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + key.DeleteKey(test_root); + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); + + // Create a temp directory for test. + ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); + test_dir_ = test_dir_.AppendASCII("WorkItemListTest"); + file_util::Delete(test_dir_, true); + ASSERT_FALSE(file_util::PathExists(test_dir_)); + file_util::CreateDirectoryW(test_dir_); + ASSERT_TRUE(file_util::PathExists(test_dir_)); + } + + virtual void TearDown() { + logging::CloseLogFile(); + // Clean up test directory + ASSERT_TRUE(file_util::Delete(test_dir_, true)); + ASSERT_FALSE(file_util::PathExists(test_dir_)); + // Clean up the temporary key + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + ASSERT_TRUE(key.DeleteKey(test_root)); + } + + FilePath test_dir_; }; +} // namespace + // Execute a WorkItem list successfully and then rollback. TEST_F(WorkItemListTest, ExecutionSuccess) { scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index e53b020..0d18716 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -10,15 +10,17 @@ #include "base/platform_thread.h" #include "base/process.h" #include "base/process_util.h" -#include "base/registry.h" #include "base/string_number_conversions.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" #include "chrome/test/mini_installer_test/mini_installer_test_util.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type, bool is_chrome_frame) : is_chrome_frame_(is_chrome_frame), diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp index 0a9ca83..56d41aa 100644 --- a/chrome/test/plugin/plugin_test.cpp +++ b/chrome/test/plugin/plugin_test.cpp @@ -51,7 +51,7 @@ #include "webkit/glue/plugins/plugin_list.h" #if defined(OS_WIN) -#include "base/registry.h" +#include "base/win/registry.h" #endif class PluginTest : public UITest { @@ -80,7 +80,7 @@ class PluginTest : public UITest { if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { // The installer adds our process names to the registry key below. Since // the installer might not have run on this machine, add it manually. - RegKey regkey; + base::win::RegKey regkey; if (regkey.Open(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", KEY_WRITE)) { diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 013995d..b81be69 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -17,11 +17,11 @@ #include "base/logging.h" #include "base/logging_win.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/string_number_conversions.h" #include "base/string_piece.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -40,6 +40,8 @@ #include "chrome_frame/utils.h" #include "googleurl/src/url_util.h" +using base::win::RegKey; + namespace { // This function has the side effect of initializing an unprotected // vector pointer inside GoogleUrl. If this is called during DLL loading, diff --git a/chrome_frame/crash_reporting/crash_metrics.cc b/chrome_frame/crash_reporting/crash_metrics.cc index 3a6c9ee..e5d8fb5 100644 --- a/chrome_frame/crash_reporting/crash_metrics.cc +++ b/chrome_frame/crash_reporting/crash_metrics.cc @@ -5,7 +5,7 @@ #include "chrome_frame/crash_reporting/crash_metrics.h" #include "base/metrics/histogram.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome_frame/utils.h" static const wchar_t kChromeFrameMetricsKey[] = @@ -28,7 +28,7 @@ CrashMetricsReporter* CrashMetricsReporter::GetInstance() { bool CrashMetricsReporter::SetMetric(Metric metric, int value) { DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC); - RegKey metric_key; + base::win::RegKey metric_key; if (metric_key.Create(HKEY_CURRENT_USER, kChromeFrameMetricsKey, KEY_SET_VALUE)) { if (metric_key.WriteValue(g_metric_names[metric], value)) { @@ -47,7 +47,7 @@ int CrashMetricsReporter::GetMetric(Metric metric) { DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC); int ret = 0; - RegKey metric_key; + base::win::RegKey metric_key; if (metric_key.Open(HKEY_CURRENT_USER, kChromeFrameMetricsKey, KEY_QUERY_VALUE)) { int value = 0; diff --git a/chrome_frame/policy_settings.cc b/chrome_frame/policy_settings.cc index 7e5be2c..d00e69a 100644 --- a/chrome_frame/policy_settings.cc +++ b/chrome_frame/policy_settings.cc @@ -5,9 +5,9 @@ #include "chrome_frame/policy_settings.h" #include "base/logging.h" -#include "base/registry.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/common/policy_constants.h" #include "chrome_frame/utils.h" @@ -45,7 +45,7 @@ void PolicySettings::RefreshFromRegistry() { default_renderer_ = RENDERER_NOT_SPECIFIED; renderer_exclusion_list_.clear(); - RegKey config_key; + base::win::RegKey config_key; DWORD value = RENDERER_NOT_SPECIFIED; HKEY root_key[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; std::wstring settings_value( diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index e98d353..99fedd2 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -14,13 +14,13 @@ #include "base/file_version_info.h" #include "base/path_service.h" #include "base/process_util.h" -#include "base/registry.h" // to find IE and firefox #include "base/scoped_handle.h" #include "base/scoped_ptr.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_paths.h" @@ -116,7 +116,8 @@ std::wstring GetExecutableAppPath(const std::wstring& file) { L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"; std::wstring app_path; - RegKey key(HKEY_LOCAL_MACHINE, (kAppPathsKey + file).c_str(), KEY_READ); + base::win::RegKey key(HKEY_LOCAL_MACHINE, (kAppPathsKey + file).c_str(), + KEY_READ); if (key.Handle()) { key.ReadValue(NULL, &app_path); } @@ -129,7 +130,7 @@ std::wstring FormatCommandForApp(const std::wstring& exe_name, std::wstring reg_path( base::StringPrintf(L"Applications\\%ls\\shell\\open\\command", exe_name.c_str())); - RegKey key(HKEY_CLASSES_ROOT, reg_path.c_str(), KEY_READ); + base::win::RegKey key(HKEY_CLASSES_ROOT, reg_path.c_str(), KEY_READ); std::wstring command; if (key.Handle()) { diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index 729f787..34c1183 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -17,7 +17,6 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/process_util.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/scoped_bstr_win.h" #include "base/scoped_comptr_win.h" @@ -27,6 +26,7 @@ #include "base/time.h" #include "base/trace_event_win.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths_internal.h" @@ -1092,7 +1092,7 @@ TEST_F(ChromeFrameCreationTest, PerfCold) { // from the cache. This could also fail if the Flash control is in use. // On Vista this could fail because of UAC TEST_F(FlashCreationTest, PerfCold) { - RegKey flash_key(HKEY_CLASSES_ROOT, kFlashControlKey, KEY_READ); + base::win::RegKey flash_key(HKEY_CLASSES_ROOT, kFlashControlKey, KEY_READ); std::wstring plugin_path; ASSERT_TRUE(flash_key.ReadValue(L"", &plugin_path)); @@ -1112,7 +1112,8 @@ TEST_F(FlashCreationTest, PerfCold) { // correctly causing the attempt to evict the dll from the system cache to // fail. TEST_F(SilverlightCreationTest, DISABLED_PerfCold) { - RegKey silverlight_key(HKEY_CLASSES_ROOT, kSilverlightControlKey, KEY_READ); + base::win::RegKey silverlight_key(HKEY_CLASSES_ROOT, kSilverlightControlKey, + KEY_READ); std::wstring plugin_path; ASSERT_TRUE(silverlight_key.ReadValue(L"", &plugin_path)); diff --git a/chrome_frame/test/policy_settings_unittest.cc b/chrome_frame/test/policy_settings_unittest.cc index a31e764..52a3c55 100644 --- a/chrome_frame/test/policy_settings_unittest.cc +++ b/chrome_frame/test/policy_settings_unittest.cc @@ -4,14 +4,16 @@ #include "base/basictypes.h" #include "base/logging.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/common/policy_constants.h" #include "chrome_frame/policy_settings.h" #include "testing/gtest/include/gtest/gtest.h" +using base::win::RegKey; + namespace { // A best effort way to zap CF policy entries that may be in the registry. diff --git a/chrome_frame/test/util_unittests.cc b/chrome_frame/test/util_unittests.cc index 055bae9..bc18062 100644 --- a/chrome_frame/test/util_unittests.cc +++ b/chrome_frame/test/util_unittests.cc @@ -5,12 +5,14 @@ #include "base/file_path.h" #include "base/file_version_info.h" #include "base/file_version_info_win.h" -#include "base/registry.h" +#include "base/win/registry.h" #include "chrome_frame/utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gmock/include/gmock/gmock.h" +using base::win::RegKey; + const wchar_t kChannelName[] = L"-dev"; const wchar_t kSuffix[] = L"-fix"; diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index ec631bd..4437668 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome_frame/utils.h" + #include <htiframe.h> #include <mshtml.h> #include <shlobj.h> @@ -14,7 +16,6 @@ #include "base/lazy_instance.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_bstr_win.h" #include "base/scoped_comptr_win.h" #include "base/scoped_variant_win.h" @@ -24,6 +25,7 @@ #include "base/stringprintf.h" #include "base/thread_local.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" #include "chrome/common/chrome_paths_internal.h" #include "chrome/common/url_constants.h" #include "chrome/installer/util/chrome_frame_distribution.h" @@ -31,14 +33,14 @@ #include "chrome_frame/html_utils.h" #include "chrome_frame/policy_settings.h" #include "chrome_frame/simple_resource_loader.h" -#include "chrome_frame/utils.h" #include "googleurl/src/gurl.h" #include "googleurl/src/url_canon.h" - #include "grit/chromium_strings.h" #include "net/base/escape.h" #include "net/http/http_util.h" +using base::win::RegKey; + // Note that these values are all lower case and are compared to // lower-case-transformed values. const wchar_t kMetaTag[] = L"meta"; @@ -754,7 +756,7 @@ RendererType RendererTypeForUrl(const std::wstring& url) { } bool match_found = false; - RegistryValueIterator url_list(config_key.Handle(), url_list_name); + base::win::RegistryValueIterator url_list(config_key.Handle(), url_list_name); while (!match_found && url_list.Valid()) { if (MatchPattern(url, url_list.Name())) { match_found = true; @@ -1518,7 +1520,7 @@ void WaitWithMessageLoop(HANDLE* handles, int count, DWORD timeout) { void EnumerateKeyValues(HKEY parent_key, const wchar_t* sub_key_name, std::vector<std::wstring>* values) { DCHECK(values); - RegistryValueIterator url_list(parent_key, sub_key_name); + base::win::RegistryValueIterator url_list(parent_key, sub_key_name); while (url_list.Valid()) { values->push_back(url_list.Value()); ++url_list; diff --git a/net/base/platform_mime_util_win.cc b/net/base/platform_mime_util_win.cc index bffb81a..b93008b 100644 --- a/net/base/platform_mime_util_win.cc +++ b/net/base/platform_mime_util_win.cc @@ -6,8 +6,8 @@ #include "net/base/platform_mime_util.h" -#include "base/registry.h" #include "base/utf_string_conversions.h" +#include "base/win/registry.h" namespace net { @@ -16,8 +16,8 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( // check windows registry for file extension's mime type (registry key // names are not case-sensitive). std::wstring value, key = L"." + ext; - RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue(L"Content Type", - &value); + base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue( + L"Content Type", &value); if (!value.empty()) { *result = WideToUTF8(value); return true; @@ -28,8 +28,8 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( bool PlatformMimeUtil::GetPreferredExtensionForMimeType( const std::string& mime_type, FilePath::StringType* ext) const { std::wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type)); - if (!RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue(L"Extension", - ext)) { + if (!base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue( + L"Extension", ext)) { return false; } // Strip off the leading dot, this should always be the case. diff --git a/net/base/ssl_config_service_win.cc b/net/base/ssl_config_service_win.cc index 82f44bf..14c4d24 100644 --- a/net/base/ssl_config_service_win.cc +++ b/net/base/ssl_config_service_win.cc @@ -4,10 +4,11 @@ #include "net/base/ssl_config_service_win.h" -#include "base/registry.h" +#include "base/win/registry.h" using base::TimeDelta; using base::TimeTicks; +using base::win::RegKey; namespace net { diff --git a/net/proxy/proxy_config_service_win.cc b/net/proxy/proxy_config_service_win.cc index 1cd8a8c..d0a387f 100644 --- a/net/proxy/proxy_config_service_win.cc +++ b/net/proxy/proxy_config_service_win.cc @@ -8,11 +8,11 @@ #include <winhttp.h> #include "base/logging.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/stl_util-inl.h" +#include "base/win/registry.h" #include "net/base/net_errors.h" #include "net/proxy/proxy_config.h" @@ -61,7 +61,7 @@ class ProxyConfigServiceWin::KeyEntry { } private: - RegKey key_; + base::win::RegKey key_; base::ObjectWatcher watcher_; }; diff --git a/sandbox/src/eat_resolver.cc b/sandbox/src/eat_resolver.cc index d4f6e83..f057006 100644 --- a/sandbox/src/eat_resolver.cc +++ b/sandbox/src/eat_resolver.cc @@ -4,7 +4,7 @@ #include "sandbox/src/eat_resolver.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "sandbox/src/sandbox_nt_util.h" namespace sandbox { @@ -64,7 +64,7 @@ NTSTATUS EatResolverThunk::ResolveTarget(const void* module, if (!module) return STATUS_INVALID_PARAMETER; - PEImage pe(module); + base::win::PEImage pe(module); if (!pe.VerifyMagic()) return STATUS_INVALID_IMAGE_FORMAT; diff --git a/sandbox/src/interception.cc b/sandbox/src/interception.cc index 28edf2c..003ebd8 100644 --- a/sandbox/src/interception.cc +++ b/sandbox/src/interception.cc @@ -10,8 +10,8 @@ #include "sandbox/src/interception.h" #include "base/logging.h" -#include "base/pe_image.h" #include "base/scoped_ptr.h" +#include "base/win/pe_image.h" #include "sandbox/src/interception_internal.h" #include "sandbox/src/interceptors.h" #include "sandbox/src/sandbox.h" @@ -411,7 +411,7 @@ bool InterceptionManager::PatchClientFunctions(DllInterceptionData* thunks, if (!ntdll_base) return false; - PEImage ntdll_image(ntdll_base); + base::win::PEImage ntdll_image(ntdll_base); // Bypass purify's interception. wchar_t* loader_get = reinterpret_cast<wchar_t*>( diff --git a/sandbox/src/policy_broker.cc b/sandbox/src/policy_broker.cc index ff67667..0a63750 100644 --- a/sandbox/src/policy_broker.cc +++ b/sandbox/src/policy_broker.cc @@ -7,7 +7,7 @@ #include "sandbox/src/policy_broker.h" #include "base/logging.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "base/win/windows_version.h" #include "sandbox/src/interception.h" #include "sandbox/src/interceptors.h" @@ -41,7 +41,7 @@ SANDBOX_INTERCEPT NtExports g_nt; bool SetupNtdllImports(TargetProcess *child) { HMODULE ntdll = ::GetModuleHandle(kNtdllName); - PEImage ntdll_image(ntdll); + base::win::PEImage ntdll_image(ntdll); // Bypass purify's interception. wchar_t* loader_get = reinterpret_cast<wchar_t*>( diff --git a/sandbox/src/resolver.cc b/sandbox/src/resolver.cc index 7ed02e4..295bfb2 100644 --- a/sandbox/src/resolver.cc +++ b/sandbox/src/resolver.cc @@ -4,7 +4,7 @@ #include "sandbox/src/resolver.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "sandbox/src/sandbox_nt_util.h" namespace sandbox { @@ -47,7 +47,7 @@ NTSTATUS ResolverThunk::ResolveInterceptor(const void* interceptor_module, if (!interceptor_module) return STATUS_INVALID_PARAMETER; - PEImage pe(interceptor_module); + base::win::PEImage pe(interceptor_module); if (!pe.VerifyMagic()) return STATUS_INVALID_IMAGE_FORMAT; diff --git a/sandbox/src/sandbox_nt_util.cc b/sandbox/src/sandbox_nt_util.cc index 89da4e0..20035b3 100644 --- a/sandbox/src/sandbox_nt_util.cc +++ b/sandbox/src/sandbox_nt_util.cc @@ -4,7 +4,7 @@ #include "sandbox/src/sandbox_nt_util.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/target_services.h" @@ -357,7 +357,7 @@ UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32* flags) { __try { do { *flags = 0; - PEImage pe(module); + base::win::PEImage pe(module); if (!pe.VerifyMagic()) break; diff --git a/sandbox/src/service_resolver.cc b/sandbox/src/service_resolver.cc index 728555e..79579a0 100644 --- a/sandbox/src/service_resolver.cc +++ b/sandbox/src/service_resolver.cc @@ -5,7 +5,7 @@ #include "sandbox/src/service_resolver.h" #include "base/logging.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" namespace sandbox { @@ -28,7 +28,7 @@ NTSTATUS ServiceResolverThunk::ResolveTarget(const void* module, if (NULL == module) return STATUS_UNSUCCESSFUL; - PEImage module_image(module); + base::win::PEImage module_image(module); *address = module_image.GetProcAddress(function_name); if (NULL == *address) { diff --git a/sandbox/src/sidestep_resolver.cc b/sandbox/src/sidestep_resolver.cc index 74409a8..0a2803c 100644 --- a/sandbox/src/sidestep_resolver.cc +++ b/sandbox/src/sidestep_resolver.cc @@ -4,7 +4,7 @@ #include "sandbox/src/sidestep_resolver.h" -#include "base/pe_image.h" +#include "base/win/pe_image.h" #include "sandbox/src/sandbox_nt_util.h" #include "sandbox/src/sidestep/preamble_patcher.h" @@ -191,7 +191,7 @@ bool SmartSidestepResolverThunk::IsInternalCall(const void* base, DCHECK_NT(base); DCHECK_NT(return_address); - PEImage pe(base); + base::win::PEImage pe(base); if (pe.GetImageSectionFromAddr(return_address)) return true; return false; diff --git a/sandbox/src/target_process.cc b/sandbox/src/target_process.cc index a9848c5..1341949 100644 --- a/sandbox/src/target_process.cc +++ b/sandbox/src/target_process.cc @@ -5,8 +5,8 @@ #include "sandbox/src/target_process.h" #include "base/basictypes.h" -#include "base/pe_image.h" #include "base/scoped_ptr.h" +#include "base/win/pe_image.h" #include "sandbox/src/crosscall_server.h" #include "sandbox/src/crosscall_client.h" #include "sandbox/src/policy_low_level.h" @@ -54,7 +54,7 @@ void* GetBaseAddress(const wchar_t* exe_name, void* entry_point) { if (NULL == exe) return exe; - PEImage pe(exe); + base::win::PEImage pe(exe); if (!pe.VerifyMagic()) { ::FreeLibrary(exe); return exe; diff --git a/webkit/glue/plugins/plugin_list_win.cc b/webkit/glue/plugins/plugin_list_win.cc index e515e10..4869262 100644 --- a/webkit/glue/plugins/plugin_list_win.cc +++ b/webkit/glue/plugins/plugin_list_win.cc @@ -12,11 +12,11 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/path_service.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" +#include "base/win/registry.h" #include "webkit/glue/plugins/plugin_constants_win.h" #include "webkit/glue/plugins/plugin_lib.h" #include "webkit/glue/webkit_glue.h" @@ -67,7 +67,7 @@ bool GetInstalledPath(const TCHAR* app, FilePath* out) { reg_path.append(L"\\"); reg_path.append(app); - RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); + base::win::RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); std::wstring path; if (key.ReadValue(kRegistryPath, &path)) { *out = FilePath(path); @@ -82,13 +82,13 @@ void GetPluginsInRegistryDirectory( HKEY root_key, const std::wstring& registry_folder, std::set<FilePath>* plugin_dirs) { - for (RegistryKeyIterator iter(root_key, registry_folder.c_str()); + for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str()); iter.Valid(); ++iter) { // Use the registry to gather plugin across the file system. std::wstring reg_path = registry_folder; reg_path.append(L"\\"); reg_path.append(iter.Name()); - RegKey key(root_key, reg_path.c_str(), KEY_READ); + base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ); std::wstring path; if (key.ReadValue(kRegistryPath, &path)) @@ -99,11 +99,12 @@ void GetPluginsInRegistryDirectory( // Enumerate through the registry key to find all installed FireFox paths. // FireFox 3 beta and version 2 can coexist. See bug: 1025003 void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { - RegistryKeyIterator it(HKEY_LOCAL_MACHINE, kRegistryFirefoxInstalled); + base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, + kRegistryFirefoxInstalled); for (; it.Valid(); ++it) { std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + it.Name() + L"\\Main"; - RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); + base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); std::wstring install_dir; if (!key.ReadValue(L"Install Directory", &install_dir)) continue; @@ -180,7 +181,8 @@ void GetWindowsMediaDirectory(std::set<FilePath>* plugin_dirs) { void GetJavaDirectory(std::set<FilePath>* plugin_dirs) { // Load the new NPAPI Java plugin // 1. Open the main JRE key under HKLM - RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, KEY_QUERY_VALUE); + base::win::RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, + KEY_QUERY_VALUE); // 2. Read the current Java version std::wstring java_version; diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc index 867727f..da7a68f 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc @@ -13,12 +13,12 @@ #include "base/lazy_instance.h" #include "base/message_loop.h" #include "base/metrics/stats_counters.h" -#include "base/registry.h" #include "base/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" #include "base/stringprintf.h" +#include "base/win/registry.h" #include "base/win/windows_version.h" #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" @@ -416,7 +416,7 @@ bool WebPluginDelegateImpl::PlatformInitialize() { // for the rest patch this function. if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && base::win::GetVersion() == base::win::VERSION_XP && - !RegKey().Open(HKEY_LOCAL_MACHINE, + !base::win::RegKey().Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe", KEY_READ) && !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) { |