Skip to content

Commit

Permalink
Move windows version-related stuff out of base/win_util and into base…
Browse files Browse the repository at this point in the history
…/win/windows_version. Many files now only need to include this instead of all of win_util.

Remove a bunch of unused code from base/win_util. There was a surprising amount.

Replace the AppUserModel property key with the one from the SDK now that we use the Win7 SDK. Move GetLogonSessionOnlyDACL from win_util to ipc since it's only used in that one place.

TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3823002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62694 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Oct 15, 2010
1 parent 7d1f334 commit 935aa54
Show file tree
Hide file tree
Showing 67 changed files with 409 additions and 469 deletions.
4 changes: 2 additions & 2 deletions app/animation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions app/animation_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions app/l10n_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 3 additions & 5 deletions app/l10n_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"));
}

Expand All @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions app/resource_bundle_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions app/win_util.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
32 changes: 19 additions & 13 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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/*'],
],
},],
],
}],
Expand Down
6 changes: 3 additions & 3 deletions base/base_paths_win.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions base/file_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions base/path_service_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions base/pe_image_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 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 contains unit tests for PEImage.

#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,
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions base/platform_thread_win.cc
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions base/process_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions base/trace_event_win_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 935aa54

Please sign in to comment.