diff options
67 files changed, 409 insertions, 469 deletions
diff --git a/app/animation.cc b/app/animation.cc index 2dc2bcf6..edb1232 100644 --- a/app/animation.cc +++ b/app/animation.cc @@ -8,7 +8,7 @@ #include "gfx/rect.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif Animation::Animation(base::TimeDelta timer_interval) @@ -90,7 +90,7 @@ void Animation::SetContainer(AnimationContainer* container) { // static bool Animation::ShouldRenderRichAnimation() { #if defined(OS_WIN) - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { BOOL result; // Get "Turn off all unnecessary animations" value. if (::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)) { diff --git a/app/animation_unittest.cc b/app/animation_unittest.cc index df0b262b..280e74f 100644 --- a/app/animation_unittest.cc +++ b/app/animation_unittest.cc @@ -5,7 +5,7 @@ #include "app/linear_animation.h" #include "app/test_animation_delegate.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif #include "testing/gtest/include/gtest/gtest.h" @@ -122,7 +122,7 @@ TEST_F(AnimationTest, DeleteFromEnd) { TEST_F(AnimationTest, ShouldRenderRichAnimation) { #if defined(OS_WIN) - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { BOOL result; ASSERT_NE( 0, ::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)); diff --git a/app/l10n_util_unittest.cc b/app/l10n_util_unittest.cc index 85c5296..4a15903 100644 --- a/app/l10n_util_unittest.cc +++ b/app/l10n_util_unittest.cc @@ -22,7 +22,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -239,7 +239,7 @@ TEST_F(L10nUtilTest, GetAppLocale) { EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("en")); // Amharic should be blocked unless OS is Vista or newer. - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { SetICUDefaultLocale("am"); EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("en-GB"); diff --git a/app/l10n_util_win.cc b/app/l10n_util_win.cc index 4d22dd3..2f1f627 100644 --- a/app/l10n_util_win.cc +++ b/app/l10n_util_win.cc @@ -10,9 +10,7 @@ #include "app/l10n_util_win.h" #include "base/i18n/rtl.h" #include "base/string_number_conversions.h" -//#include "base/string_util.h" -#include "base/win_util.h" - +#include "base/win/windows_version.h" #include "grit/app_locale_settings.h" namespace { @@ -86,7 +84,7 @@ bool IsLocaleSupportedByOS(const std::string& locale) { // On Win XP, no Ethiopic/Amahric font is availabel out of box. We hard-coded // 'Abyssinica SIL' in the resource bundle to use in the UI. Check // for its presence to determine whether or not to support Amharic UI on XP. - return (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA || + return (base::win::GetVersion() >= base::win::VERSION_VISTA || !LowerCaseEqualsASCII(locale, "am") || IsFontPresent(L"Abyssinica SIL")); } @@ -102,7 +100,7 @@ bool NeedOverrideDefaultUIFont(std::wstring* override_font_family, // we need separate ui font specifications. int ui_font_family_id = IDS_UI_FONT_FAMILY; int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER; - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { ui_font_family_id = IDS_UI_FONT_FAMILY_XP; ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP; } diff --git a/app/resource_bundle_win.cc b/app/resource_bundle_win.cc index 6676dc6..369ee40 100644 --- a/app/resource_bundle_win.cc +++ b/app/resource_bundle_win.cc @@ -17,14 +17,15 @@ #include "base/resource_util.h" #include "base/stl_util-inl.h" #include "base/string_piece.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" + #include "gfx/font.h" namespace { // Returns the flags that should be passed to LoadLibraryEx. DWORD GetDataDllLoadFlags() { - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) + if (base::win::GetVersion() >= base::win::VERSION_VISTA) return LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | LOAD_LIBRARY_AS_IMAGE_RESOURCE; return DONT_RESOLVE_DLL_REFERENCES; diff --git a/app/win_util.cc b/app/win_util.cc index 657c695f..5232e34 100644 --- a/app/win_util.cc +++ b/app/win_util.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. @@ -24,6 +24,7 @@ #include "base/scoped_handle_win.h" #include "base/string_util.h" #include "base/win_util.h" +#include "base/win/windows_version.h" #include "gfx/codec/png_codec.h" #include "gfx/gdi_util.h" @@ -99,7 +100,7 @@ bool IsDrag(const POINT& origin, const POINT& current) { } bool ShouldUseVistaFrame() { - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) + if (base::win::GetVersion() < base::win::VERSION_VISTA) return false; // If composition is not enabled, we behave like on XP. BOOL f; @@ -545,7 +546,7 @@ gfx::Font GetWindowTitleFont() { void SetAppIdForWindow(const std::wstring& app_id, HWND hwnd) { // This functionality is only available on Win7+. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) return; // Load Shell32.dll into memory. diff --git a/base/base.gypi b/base/base.gypi index 180a1f9..20223bb 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -301,6 +301,8 @@ 'watchdog.h', 'weak_ptr.cc', 'weak_ptr.h', + 'win/windows_version.cc', + 'win/windows_version.h', 'win_util.cc', 'win_util.h', 'windows_message_list.h', @@ -362,19 +364,23 @@ }, ], [ 'OS == "win"', { - 'include_dirs': [ - '<(DEPTH)/third_party/wtl/include', - ], - 'sources!': [ - 'event_recorder_stubs.cc', - 'file_descriptor_shuffle.cc', - 'message_pump_libevent.cc', - # Not using sha1_win.cc because it may have caused a - # regression to page cycler moz. - 'sha1_win.cc', - 'string16.cc', - 'trace_event.cc', - ], + 'include_dirs': [ + '<(DEPTH)/third_party/wtl/include', + ], + 'sources!': [ + 'event_recorder_stubs.cc', + 'file_descriptor_shuffle.cc', + 'message_pump_libevent.cc', + # Not using sha1_win.cc because it may have caused a + # regression to page cycler moz. + 'sha1_win.cc', + 'string16.cc', + 'trace_event.cc', + ], + }, { # OS != "win" + 'sources/': [ + ['exclude', '/win/*'], + ], },], ], }], diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc index 9b5c150..25271e4 100644 --- a/base/base_paths_win.cc +++ b/base/base_paths_win.cc @@ -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. @@ -10,7 +10,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx extern "C" IMAGE_DOS_HEADER __ImageBase; @@ -86,7 +86,7 @@ bool PathProviderWin(int key, FilePath* result) { cur = FilePath(system_buffer); break; case base::DIR_LOCAL_APP_DATA_LOW: - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (win::GetVersion() < win::VERSION_VISTA) { return false; } // TODO(nsylvain): We should use SHGetKnownFolderPath instead. Bug 1281128 diff --git a/base/file_util_win.cc b/base/file_util_win.cc index c601f46..d750749 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -23,6 +23,7 @@ #include "base/time.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" +#include "base/win/windows_version.h" namespace file_util { @@ -261,7 +262,7 @@ bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, if (!PathExists(to_path)) { // Except that Vista fails to do that, and instead do a recursive copy if // the target directory doesn't exist. - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) + if (base::win::GetVersion() >= base::win::VERSION_VISTA) CreateDirectory(to_path); else ShellCopy(from_path, to_path, false); @@ -402,7 +403,7 @@ bool CreateShortcutLink(const wchar_t *source, const wchar_t *destination, if (icon && FAILED(i_shell_link->SetIconLocation(icon, icon_index))) return false; - if (app_id && (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7)) { + if (app_id && (base::win::GetVersion() >= base::win::VERSION_WIN7)) { ScopedComPtr<IPropertyStore> property_store; if (FAILED(property_store.QueryFrom(i_shell_link))) return false; @@ -452,7 +453,7 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination, if (icon && FAILED(i_shell_link->SetIconLocation(icon, icon_index))) return false; - if (app_id && win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) { + if (app_id && base::win::GetVersion() >= base::win::VERSION_WIN7) { ScopedComPtr<IPropertyStore> property_store; if (FAILED(property_store.QueryFrom(i_shell_link))) return false; @@ -467,7 +468,7 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination, bool TaskbarPinShortcutLink(const wchar_t* shortcut) { // "Pin to taskbar" is only supported after Win7. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) return false; int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarpin", shortcut, @@ -477,7 +478,7 @@ bool TaskbarPinShortcutLink(const wchar_t* shortcut) { bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) { // "Unpin from taskbar" is only supported after Win7. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) return false; int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarunpin", @@ -1007,7 +1008,7 @@ bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) { bool PreReadImage(const wchar_t* file_path, size_t size_to_read, size_t step_size) { - if (win_util::GetWinVersion() > win_util::WINVERSION_XP) { + if (base::win::GetVersion() > base::win::VERSION_XP) { // Vista+ branch. On these OSes, the forced reads through the DLL actually // slows warm starts. The solution is to sequentially read file contents // with an optional cap on total amount to read. diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc index cc86be0..4c41aed 100644 --- a/base/path_service_unittest.cc +++ b/base/path_service_unittest.cc @@ -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,7 +8,7 @@ #include "base/file_util.h" #include "base/file_path.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest-spi.h" @@ -50,7 +50,7 @@ TEST_F(PathServiceTest, Get) { #if defined(OS_WIN) for (int key = base::PATH_WIN_START + 1; key < base::PATH_WIN_END; ++key) { if (key == base::DIR_LOCAL_APP_DATA_LOW && - win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + base::win::GetVersion() < base::win::VERSION_VISTA) { // DIR_LOCAL_APP_DATA_LOW is not supported prior Vista and is expected to // fail. EXPECT_TRUE(ReturnsInvalidPath(key)) << key; diff --git a/base/pe_image_unittest.cc b/base/pe_image_unittest.cc index 1621843..6d8875e 100644 --- a/base/pe_image_unittest.cc +++ b/base/pe_image_unittest.cc @@ -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. @@ -6,7 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "base/pe_image.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" // Just counts the number of invocations. bool ExportsCallback(const PEImage &image, @@ -147,7 +147,7 @@ int GetExpectedValue(Value value, DWORD os) { // the actual number of items found is within the expected range. TEST(PEImageTest, EnumeratesPE) { // Windows Server 2003 is not supported as a test environment for this test. - if (win_util::GetWinVersion() == win_util::WINVERSION_SERVER_2003) + if (base::win::GetVersion() == base::win::VERSION_SERVER_2003) return; HMODULE module = LoadLibrary(L"advapi32.dll"); ASSERT_TRUE(NULL != module); diff --git a/base/platform_thread_win.cc b/base/platform_thread_win.cc index 2dd325e..a4a1b52 100644 --- a/base/platform_thread_win.cc +++ b/base/platform_thread_win.cc @@ -1,11 +1,11 @@ -// 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 "base/platform_thread.h" #include "base/logging.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" namespace { @@ -68,7 +68,7 @@ void PlatformThread::SetName(const char* name) { bool PlatformThread::Create(size_t stack_size, Delegate* delegate, PlatformThreadHandle* thread_handle) { unsigned int flags = 0; - if (stack_size > 0 && win_util::GetWinVersion() >= win_util::WINVERSION_XP) { + if (stack_size > 0 && base::win::GetVersion() >= base::win::VERSION_XP) { flags = STACK_SIZE_PARAM_IS_A_RESERVATION; } else { stack_size = 0; diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 4b701e9..7a835d7 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -18,7 +18,7 @@ #include "base/metrics/histogram.h" #include "base/scoped_handle_win.h" #include "base/scoped_ptr.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" // userenv.dll is required for CreateEnvironmentBlock(). #pragma comment(lib, "userenv.lib") @@ -155,7 +155,7 @@ bool GetProcessIntegrityLevel(ProcessHandle process, IntegrityLevel *level) { if (!level) return false; - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) + if (base::win::GetVersion() < base::win::VERSION_VISTA) return false; HANDLE process_token; diff --git a/base/trace_event_win_unittest.cc b/base/trace_event_win_unittest.cc index 7222d95..a142af1 100644 --- a/base/trace_event_win_unittest.cc +++ b/base/trace_event_win_unittest.cc @@ -1,13 +1,16 @@ // 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 "base/trace_event.h" + #include <strstream> + #include "base/basictypes.h" #include "base/file_util.h" #include "base/event_trace_consumer_win.h" #include "base/event_trace_controller_win.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include <initguid.h> // NOLINT - must be last include. @@ -74,7 +77,7 @@ TestEventConsumer* TestEventConsumer::current_ = NULL; class TraceEventTest: public testing::Test { public: void SetUp() { - bool is_xp = win_util::GetWinVersion() < win_util::WINVERSION_VISTA; + bool is_xp = base::win::GetVersion() < base::win::VERSION_VISTA; // Resurrect and initialize the TraceLog singleton instance. // On Vista and better, we need the provider registered before we diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc new file mode 100644 index 0000000..a80688c --- /dev/null +++ b/base/win/windows_version.cc @@ -0,0 +1,72 @@ +// 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 "base/win/windows_version.h" + +#include <windows.h> + +#include "base/logging.h" + +namespace base { +namespace win { + +Version GetVersion() { + static bool checked_version = false; + static Version win_version = VERSION_PRE_2000; + if (!checked_version) { + OSVERSIONINFOEX version_info; + version_info.dwOSVersionInfoSize = sizeof version_info; + GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); + if (version_info.dwMajorVersion == 5) { + switch (version_info.dwMinorVersion) { + case 0: + win_version = VERSION_2000; + break; + case 1: + win_version = VERSION_XP; + break; + case 2: + default: + win_version = VERSION_SERVER_2003; + break; + } + } else if (version_info.dwMajorVersion == 6) { + if (version_info.wProductType != VER_NT_WORKSTATION) { + // 2008 is 6.0, and 2008 R2 is 6.1. + win_version = VERSION_2008; + } else { + if (version_info.dwMinorVersion == 0) { + win_version = VERSION_VISTA; + } else { + win_version = VERSION_WIN7; + } + } + } else if (version_info.dwMajorVersion > 6) { + win_version = VERSION_WIN7; + } + checked_version = true; + } + return win_version; +} + +void GetServicePackLevel(int* major, int* minor) { + DCHECK(major && minor); + static bool checked_version = false; + static int service_pack_major = -1; + static int service_pack_minor = -1; + if (!checked_version) { + OSVERSIONINFOEX version_info = {0}; + version_info.dwOSVersionInfoSize = sizeof(version_info); + GetVersionEx(reinterpret_cast<OSVERSIONINFOW*>(&version_info)); + service_pack_major = version_info.wServicePackMajor; + service_pack_minor = version_info.wServicePackMinor; + checked_version = true; + } + + *major = service_pack_major; + *minor = service_pack_minor; +} + +} // namespace win +} // namespace base diff --git a/base/win/windows_version.h b/base/win/windows_version.h new file mode 100644 index 0000000..7e281a6 --- /dev/null +++ b/base/win/windows_version.h @@ -0,0 +1,34 @@ +// 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_WINDOWS_VERSION_H_ +#define BASE_WIN_WINDOWS_VERSION_H_ +#pragma once + +namespace base { +namespace win { + +// NOTE: Keep these in order so callers can do things like +// "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, +// though. +enum Version { + VERSION_PRE_2000 = 0, // Not supported + VERSION_2000 = 1, // Not supported + VERSION_XP = 2, + VERSION_SERVER_2003 = 3, + VERSION_VISTA = 4, + VERSION_2008 = 5, + VERSION_WIN7 = 6, +}; + +// Returns the running version of Windows. +Version GetVersion(); + +// Returns the major and minor version of the service pack installed. +void GetServicePackLevel(int* major, int* minor); + +} // namespace win +} // namespace base + +#endif // BASE_WIN_WINDOWS_VERSION_H_ diff --git a/base/win_util.cc b/base/win_util.cc index b87e441..70d2829 100644 --- a/base/win_util.cc +++ b/base/win_util.cc @@ -5,6 +5,8 @@ #include "base/win_util.h" #include <aclapi.h> +#include <shobjidl.h> // Must be before propkey. +#include <propkey.h> #include <propvarutil.h> #include <sddl.h> #include <shlobj.h> @@ -15,6 +17,7 @@ #include "base/scoped_ptr.h" #include "base/string_util.h" #include "base/stringprintf.h" +#include "base/win/windows_version.h" namespace win_util { @@ -24,15 +27,11 @@ namespace win_util { #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) -const PROPERTYKEY kPKEYAppUserModelID = - { { 0x9F4C2855, 0x9F79, 0x4B39, - { 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, } }, 5 }; - void GetNonClientMetrics(NONCLIENTMETRICS* metrics) { DCHECK(metrics); static const UINT SIZEOF_NONCLIENTMETRICS = - (GetWinVersion() >= WINVERSION_VISTA) ? + (base::win::GetVersion() >= base::win::VERSION_VISTA) ? sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; metrics->cbSize = SIZEOF_NONCLIENTMETRICS; const bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, @@ -41,134 +40,6 @@ void GetNonClientMetrics(NONCLIENTMETRICS* metrics) { DCHECK(success); } -WinVersion GetWinVersion() { - static bool checked_version = false; - static WinVersion win_version = WINVERSION_PRE_2000; - if (!checked_version) { - OSVERSIONINFOEX version_info; - version_info.dwOSVersionInfoSize = sizeof version_info; - GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); - if (version_info.dwMajorVersion == 5) { - switch (version_info.dwMinorVersion) { - case 0: - win_version = WINVERSION_2000; - break; - case 1: - win_version = WINVERSION_XP; - break; - case 2: - default: - win_version = WINVERSION_SERVER_2003; - break; - } - } else if (version_info.dwMajorVersion == 6) { - if (version_info.wProductType != VER_NT_WORKSTATION) { - // 2008 is 6.0, and 2008 R2 is 6.1. - win_version = WINVERSION_2008; - } else { - if (version_info.dwMinorVersion == 0) { - win_version = WINVERSION_VISTA; - } else { - win_version = WINVERSION_WIN7; - } - } - } else if (version_info.dwMajorVersion > 6) { - win_version = WINVERSION_WIN7; - } - checked_version = true; - } - return win_version; -} - -void GetServicePackLevel(int* major, int* minor) { - DCHECK(major && minor); - static bool checked_version = false; - static int service_pack_major = -1; - static int service_pack_minor = -1; - if (!checked_version) { - OSVERSIONINFOEX version_info = {0}; - version_info.dwOSVersionInfoSize = sizeof(version_info); - GetVersionEx(reinterpret_cast<OSVERSIONINFOW*>(&version_info)); - service_pack_major = version_info.wServicePackMajor; - service_pack_minor = version_info.wServicePackMinor; - checked_version = true; - } - - *major = service_pack_major; - *minor = service_pack_minor; -} - -bool AddAccessToKernelObject(HANDLE handle, WELL_KNOWN_SID_TYPE known_sid, - ACCESS_MASK access) { - PSECURITY_DESCRIPTOR descriptor = NULL; - PACL old_dacl = NULL; - PACL new_dacl = NULL; - - if (ERROR_SUCCESS != GetSecurityInfo(handle, SE_KERNEL_OBJECT, - DACL_SECURITY_INFORMATION, NULL, NULL, &old_dacl, NULL, - &descriptor)) - return false; - - BYTE sid[SECURITY_MAX_SID_SIZE] = {0}; - DWORD size_sid = SECURITY_MAX_SID_SIZE; - - if (known_sid == WinSelfSid) { - // We hijack WinSelfSid when we want to add the current user instead of - // a known sid. - HANDLE token = NULL; - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)) { - LocalFree(descriptor); - return false; - } - - DWORD size = sizeof(TOKEN_USER) + size_sid; - scoped_array<BYTE> token_user_bytes(new BYTE[size]); - TOKEN_USER* token_user = - reinterpret_cast<TOKEN_USER*>(token_user_bytes.get()); - BOOL ret = GetTokenInformation(token, TokenUser, token_user, size, &size); - - CloseHandle(token); - - if (!ret) { - LocalFree(descriptor); - return false; - } - memcpy(sid, token_user->User.Sid, size_sid); - } else { - if (!CreateWellKnownSid(known_sid , NULL, sid, &size_sid)) { - LocalFree(descriptor); - return false; - } - } - - EXPLICIT_ACCESS new_access = {0}; - new_access.grfAccessMode = GRANT_ACCESS; - new_access.grfAccessPermissions = access; - new_access.grfInheritance = NO_INHERITANCE; - - new_access.Trustee.pMultipleTrustee = NULL; - new_access.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; - new_access.Trustee.TrusteeForm = TRUSTEE_IS_SID; - new_access.Trustee.ptstrName = reinterpret_cast<LPWSTR>(&sid); - - if (ERROR_SUCCESS != SetEntriesInAcl(1, &new_access, old_dacl, &new_dacl)) { - LocalFree(descriptor); - return false; - } - - DWORD result = SetSecurityInfo(handle, SE_KERNEL_OBJECT, - DACL_SECURITY_INFORMATION, NULL, NULL, - new_dacl, NULL); - - LocalFree(new_dacl); - LocalFree(descriptor); - - if (ERROR_SUCCESS != result) - return false; - - return true; -} - bool GetUserSidString(std::wstring* user_sid) { // Get the current token. HANDLE token = NULL; @@ -198,62 +69,6 @@ bool GetUserSidString(std::wstring* user_sid) { return true; } -bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor) { - // Get the current token. - HANDLE token = NULL; - if (!OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) - return false; - ScopedHandle token_scoped(token); - - // Get the size of the TokenGroups structure. - DWORD size = 0; - BOOL result = GetTokenInformation(token, TokenGroups, NULL, 0, &size); - if (result != FALSE && GetLastError() != ERROR_INSUFFICIENT_BUFFER) - return false; - - // Get the data. - scoped_array<char> token_groups_chars(new char[size]); - TOKEN_GROUPS* token_groups = - reinterpret_cast<TOKEN_GROUPS*>(token_groups_chars.get()); - - if (!GetTokenInformation(token, TokenGroups, token_groups, size, &size)) - return false; - - // Look for the logon sid. - SID* logon_sid = NULL; - for (unsigned int i = 0; i < token_groups->GroupCount ; ++i) { - if ((token_groups->Groups[i].Attributes & SE_GROUP_LOGON_ID) != 0) { - logon_sid = static_cast<SID*>(token_groups->Groups[i].Sid); - break; - } - } - - if (!logon_sid) - return false; - - // Convert the data to a string. - wchar_t* sid_string; - if (!ConvertSidToStringSid(logon_sid, &sid_string)) - return false; - - static const wchar_t dacl_format[] = L"D:(A;OICI;GA;;;%ls)"; - wchar_t dacl[SECURITY_MAX_SID_SIZE + arraysize(dacl_format) + 1] = {0}; - wsprintf(dacl, dacl_format, sid_string); - - LocalFree(sid_string); - - // Convert the string to a security descriptor - if (!ConvertStringSecurityDescriptorToSecurityDescriptor( - dacl, - SDDL_REVISION_1, - reinterpret_cast<PSECURITY_DESCRIPTOR*>(security_descriptor), - NULL)) { - return false; - } - - return true; -} - #pragma warning(push) #pragma warning(disable:4312 4244) WNDPROC SetWindowProc(HWND hwnd, WNDPROC proc) { @@ -276,46 +91,6 @@ void* GetWindowUserData(HWND hwnd) { return reinterpret_cast<void*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); } -// Maps to the WNDPROC for a window that was active before the subclass was -// installed. -static const wchar_t* const kHandlerKey = L"__ORIGINAL_MESSAGE_HANDLER__"; - -bool IsSubclassed(HWND window, WNDPROC subclass_proc) { - WNDPROC original_handler = - reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC)); - return original_handler == subclass_proc; -} - -bool Subclass(HWND window, WNDPROC subclass_proc) { - WNDPROC original_handler = - reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC)); - if (original_handler != subclass_proc) { - win_util::SetWindowProc(window, subclass_proc); - SetProp(window, kHandlerKey, original_handler); - return true; - } - return false; -} - -bool Unsubclass(HWND window, WNDPROC subclass_proc) { - WNDPROC current_handler = - reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC)); - if (current_handler == subclass_proc) { - HANDLE original_handler = GetProp(window, kHandlerKey); - if (original_handler) { - RemoveProp(window, kHandlerKey); - win_util::SetWindowProc(window, - reinterpret_cast<WNDPROC>(original_handler)); - return true; - } - } - return false; -} - -WNDPROC GetSuperclassWNDPROC(HWND window) { - return reinterpret_cast<WNDPROC>(GetProp(window, kHandlerKey)); -} - #pragma warning(pop) bool IsShiftPressed() { @@ -398,7 +173,7 @@ bool SetAppIdForPropertyStore(IPropertyStore* property_store, if (FAILED(InitPropVariantFromString(app_id, &property_value))) return false; - HRESULT result = property_store->SetValue(kPKEYAppUserModelID, + HRESULT result = property_store->SetValue(PKEY_AppUserModel_ID, property_value); if (S_OK == result) result = property_store->Commit(); diff --git a/base/win_util.h b/base/win_util.h index 01372bd..18400f2 100644 --- a/base/win_util.h +++ b/base/win_util.h @@ -16,11 +16,22 @@ struct IPropertyStore; struct _tagpropertykey; typedef _tagpropertykey PROPERTYKEY; +// TODO(brettw) remove this once RLZ is updated to use the new version in +// base/win/windows_version.h. +#if defined(RLZ_WIN_LIB_LIB_MUTEX_H_) || defined(RLZ_WIN_LIB_USER_KEY_H_) \ + || defined(RLZ_WIN_LIB_PROCESS_INFO_H_) +#include "base/win/windows_version.h" +#endif + namespace win_util { -// NOTE: Keep these in order so callers can do things like -// "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, -// though. +void GetNonClientMetrics(NONCLIENTMETRICS* metrics); + +// TODO(brettw) remove this once RLZ is updated to use the new version in +// base/win/windows_version.h. +#if defined(RLZ_WIN_LIB_LIB_MUTEX_H_) || defined(RLZ_WIN_LIB_USER_KEY_H_) \ + || defined(RLZ_WIN_LIB_PROCESS_INFO_H_) +// These must match the values in base::win! enum WinVersion { WINVERSION_PRE_2000 = 0, // Not supported WINVERSION_2000 = 1, // Not supported @@ -30,58 +41,17 @@ enum WinVersion { WINVERSION_2008 = 5, WINVERSION_WIN7 = 6, }; - -// Property key for System.AppUserModel.ID. -// <http://msdn.microsoft.com/en-us/library/dd391569(VS.85).aspx> -// TODO(xiyuan): Remove this once we compile with Win7 SDK. -extern const PROPERTYKEY kPKEYAppUserModelID; - -void GetNonClientMetrics(NONCLIENTMETRICS* metrics); - -// Returns the running version of Windows. -WinVersion GetWinVersion(); - -// Returns the major and minor version of the service pack installed. -void GetServicePackLevel(int* major, int* minor); - -// Adds an ACE in the DACL of the object referenced by handle. The ACE is -// granting |access| to the user |known_sid|. -// If |known_sid| is WinSelfSid, the sid of the current user will be added to -// the DACL. -bool AddAccessToKernelObject(HANDLE handle, WELL_KNOWN_SID_TYPE known_sid, - ACCESS_MASK access); +inline WinVersion GetWinVersion() { + return static_cast<WinVersion>(base::win::GetVersion()); +} +#endif // RLZ_* // Returns the string representing the current user sid. bool GetUserSidString(std::wstring* user_sid); -// Creates a security descriptor with a DACL that has one ace giving full -// access to the current logon session. -// The security descriptor returned must be freed using LocalFree. -// The function returns true if it succeeds, false otherwise. -bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor); - // Useful for subclassing a HWND. Returns the previous window procedure. WNDPROC SetWindowProc(HWND hwnd, WNDPROC wndproc); -// Returns true if the existing window procedure is the same as |subclass_proc|. -bool IsSubclassed(HWND window, WNDPROC subclass_proc); - -// Subclasses a window, replacing its existing window procedure with the -// specified one. Returns true if the current window procedure was replaced, -// false if the window has already been subclassed with the specified -// subclass procedure. -bool Subclass(HWND window, WNDPROC subclass_proc); - -// Unsubclasses a window subclassed using Subclass. Returns true if -// the window was subclassed with the specified |subclass_proc| and the window -// was successfully unsubclassed, false if the window's window procedure is not -// |subclass_proc|. -bool Unsubclass(HWND window, WNDPROC subclass_proc); - -// Retrieves the original WNDPROC of a window subclassed using -// SubclassWindow. -WNDPROC GetSuperclassWNDPROC(HWND window); - // Pointer-friendly wrappers around Get/SetWindowLong(..., GWLP_USERDATA, ...) // Returns the previously set value. void* SetWindowUserData(HWND hwnd, void* user_data); diff --git a/base/win_util_unittest.cc b/base/win_util_unittest.cc index 0ff1eca..673bc84 100644 --- a/base/win_util_unittest.cc +++ b/base/win_util_unittest.cc @@ -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. @@ -7,12 +7,13 @@ #include "base/basictypes.h" #include "base/string_util.h" #include "base/win_util.h" +#include "base/win/windows_version.h" #include "testing/gtest/include/gtest/gtest.h" // The test is somewhat silly, because the Vista bots some have UAC enabled // and some have it disabled. At least we check that it does not crash. TEST(BaseWinUtilTest, TestIsUACEnabled) { - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { win_util::UserAccountControlIsEnabled(); } else { EXPECT_TRUE(win_util::UserAccountControlIsEnabled()); diff --git a/chrome/app/chrome_exe_main.cc b/chrome/app/chrome_exe_main.cc index ed4c263..296431c 100644 --- a/chrome/app/chrome_exe_main.cc +++ b/chrome/app/chrome_exe_main.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 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. @@ -7,7 +7,7 @@ #include "base/at_exit.h" #include "base/command_line.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/app/breakpad_win.h" #include "chrome/app/client_util.h" #include "chrome/common/result_codes.h" @@ -37,7 +37,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { if (!sandbox_info.broker_services) sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices(); - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { // Enforces strong DEP support. Vista uses the NXCOMPAT flag in the exe. sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED); } diff --git a/chrome/browser/aeropeek_manager.cc b/chrome/browser/aeropeek_manager.cc index 52fb7b7..a63d2b9 100644 --- a/chrome/browser/aeropeek_manager.cc +++ b/chrome/browser/aeropeek_manager.cc @@ -13,7 +13,7 @@ #include "base/scoped_handle_win.h" #include "base/scoped_native_library.h" #include "base/waitable_event.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/app_icon_win.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" @@ -1029,7 +1029,7 @@ bool AeroPeekManager::Enabled() { // TODO(hbono): Bug 37957 <http://crbug.com/37957>: find solutions that avoid // flooding users with tab thumbnails. const CommandLine* command_line = CommandLine::ForCurrentProcess(); - return win_util::GetWinVersion() >= win_util::WINVERSION_WIN7 && + return base::win::GetVersion() >= base::win::VERSION_WIN7 && win_util::ShouldUseVistaFrame() && !command_line->HasSwitch(switches::kApp) && command_line->HasSwitch(switches::kEnableAeroPeekTabs); diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index 8911307..ef1dc17 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -19,7 +19,7 @@ #include "base/path_service.h" #include "base/scoped_ptr.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/metrics/metrics_service.h" @@ -49,7 +49,7 @@ void RecordBreakpadStatusUMA(MetricsService* metrics) { } void WarnAboutMinimumSystemRequirements() { - if (win_util::GetWinVersion() < win_util::WINVERSION_XP) { + if (base::win::GetVersion() < base::win::VERSION_XP) { // Display a warning message if the user is running chrome on Windows 2000. const std::wstring text = l10n_util::GetString(IDS_UNSUPPORTED_OS_PRE_WIN_XP); @@ -148,10 +148,10 @@ void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) { int HandleIconsCommands(const CommandLine &parsed_command_line) { if (parsed_command_line.HasSwitch(switches::kHideIcons)) { std::wstring cp_applet; - win_util::WinVersion version = win_util::GetWinVersion(); - if (version >= win_util::WINVERSION_VISTA) { + base::win::Version version = base::win::GetVersion(); + if (version >= base::win::VERSION_VISTA) { cp_applet.assign(L"Programs and Features"); // Windows Vista and later. - } else if (version >= win_util::WINVERSION_XP) { + } else if (version >= base::win::VERSION_XP) { cp_applet.assign(L"Add/Remove Programs"); // Windows XP. } else { return ResultCodes::UNSUPPORTED_PARAM; // Not supported diff --git a/chrome/browser/bug_report_util.h b/chrome/browser/bug_report_util.h index c01acc04..7d5af5d 100644 --- a/chrome/browser/bug_report_util.h +++ b/chrome/browser/bug_report_util.h @@ -12,6 +12,8 @@ #if defined(OS_MACOSX) #include "base/mac_util.h" #include "base/sys_info.h" +#elif defined(OS_WIN) +#include "base/win/windows_version.h" #endif #include "chrome/browser/userfeedback/proto/common.pb.h" #include "chrome/browser/userfeedback/proto/extension.pb.h" @@ -54,7 +56,7 @@ class BugReportUtil { // SetOSVersion copies the maj.minor.build + servicePack_string // into a string. We currently have: - // win_util::GetWinVersion returns WinVersion, which is just + // base::win::GetVersion returns WinVersion, which is just // an enum of 2000, XP, 2003, or VISTA. Not enough detail for // bug reports. // base::SysInfo::OperatingSystemVersion returns an std::string diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc index 52f2ff0..bda422b 100644 --- a/chrome/browser/diagnostics/recon_diagnostics.cc +++ b/chrome/browser/diagnostics/recon_diagnostics.cc @@ -20,7 +20,7 @@ #include "chrome/common/json_value_serializer.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/installer/util/install_util.h" #endif @@ -49,13 +49,13 @@ class OperatingSystemTest : public DiagnosticTest { int major = 0; int minor = 0; #if defined(OS_WIN) - version = win_util::GetWinVersion(); - if (version < win_util::WINVERSION_XP) { + version = base::win::GetVersion(); + if (version < base::win::VERSION_XP) { RecordFailure(ASCIIToUTF16("Windows 2000 or earlier")); return false; } - win_util::GetServicePackLevel(&major, &minor); - if ((version == win_util::WINVERSION_XP) && (major < 2)) { + base::win::GetServicePackLevel(&major, &minor); + if ((version == base::win::VERSION_XP) && (major < 2)) { RecordFailure(ASCIIToUTF16("XP Service Pack 1 or earlier")); return false; } diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc index a683faa..e415699 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.cc +++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc @@ -15,7 +15,7 @@ #include "base/thread.h" #include "base/values.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif #include "chrome/browser/appcache/view_appcache_internals_job_factory.h" #include "chrome/browser/browser_process.h" @@ -305,7 +305,7 @@ void ChromeURLDataManager::DataSource::SetFontAndTextDirection( #if defined(OS_WIN) // Some fonts used for some languages changed a lot in terms of the font // metric in Vista. So, we need to use different size before Vista. - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) + if (base::win::GetVersion() < base::win::VERSION_VISTA) web_font_size_id = IDS_WEB_FONT_SIZE_XP; #endif localized_strings->SetString("fontsize", diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 4269fc9..4360909 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -23,6 +23,7 @@ #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" @@ -598,7 +599,7 @@ void UpdateAppIconDownloadProgress(int download_count, float progress) { #if defined(OS_WIN) // Taskbar progress bar is only supported on Win7. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) return; ScopedComPtr<ITaskbarList3> taskbar; diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index 03ffd56..df3f46d 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -24,7 +24,7 @@ #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/extension_updater.h" #include "chrome/browser/importer/importer.h" @@ -439,7 +439,7 @@ bool DecodeImportParams(const std::string& encoded, int* browser_type, void FirstRun::PlatformSetup() { FirstRun::CreateChromeDesktopShortcut(); // Windows 7 has deprecated the quick launch bar. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) CreateChromeQuickLaunchShortcut(); } diff --git a/chrome/browser/geolocation/wifi_data_provider_win.cc b/chrome/browser/geolocation/wifi_data_provider_win.cc index cfc2636..2dfb06b 100644 --- a/chrome/browser/geolocation/wifi_data_provider_win.cc +++ b/chrome/browser/geolocation/wifi_data_provider_win.cc @@ -26,8 +26,9 @@ #include <windows.h> #include <winioctl.h> #include <wlanapi.h> + #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/geolocation/wifi_data_provider_common.h" #include "chrome/browser/geolocation/wifi_data_provider_common_win.h" @@ -194,7 +195,7 @@ WindowsWlanApi::~WindowsWlanApi() { } WindowsWlanApi* WindowsWlanApi::Create() { - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) + if (base::win::GetVersion() < base::win::VERSION_VISTA) return NULL; // We use an absolute path to load the DLL to avoid DLL preloading attacks. string16 system_directory; diff --git a/chrome/browser/google/google_update.cc b/chrome/browser/google/google_update.cc index 8aed252..cb68832 100644 --- a/chrome/browser/google/google_update.cc +++ b/chrome/browser/google/google_update.cc @@ -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. @@ -13,7 +13,7 @@ #include "base/string_util.h" #include "base/task.h" #include "base/thread.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" @@ -63,7 +63,7 @@ HRESULT CoCreateInstanceAsAdmin(REFCLSID class_id, REFIID interface_id, // For Vista we need to instantiate the COM server via the elevation // moniker. This ensures that the UAC dialog shows up. - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { wchar_t class_id_as_string[MAX_PATH] = {0}; StringFromGUID2(class_id, class_id_as_string, arraysize(class_id_as_string)); diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index ef93a52..2d6d319 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -26,7 +26,7 @@ #include "base/time.h" #include "base/values.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/importer/importer_bridge.h" #include "chrome/browser/importer/importer_data_types.h" @@ -463,7 +463,7 @@ bool IEImporter::GetFavoritesInfo(IEImporter::FavoritesInfo *info) { // is not recording in Vista's registry. So in Vista, we assume the Links // folder is under Favorites folder since it looks like there is not name // different in every language version of Windows Vista. - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { // The Link folder name is stored in the registry. DWORD buffer_length = sizeof(buffer); RegKey reg_key(HKEY_CURRENT_USER, diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index 12e2d2c..3614b9c 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -21,7 +21,7 @@ #include "base/string_util.h" #include "base/thread.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/favicon_service.h" #include "chrome/browser/history/history.h" @@ -390,7 +390,7 @@ bool UpdateJumpList(const wchar_t* app_id, // JumpList is implemented only on Windows 7 or later. // So, we should return now when this function is called on earlier versions // of Windows. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) return true; // Create an ICustomDestinationList object and attach it to our application. @@ -579,7 +579,7 @@ JumpList::~JumpList() { // static bool JumpList::Enabled() { - return (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7 && + return (base::win::GetVersion() >= base::win::VERSION_WIN7 && !CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableCustomJumpList)); } @@ -590,7 +590,7 @@ bool JumpList::AddObserver(Profile* profile) { // When we add this object to the observer list, we save the pointer to this // TabRestoreService object. This pointer is used when we remove this object // from the observer list. - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7 || !profile) + if (base::win::GetVersion() < base::win::VERSION_WIN7 || !profile) return false; TabRestoreService* tab_restore_service = profile->GetTabRestoreService(); diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 9b1c7d3..98e6729 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -5,9 +5,9 @@ #include "chrome/browser/shell_integration.h" #include <windows.h> -#include <propvarutil.h> -#include <shlobj.h> #include <shobjidl.h> +#include <propkey.h> +#include <propvarutil.h> #include "base/command_line.h" #include "base/file_util.h" @@ -19,6 +19,7 @@ #include "base/task.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/chrome_constants.h" @@ -249,7 +250,7 @@ bool MigrateChromiumShortcutsTask::GetShortcutAppId( PROPVARIANT appid_value; PropVariantInit(&appid_value); - if (FAILED(property_store->GetValue(win_util::kPKEYAppUserModelID, + if (FAILED(property_store->GetValue(PKEY_AppUserModel_ID, &appid_value))) return false; @@ -300,7 +301,7 @@ ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { // to show up in Add/Remove programs for us. const std::wstring kChromeProtocols[] = {L"http", L"https"}; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { IApplicationAssociationRegistration* pAAR; HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), @@ -368,7 +369,7 @@ ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { // is false. bool ShellIntegration::IsFirefoxDefaultBrowser() { bool ff_default = false; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { std::wstring app_cmd; RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && @@ -407,7 +408,7 @@ std::wstring ShellIntegration::GetChromiumAppId(const FilePath& profile_path) { } void ShellIntegration::MigrateChromiumShortcuts() { - if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + if (base::win::GetVersion() < base::win::VERSION_WIN7) return; BrowserThread::PostTask( diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 160cbf4..c7ce959 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -14,6 +14,7 @@ #include "base/i18n/rtl.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/metrics/user_metrics.h" @@ -524,12 +525,12 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add, // work as before - enabling UAC or installing the latest service pack // for Vista is another option. int service_pack_major = 0, service_pack_minor = 0; - win_util::GetServicePackLevel(&service_pack_major, &service_pack_minor); + base::win::GetServicePackLevel(&service_pack_major, &service_pack_minor); if (win_util::UserAccountControlIsEnabled() || - win_util::GetWinVersion() == win_util::WINVERSION_XP || - (win_util::GetWinVersion() == win_util::WINVERSION_VISTA && + base::win::GetVersion() == base::win::VERSION_XP || + (base::win::GetVersion() == base::win::VERSION_VISTA && service_pack_major >= 1) || - win_util::GetWinVersion() > win_util::WINVERSION_VISTA) { + base::win::GetVersion() > base::win::VERSION_VISTA) { UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR); // CheckForUpdate(false, ...) means don't upgrade yet. google_updater_->CheckForUpdate(false, window()); diff --git a/chrome/browser/views/create_application_shortcut_view.cc b/chrome/browser/views/create_application_shortcut_view.cc index 3308315..77e2ea6 100644 --- a/chrome/browser/views/create_application_shortcut_view.cc +++ b/chrome/browser/views/create_application_shortcut_view.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. @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/callback.h" #include "base/utf_string_conversions.h" +#include "base/win/windows_version.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -264,7 +265,7 @@ void CreateApplicationShortcutView::Init() { profile->GetPrefs()->GetBoolean(prefs::kWebAppCreateInAppsMenu)); quick_launch_check_box_ = AddCheckbox( - (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) ? + (base::win::GetVersion() >= base::win::VERSION_WIN7) ? l10n_util::GetString(IDS_PIN_TO_TASKBAR_CHKBOX) : l10n_util::GetString(IDS_CREATE_SHORTCUTS_QUICK_LAUNCH_BAR_CHKBOX), profile->GetPrefs()->GetBoolean(prefs::kWebAppCreateInQuickLaunchBar)); diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc index 1a4d04a..e8ec6e8 100644 --- a/chrome/browser/views/shell_dialogs_win.cc +++ b/chrome/browser/views/shell_dialogs_win.cc @@ -19,7 +19,7 @@ #include "base/string_split.h" #include "base/thread.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "gfx/font.h" #include "grit/app_strings.h" @@ -277,7 +277,7 @@ bool SaveFileAsWithFilter(HWND owner, save_as.lpstrDefExt = &def_ext[0]; save_as.lCustData = NULL; - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { // The save as on Windows XP remembers its last position, // and if the screen resolution changed, it will be off screen. save_as.Flags |= OFN_ENABLEHOOK; diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index 7923771..fc385a6 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -21,6 +21,7 @@ #include "base/thread.h" #include "base/scoped_ptr.h" #include "base/utf_string_conversions.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/download/download_util.h" #include "chrome/browser/profile.h" @@ -293,9 +294,9 @@ bool CreateShortcutTask::CreateShortcut() { shortcut_info_.create_in_quick_launch_bar, // For Win7, create_in_quick_launch_bar means pinning to taskbar. Use // base::PATH_START as a flag for this case. - (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) ? + (base::win::GetVersion() >= base::win::VERSION_WIN7) ? base::PATH_START : base::DIR_APP_DATA, - (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) ? + (base::win::GetVersion() >= base::win::VERSION_WIN7) ? NULL : L"Microsoft\\Internet Explorer\\Quick Launch" } }; @@ -323,7 +324,7 @@ bool CreateShortcutTask::CreateShortcut() { bool pin_to_taskbar = shortcut_info_.create_in_quick_launch_bar && - (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7); + (base::win::GetVersion() >= base::win::VERSION_WIN7); // For Win7's pinning support, any shortcut could be used. So we only create // the shortcut file when there is no shortcut file will be created. That is, @@ -577,7 +578,7 @@ void UpdateShortcutWorker::CheckExistingShortcuts() { shortcut_info_.create_in_quick_launch_bar, // For Win7, create_in_quick_launch_bar means pinning to taskbar. base::DIR_APP_DATA, - (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) ? + (base::win::GetVersion() >= base::win::VERSION_WIN7) ? L"Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar" : L"Microsoft\\Internet Explorer\\Quick Launch" } diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc index 894778e..a5667af 100644 --- a/chrome/common/sandbox_policy.cc +++ b/chrome/common/sandbox_policy.cc @@ -17,7 +17,7 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/trace_event.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/child_process_info.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -228,7 +228,7 @@ bool ApplyPolicyForUntrustedPlugin(sandbox::TargetPolicy* policy) { policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; - if (win_util::GetWinVersion() > win_util::WINVERSION_XP) { + if (base::win::GetVersion() > base::win::VERSION_XP) { // On 2003/Vista the initial token has to be restricted if the main token // is restricted. initial_token = sandbox::USER_RESTRICTED_SAME_ACCESS; @@ -279,7 +279,7 @@ bool ApplyPolicyForUntrustedPlugin(sandbox::TargetPolicy* policy) { policy)) return false; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { if (!AddKeyAndSubkeys(L"HKEY_CURRENT_USER\\SOFTWARE\\AppDataLow", sandbox::TargetPolicy::REG_ALLOW_ANY, policy)) @@ -343,7 +343,7 @@ bool ApplyPolicyForBuiltInFlashPlugin(sandbox::TargetPolicy* policy) { sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; - if (win_util::GetWinVersion() > win_util::WINVERSION_XP) + if (base::win::GetVersion() > base::win::VERSION_XP) initial_token = sandbox::USER_RESTRICTED_SAME_ACCESS; policy->SetTokenLevel(initial_token, sandbox::USER_LIMITED); @@ -417,7 +417,7 @@ void AddPolicyForRenderer(sandbox::TargetPolicy* policy, policy->SetJobLevel(sandbox::JOB_LOCKDOWN, 0); sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; - if (win_util::GetWinVersion() > win_util::WINVERSION_XP) { + if (base::win::GetVersion() > base::win::VERSION_XP) { // On 2003/Vista the initial token has to be restricted if the main // token is restricted. initial_token = sandbox::USER_RESTRICTED_SAME_ACCESS; diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 9329215..7b674f2 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -20,7 +20,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/setup/install.h" #include "chrome/installer/setup/setup_constants.h" @@ -677,7 +677,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, return exit_code; if (system_install && !IsUserAnAdmin()) { - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && + if (base::win::GetVersion() >= base::win::VERSION_VISTA && !parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { std::wstring exe = parsed_command_line.GetProgram().value(); std::wstring params(command_line); diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 4822aa1..9ab8aab 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -12,7 +12,7 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/result_codes.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths_internal.h" @@ -468,7 +468,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome( if (remove_all && (!suffix.empty() || CurrentUserHasDefaultBrowser(system_uninstall)) && !::IsUserAnAdmin() && - (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) && + (base::win::GetVersion() >= base::win::VERSION_VISTA) && !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { std::wstring exe = cmd_line.GetProgram().value(); std::wstring params(cmd_params); diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 9715e71..c0fc09dc 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -21,7 +21,7 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/pref_names.h" @@ -228,7 +228,7 @@ bool RelaunchSetupAsConsoleUser(const std::wstring& flag) { WideToASCII(installer_util::switches::kToastResultsKey), base::IntToString(key)); - if (win_util::GetWinVersion() > win_util::WINVERSION_XP) { + if (base::win::GetVersion() > base::win::VERSION_XP) { // Make sure that in Vista and Above we have the proper DACLs so // the interactive user can launch it. if (!FixDACLsForExecute(setup_exe.ToWStringHack().c_str())) diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index e99f387..a0dfad1 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -20,7 +20,7 @@ #include "base/scoped_ptr.h" #include "base/string_util.h" #include "base/values.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/json_value_serializer.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" @@ -80,14 +80,14 @@ installer::Version* InstallUtil::GetChromeVersion(bool system_install) { bool InstallUtil::IsOSSupported() { int major, minor; - win_util::WinVersion version = win_util::GetWinVersion(); - win_util::GetServicePackLevel(&major, &minor); + base::win::Version version = base::win::GetVersion(); + base::win::GetServicePackLevel(&major, &minor); // We do not support Win2K or older, or XP without service pack 2. LOG(INFO) << "Windows Version: " << version << ", Service Pack: " << major << "." << minor; - if ((version > win_util::WINVERSION_XP) || - (version == win_util::WINVERSION_XP && major >= 2)) { + if ((version > base::win::VERSION_XP) || + (version == base::win::VERSION_XP && major >= 2)) { return true; } return false; diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index b3cf02b..257a78f 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -24,7 +24,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/browser_distribution.h" @@ -551,7 +551,7 @@ bool ShellUtil::GetQuickLaunchPath(bool system_level, std::wstring* path) { if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) return false; *path = qlaunch; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { file_util::AppendToPath(path, L"AppData\\Roaming"); } else { file_util::AppendToPath(path, L"Application Data"); @@ -618,7 +618,7 @@ bool ShellUtil::MakeChromeDefault(int shell_change, bool ret = true; // First use the new "recommended" way on Vista to make Chrome default // browser. - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { LOG(INFO) << "Registering Chrome as default browser on Vista."; IApplicationAssociationRegistration* pAAR; HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, @@ -699,7 +699,7 @@ bool ShellUtil::RegisterChromeBrowser(const std::wstring& chrome_exe, // If user is not an admin and OS is Vista, try to elevate and register. if (elevate_if_not_admin && - win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && + base::win::GetVersion() >= base::win::VERSION_VISTA && ElevateAndRegisterChrome(chrome_exe, suffix)) return true; diff --git a/chrome/renderer/pepper_widget.cc b/chrome/renderer/pepper_widget.cc index 9f05f2b..ba37f87 100644 --- a/chrome/renderer/pepper_widget.cc +++ b/chrome/renderer/pepper_widget.cc @@ -14,7 +14,7 @@ #include "webkit/glue/plugins/webplugin_delegate.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif static int g_next_id; @@ -65,7 +65,7 @@ NPError NPPaintWidget(NPP instance, iter->second->Paint(gdc, *dirty); #if defined(OS_WIN) - if (win_util::GetWinVersion() == win_util::WINVERSION_XP) { + if (base::win::GetVersion() == base::win::VERSION_XP) { gdc->canvas()->getTopPlatformDevice().makeOpaque( dirty->left, dirty->top, dirty->right - dirty->left, dirty->bottom - dirty->top); diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc index 23c1682..bdc1b29 100644 --- a/chrome/test/mini_installer_test/test.cc +++ b/chrome/test/mini_installer_test/test.cc @@ -6,7 +6,7 @@ #include "base/file_path.h" #include "base/platform_thread.h" #include "base/scoped_ptr.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/util_constants.h" @@ -51,7 +51,7 @@ class MiniInstallTest : public testing::Test { build = L"latest"; force_tests_ = cmd->HasSwitch(switches::kInstallerTestForce); chrome_frame_ = cmd->HasSwitch(installer_util::switches::kChromeFrame); - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA || + if (base::win::GetVersion() < base::win::VERSION_VISTA || force_tests_) { CleanTheSystem(); // Separate the test output from cleaning output diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 58a1007..4459e87 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -50,7 +50,7 @@ #include "net/base/net_util.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif @@ -940,7 +940,7 @@ void UITest::StartHttpServerWithPort(const FilePath& root_directory, // it will mess up with the command window and cause conhost.exe to crash. To // work around this, we start the http server on the background mode. #if defined(OS_WIN) - if (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) + if (base::win::GetVersion() >= base::win::VERSION_WIN7) cmd_line->AppendSwitch("run_background"); #endif diff --git a/chrome/tools/crash_service/crash_service.cc b/chrome/tools/crash_service/crash_service.cc index fb2fa49..dcf1daa 100644 --- a/chrome/tools/crash_service/crash_service.cc +++ b/chrome/tools/crash_service/crash_service.cc @@ -14,7 +14,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "breakpad/src/client/windows/crash_generation/client_info.h" #include "breakpad/src/client/windows/crash_generation/crash_generation_server.h" #include "breakpad/src/client/windows/sender/crash_report_sender.h" @@ -213,7 +213,7 @@ bool CrashService::Initialize(const std::wstring& command_line) { SECURITY_ATTRIBUTES security_attributes = {0}; SECURITY_ATTRIBUTES* security_attributes_actual = NULL; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { SECURITY_DESCRIPTOR* security_descriptor = reinterpret_cast<SECURITY_DESCRIPTOR*>( GetSecurityDescriptorForLowIntegrity()); diff --git a/chrome_frame/chrome_launcher_utils.cc b/chrome_frame/chrome_launcher_utils.cc index 913ff14..1b5943a 100644 --- a/chrome_frame/chrome_launcher_utils.cc +++ b/chrome_frame/chrome_launcher_utils.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. @@ -9,7 +9,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome_frame/chrome_frame_automation.h" @@ -20,7 +20,7 @@ const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; CommandLine* CreateLaunchCommandLine() { // Shortcut for OS versions that don't need the integrity broker. - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { return new CommandLine(GetChromeExecutablePath()); } diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index e073676..013995d 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -22,7 +22,7 @@ #include "base/string_piece.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/google_update_settings.h" @@ -300,7 +300,7 @@ HRESULT RefreshElevationPolicy() { // The idea here is to try this out on chrome frame dev channel // and see if it produces a significant drift in startup numbers. HRESULT SetupRunOnce() { - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) + if (base::win::GetVersion() >= base::win::VERSION_VISTA) return S_OK; std::wstring channel_name; @@ -699,7 +699,7 @@ static bool SetOrDeleteMimeHandlerKey(bool set, HKEY root_key) { bool RegisterSecuredMimeHandler(bool enable, bool is_system) { if (!is_system) { return SetOrDeleteMimeHandlerKey(enable, HKEY_CURRENT_USER); - } else if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + } else if (base::win::GetVersion() < base::win::VERSION_VISTA) { return SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE); } diff --git a/chrome_frame/delete_chrome_history.cc b/chrome_frame/delete_chrome_history.cc index 1d58df9..5745c50 100644 --- a/chrome_frame/delete_chrome_history.cc +++ b/chrome_frame/delete_chrome_history.cc @@ -7,6 +7,7 @@ #include "chrome/browser/browsing_data_remover.h" +#include "base/win/windows_version.h" #include "chrome_frame/chrome_frame_activex.h" #include "chrome_frame/utils.h" @@ -65,7 +66,7 @@ STDMETHODIMP DeleteChromeHistory::DeleteBrowsingHistory(DWORD flags) { // effort to connect. Thus, we detect if we are in that circumstance and exit // silently. base::IntegrityLevel integrity_level; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && + if (base::win::GetVersion() >= base::win::VERSION_VISTA && !base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), &integrity_level)) { return E_UNEXPECTED; diff --git a/chrome_frame/simple_resource_loader.cc b/chrome_frame/simple_resource_loader.cc index 886d18e..e39087c 100644 --- a/chrome_frame/simple_resource_loader.cc +++ b/chrome_frame/simple_resource_loader.cc @@ -14,7 +14,7 @@ #include "base/i18n/rtl.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" const wchar_t kLocalesDirName[] = L"Locales"; @@ -114,7 +114,7 @@ bool SimpleResourceLoader::GetLocaleFilePath(const std::wstring& language, HINSTANCE SimpleResourceLoader::LoadLocaleDll(const FilePath& dll_path) { DWORD load_flags = 0; - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { load_flags = LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | LOAD_LIBRARY_AS_IMAGE_RESOURCE; } else { diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index a9645ec..e98d353 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -21,6 +21,7 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths_internal.h" @@ -224,11 +225,10 @@ base::ProcessHandle LaunchIEOnVista(const std::wstring& url) { } base::ProcessHandle LaunchIE(const std::wstring& url) { - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { return LaunchIEOnVista(url); - } else { - return LaunchExecutable(kIEImageName, url); } + return LaunchExecutable(kIEImageName, url); } int CloseAllIEWindows() { @@ -372,7 +372,7 @@ HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) { // This causes the IWebBrowser2 interface which is returned to be useless, // i.e it does not receive any events, etc. Our workaround for this is // to impersonate a low integrity token and then launch IE. - if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA && + if (base::win::GetVersion() == base::win::VERSION_VISTA && GetInstalledIEVersion() == IE_7) { // Create medium integrity browser that will launch IE broker. ScopedComPtr<IWebBrowser2> medium_integrity_browser; diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index ad94c86..2ee8e17 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -9,7 +9,7 @@ #include "base/path_service.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/helper.h" @@ -868,7 +868,7 @@ const wchar_t kInstallFlowTestUrl[] = L"install_flow_test.html"; TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { ScopedChromeFrameRegistrar::UnregisterAtPath( ScopedChromeFrameRegistrar::GetChromeFrameBuildPath().value()); diff --git a/gfx/native_theme_win.cc b/gfx/native_theme_win.cc index 5ee77f9..6d143c9 100644 --- a/gfx/native_theme_win.cc +++ b/gfx/native_theme_win.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/scoped_handle.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "gfx/gdi_util.h" #include "gfx/rect.h" #include "skia/ext/platform_canvas.h" @@ -535,7 +535,7 @@ HRESULT NativeTheme::PaintProgressBar(HDC hdc, // The thickness of the bar frame inside |value_rect| const int kXPBarPadding = 3; - bool pre_vista = win_util::GetWinVersion() < win_util::WINVERSION_VISTA; + bool pre_vista = base::win::GetVersion() < base::win::VERSION_VISTA; HANDLE handle = GetThemeHandle(PROGRESS); if (handle && draw_theme_ && draw_theme_ex_) { draw_theme_(handle, hdc, PP_BAR, 0, bar_rect, NULL); diff --git a/gfx/win_util.cc b/gfx/win_util.cc index edd1a01..9941a65 100644 --- a/gfx/win_util.cc +++ b/gfx/win_util.cc @@ -6,7 +6,7 @@ #include <windows.h> -#include "base/win_util.h" +#include "base/win/windows_version.h" namespace { @@ -29,10 +29,10 @@ bool Direct2dIsAvailable() { static bool available = false; if (!checked) { - win_util::WinVersion version = win_util::GetWinVersion(); - if (version < win_util::WINVERSION_VISTA) + base::win::Version version = base::win::GetVersion(); + if (version < base::win::VERSION_VISTA) available = false; - else if (version >= win_util::WINVERSION_WIN7) + else if (version >= base::win::VERSION_WIN7) available = true; else available = DynamicLibraryPresent(L"d2d1.dll"); @@ -47,10 +47,10 @@ bool DirectWriteIsAvailable() { static bool available = false; if (!checked) { - win_util::WinVersion version = win_util::GetWinVersion(); - if (version < win_util::WINVERSION_VISTA) + base::win::Version version = base::win::GetVersion(); + if (version < base::win::VERSION_VISTA) available = false; - else if (version >= win_util::WINVERSION_WIN7) + else if (version >= base::win::VERSION_WIN7) available = true; else available = DynamicLibraryPresent(L"dwrite.dll"); diff --git a/ipc/ipc_channel_win.cc b/ipc/ipc_channel_win.cc index e6bcd3c..0470072 100644 --- a/ipc/ipc_channel_win.cc +++ b/ipc/ipc_channel_win.cc @@ -1,10 +1,11 @@ -// 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 "ipc/ipc_channel_win.h" #include <windows.h> +#include <sddl.h> #include <sstream> #include "base/auto_reset.h" @@ -17,6 +18,71 @@ #include "ipc/ipc_message_utils.h" namespace IPC { + +namespace { + +// Creates a security descriptor with a DACL that has one ace giving full +// access to the current logon session. +// The security descriptor returned must be freed using LocalFree. +// The function returns true if it succeeds, false otherwise. +bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor) { + // Get the current token. + HANDLE token = NULL; + if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) + return false; + ScopedHandle token_scoped(token); + + // Get the size of the TokenGroups structure. + DWORD size = 0; + BOOL result = GetTokenInformation(token, TokenGroups, NULL, 0, &size); + if (result != FALSE && GetLastError() != ERROR_INSUFFICIENT_BUFFER) + return false; + + // Get the data. + scoped_array<char> token_groups_chars(new char[size]); + TOKEN_GROUPS* token_groups = + reinterpret_cast<TOKEN_GROUPS*>(token_groups_chars.get()); + + if (!GetTokenInformation(token, TokenGroups, token_groups, size, &size)) + return false; + + // Look for the logon sid. + SID* logon_sid = NULL; + for (unsigned int i = 0; i < token_groups->GroupCount ; ++i) { + if ((token_groups->Groups[i].Attributes & SE_GROUP_LOGON_ID) != 0) { + logon_sid = static_cast<SID*>(token_groups->Groups[i].Sid); + break; + } + } + + if (!logon_sid) + return false; + + // Convert the data to a string. + wchar_t* sid_string; + if (!ConvertSidToStringSid(logon_sid, &sid_string)) + return false; + + static const wchar_t dacl_format[] = L"D:(A;OICI;GA;;;%ls)"; + wchar_t dacl[SECURITY_MAX_SID_SIZE + arraysize(dacl_format) + 1] = {0}; + wsprintf(dacl, dacl_format, sid_string); + + LocalFree(sid_string); + + // Convert the string to a security descriptor + if (!ConvertStringSecurityDescriptorToSecurityDescriptor( + dacl, + SDDL_REVISION_1, + reinterpret_cast<PSECURITY_DESCRIPTOR*>(security_descriptor), + NULL)) { + return false; + } + + return true; +} + +} // namespace + //------------------------------------------------------------------------------ Channel::ChannelImpl::State::State(ChannelImpl* channel) : is_pending(false) { @@ -119,7 +185,7 @@ bool Channel::ChannelImpl::CreatePipe(const std::string& channel_id, SECURITY_ATTRIBUTES security_attributes = {0}; security_attributes.bInheritHandle = FALSE; security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); - if (!win_util::GetLogonSessionOnlyDACL( + if (!GetLogonSessionOnlyDACL( reinterpret_cast<SECURITY_DESCRIPTOR**>( &security_attributes.lpSecurityDescriptor))) { NOTREACHED(); diff --git a/sandbox/src/integrity_level_test.cc b/sandbox/src/integrity_level_test.cc index fff26da..cdc8da7 100644 --- a/sandbox/src/integrity_level_test.cc +++ b/sandbox/src/integrity_level_test.cc @@ -1,11 +1,11 @@ -// 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 <atlsecurity.h> -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "testing/gtest/include/gtest/gtest.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_policy.h" @@ -45,7 +45,7 @@ SBOX_TESTS_COMMAND int CheckIntegrityLevel(int argc, wchar_t **argv) { } TEST(IntegrityLevelTest, TestLowILReal) { - if (win_util::WINVERSION_VISTA != win_util::GetWinVersion()) + if (base::win::VERSION_VISTA != base::win::GetVersion()) return; TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE); @@ -61,7 +61,7 @@ TEST(IntegrityLevelTest, TestLowILReal) { } TEST(DelayedIntegrityLevelTest, TestLowILDelayed) { - if (win_util::WINVERSION_VISTA != win_util::GetWinVersion()) + if (base::win::VERSION_VISTA != base::win::GetVersion()) return; TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE); @@ -77,7 +77,7 @@ TEST(DelayedIntegrityLevelTest, TestLowILDelayed) { } TEST(IntegrityLevelTest, TestNoILChange) { - if (win_util::WINVERSION_VISTA != win_util::GetWinVersion()) + if (base::win::VERSION_VISTA != base::win::GetVersion()) return; TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE); diff --git a/sandbox/src/policy_broker.cc b/sandbox/src/policy_broker.cc index f2316b0..ff67667 100644 --- a/sandbox/src/policy_broker.cc +++ b/sandbox/src/policy_broker.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 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,7 +8,7 @@ #include "base/logging.h" #include "base/pe_image.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "sandbox/src/interception.h" #include "sandbox/src/interceptors.h" #include "sandbox/src/policy_target.h" @@ -100,7 +100,7 @@ bool SetupBasicInterceptions(InterceptionManager* manager) { !INTERCEPT_NT(manager, NtOpenThreadToken, OPEN_THREAD_TOKEN_ID, 20)) return false; - if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { + if (base::win::GetVersion() >= base::win::VERSION_XP) { // Bug 27218: We don't have dispatch for some x64 syscalls. // This one is also provided by process_thread_policy. if (!INTERCEPT_NT(manager, NtOpenProcessTokenEx, OPEN_PROCESS_TOKEN_EX_ID, diff --git a/sandbox/src/policy_target_test.cc b/sandbox/src/policy_target_test.cc index 98f2418..577c8c5 100644 --- a/sandbox/src/policy_target_test.cc +++ b/sandbox/src/policy_target_test.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2006-2010 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 "base/win_util.h" +#include "base/win/windows_version.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/sandbox_utils.h" @@ -158,7 +158,7 @@ SBOX_TESTS_COMMAND int PolicyTargetTest_process(int argc, wchar_t **argv) { TEST(PolicyTargetTest, SetInformationThread) { TestRunner runner; - if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { + if (base::win::GetVersion() >= base::win::VERSION_XP) { runner.SetTestState(BEFORE_REVERT); EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); } @@ -167,13 +167,13 @@ TEST(PolicyTargetTest, SetInformationThread) { EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token")); runner.SetTestState(EVERY_STATE); - if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) + if (base::win::GetVersion() >= base::win::VERSION_XP) EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"PolicyTargetTest_steal")); } TEST(PolicyTargetTest, OpenThreadToken) { TestRunner runner; - if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { + if (base::win::GetVersion() >= base::win::VERSION_XP) { runner.SetTestState(BEFORE_REVERT); EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token2")); } @@ -184,7 +184,7 @@ TEST(PolicyTargetTest, OpenThreadToken) { TEST(PolicyTargetTest, OpenThreadTokenEx) { TestRunner runner; - if (win_util::GetWinVersion() < win_util::WINVERSION_XP) + if (base::win::GetVersion() < base::win::VERSION_XP) return; runner.SetTestState(BEFORE_REVERT); diff --git a/sandbox/src/registry_dispatcher.cc b/sandbox/src/registry_dispatcher.cc index b268157..5f53770 100644 --- a/sandbox/src/registry_dispatcher.cc +++ b/sandbox/src/registry_dispatcher.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2006-2010 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 "sandbox/src/registry_dispatcher.h" #include "base/scoped_handle_win.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "sandbox/src/crosscall_client.h" #include "sandbox/src/interception.h" #include "sandbox/src/interceptors.h" @@ -63,7 +63,7 @@ bool RegistryDispatcher::SetupService(InterceptionManager* manager, if (IPC_NTOPENKEY_TAG == service) { bool result = INTERCEPT_NT(manager, NtOpenKey, OPEN_KEY_ID, 16); - if (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) + if (base::win::GetVersion() >= base::win::VERSION_WIN7) result &= INTERCEPT_NT(manager, NtOpenKeyEx, OPEN_KEY_EX_ID, 20); return result; } diff --git a/sandbox/src/restricted_token_utils.cc b/sandbox/src/restricted_token_utils.cc index 2bc4c59..8842865 100644 --- a/sandbox/src/restricted_token_utils.cc +++ b/sandbox/src/restricted_token_utils.cc @@ -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. @@ -10,7 +10,7 @@ #include "base/logging.h" #include "base/scoped_handle_win.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "sandbox/src/job.h" #include "sandbox/src/restricted_token.h" #include "sandbox/src/security_level.h" @@ -85,9 +85,8 @@ DWORD CreateRestrictedToken(HANDLE *token_handle, // in the token to achieve this. You should also set the process to be // low integrity level so it can't access object created by other // processes. - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) restricted_token.AddRestrictingSidLogonSession(); - } break; } case USER_RESTRICTED: { @@ -286,7 +285,7 @@ const wchar_t* GetIntegrityLevelString(IntegrityLevel integrity_level) { return NULL; } DWORD SetTokenIntegrityLevel(HANDLE token, IntegrityLevel integrity_level) { - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) + if (base::win::GetVersion() < base::win::VERSION_VISTA) return ERROR_SUCCESS; const wchar_t* integrity_level_str = GetIntegrityLevelString(integrity_level); @@ -312,7 +311,7 @@ DWORD SetTokenIntegrityLevel(HANDLE token, IntegrityLevel integrity_level) { } DWORD SetProcessIntegrityLevel(IntegrityLevel integrity_level) { - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) + if (base::win::GetVersion() < base::win::VERSION_VISTA) return ERROR_SUCCESS; const wchar_t* integrity_level_str = GetIntegrityLevelString(integrity_level); diff --git a/sandbox/tests/validation_tests/suite.cc b/sandbox/tests/validation_tests/suite.cc index 49faf6d..a5886cd 100644 --- a/sandbox/tests/validation_tests/suite.cc +++ b/sandbox/tests/validation_tests/suite.cc @@ -11,6 +11,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "sandbox/tests/common/controller.h" +#pragma comment(lib, "shlwapi.lib") + namespace sandbox { // Returns true if the volume that contains any_path supports ACL security. The diff --git a/views/controls/button/native_button_win.cc b/views/controls/button/native_button_win.cc index 45301f0..5aac782 100644 --- a/views/controls/button/native_button_win.cc +++ b/views/controls/button/native_button_win.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/scoped_comptr_win.h" #include "base/win_util.h" +#include "base/win/windows_version.h" #include "views/controls/button/checkbox.h" #include "views/controls/button/native_button.h" #include "views/controls/button/radio_button.h" @@ -39,7 +40,7 @@ void NativeButtonWin::UpdateLabel() { // Show or hide the shield icon of Windows onto this button every time when we // update the button text so Windows can lay out the shield icon and the // button text correctly. - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && + if (base::win::GetVersion() >= base::win::VERSION_VISTA && win_util::UserAccountControlIsEnabled()) { Button_SetElevationRequiredState(native_view(), native_button_->need_elevation()); diff --git a/views/controls/menu/menu_host_win.cc b/views/controls/menu/menu_host_win.cc index 384229f..1bcc295 100644 --- a/views/controls/menu/menu_host_win.cc +++ b/views/controls/menu/menu_host_win.cc @@ -1,10 +1,10 @@ -// 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 "views/controls/menu/menu_host_win.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "views/controls/menu/menu_controller.h" #include "views/controls/menu/menu_host_root_view.h" #include "views/controls/menu/menu_item_view.h" @@ -23,7 +23,7 @@ MenuHostWin::MenuHostWin(SubmenuView* submenu) owns_capture_(false) { set_window_style(WS_POPUP); set_initial_class_style( - (win_util::GetWinVersion() < win_util::WINVERSION_XP) ? + (base::win::GetVersion() < base::win::VERSION_XP) ? 0 : CS_DROPSHADOW); is_mouse_down_ = ((GetKeyState(VK_LBUTTON) & 0x80) || diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index c91dcdf..254c677 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -15,7 +15,7 @@ #include "base/i18n/rtl.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "gfx/native_theme_win.h" #include "grit/app_strings.h" #include "skia/ext/skia_utils_win.h" @@ -761,7 +761,7 @@ void NativeTextfieldWin::OnNCPaint(HRGN region) { int part; int state; - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) { part = EP_EDITTEXT; if (!textfield_->IsEnabled()) diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 0443478..b9b1c61 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -12,6 +12,7 @@ #include "app/win_util.h" #include "base/i18n/rtl.h" #include "base/win_util.h" +#include "base/win/windows_version.h" #include "gfx/canvas_skia_paint.h" #include "gfx/font.h" #include "gfx/icon_util.h" @@ -193,7 +194,7 @@ static BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) { } // namespace void WindowWin::FrameTypeChanged() { - if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { // We need to toggle the rendering policy of the DWM/glass frame as we // change from opaque to glass. "Non client rendering enabled" means that // the DWM's glass non-client rendering is enabled, which is why diff --git a/webkit/glue/plugins/pepper_scrollbar.cc b/webkit/glue/plugins/pepper_scrollbar.cc index c265851..88a3f9b 100644 --- a/webkit/glue/plugins/pepper_scrollbar.cc +++ b/webkit/glue/plugins/pepper_scrollbar.cc @@ -19,7 +19,7 @@ #include "webkit/glue/webkit_glue.h" #if defined(OS_WIN) -#include "base/win_util.h" +#include "base/win/windows_version.h" #endif using WebKit::WebInputEvent; @@ -164,7 +164,7 @@ bool Scrollbar::Paint(const PP_Rect* rect, ImageData* image) { scrollbar_->paint(webkit_glue::ToWebCanvas(canvas), gfx_rect); #if defined(OS_WIN) - if (win_util::GetWinVersion() == win_util::WINVERSION_XP) { + if (base::win::GetVersion() == base::win::VERSION_XP) { canvas->getTopPlatformDevice().makeOpaque( gfx_rect.x(), gfx_rect.y(), gfx_rect.width(), gfx_rect.height()); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc index 115a494..867727f 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc @@ -19,7 +19,7 @@ #include "base/string_split.h" #include "base/string_util.h" #include "base/stringprintf.h" -#include "base/win_util.h" +#include "base/win/windows_version.h" #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/plugins/default_plugin_shared.h" @@ -415,7 +415,7 @@ bool WebPluginDelegateImpl::PlatformInitialize() { // name of the current process. We do it in the installer for admin users, // for the rest patch this function. if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && - win_util::GetWinVersion() == win_util::WINVERSION_XP && + base::win::GetVersion() == base::win::VERSION_XP && !RegKey().Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe", KEY_READ) && |