diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-31 20:39:02 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-31 20:39:02 +0000 |
commit | fd85ad650d68309b965dbc9f3d6823cf2754349c (patch) | |
tree | 28b98629e02b2e05ec74272146f249ca62a164da | |
parent | ce072a7181ea5d58133e33654133236f5d9f5551 (diff) | |
download | chromium_src-fd85ad650d68309b965dbc9f3d6823cf2754349c.zip chromium_src-fd85ad650d68309b965dbc9f3d6823cf2754349c.tar.gz chromium_src-fd85ad650d68309b965dbc9f3d6823cf2754349c.tar.bz2 |
Move app/win_util to app/win and fix the namespace usage.
Split out the two classes: ScopedComInitializer and ScopedCOMem (which I renamed) to separate files.
I removed the win_util_path file which had one function in it and moved the function to win_util.
Somehow, this was getting picked up by the nacl64 build and the call in sandbox_policy was then not being
defined. I just implemented the function in-plcae since it's just a simple wrapper around a Windows API call.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6013009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70343 0039d316-1c4b-4281-b951-d872f2087c98
51 files changed, 343 insertions, 344 deletions
diff --git a/app/app.gyp b/app/app.gyp index e34f161..bac326b 100644 --- a/app/app.gyp +++ b/app/app.gyp @@ -58,7 +58,7 @@ 'tree_node_iterator_unittest.cc', 'tree_node_model_unittest.cc', 'view_prop_unittest.cc', - 'win_util_unittest.cc', + 'win/win_util_unittest.cc', ], 'include_dirs': [ '..', diff --git a/app/app_base.gypi b/app/app_base.gypi index 2581bdb..6bcad0e 100644 --- a/app/app_base.gypi +++ b/app/app_base.gypi @@ -32,13 +32,6 @@ 'tree_node_model.h', ], 'conditions': [ - ['OS=="win"', { - 'sources': [ - 'win_util.cc', - 'win_util.h', - 'win_util_path.cc', - ], - }], ['OS!="linux" and OS!="freebsd" and OS!="openbsd"', { 'sources!': [ 'gtk_dnd_util.cc', @@ -238,12 +231,16 @@ 'win/hwnd_util.h', 'win/iat_patch_function.cc', 'win/iat_patch_function.h', + 'win/scoped_co_mem.h', + 'win/scoped_com_initializer.h', 'win/scoped_prop.cc', 'win/scoped_prop.h', 'win/shell.cc', 'win/shell.h', 'win/window_impl.cc', 'win/window_impl.h', + 'win/win_util.cc', + 'win/win_util.h', 'x11_util.cc', 'x11_util.h', 'x11_util_internal.h', diff --git a/app/win/scoped_co_mem.h b/app/win/scoped_co_mem.h new file mode 100644 index 0000000..a6017fa --- /dev/null +++ b/app/win/scoped_co_mem.h @@ -0,0 +1,49 @@ +// 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 APP_WIN_SCOPED_CO_MEM_H_ +#define APP_WIN_SCOPED_CO_MEM_H_ +#pragma once + +#include <objbase.h> + +#include "base/basictypes.h" + +namespace app { +namespace win { + +// Simple scoped memory releaser class for COM allocated memory. +// Example: +// app::win::ScopedCoMem<ITEMIDLIST> file_item; +// SHGetSomeInfo(&file_item, ...); +// ... +// return; <-- memory released +template<typename T> +class ScopedCoMem { + public: + explicit ScopedCoMem() : mem_ptr_(NULL) {} + + ~ScopedCoMem() { + if (mem_ptr_) + CoTaskMemFree(mem_ptr_); + } + + T** operator&() { // NOLINT + return &mem_ptr_; + } + + operator T*() { + return mem_ptr_; + } + + private: + T* mem_ptr_; + + DISALLOW_COPY_AND_ASSIGN(ScopedCoMem); +}; + +} // namespace win +} // namespace app + +#endif // APP_WIN_SCOPED_CO_MEM_H_ diff --git a/app/win/scoped_com_initializer.h b/app/win/scoped_com_initializer.h new file mode 100644 index 0000000..3a2cf55 --- /dev/null +++ b/app/win/scoped_com_initializer.h @@ -0,0 +1,60 @@ +// 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 APP_WIN_SCOPED_COM_INITIALIZER_H_ +#define APP_WIN_SCOPED_COM_INITIALIZER_H_ +#pragma once + +#include "base/basictypes.h" +#include "build/build_config.h" + +#if defined(OS_WIN) + +#include <objbase.h> + +namespace app { +namespace win { + +// Initializes COM in the constructor (STA), and uninitializes COM in the +// destructor. +class ScopedCOMInitializer { + public: + ScopedCOMInitializer() : hr_(CoInitialize(NULL)) { + } + + ScopedCOMInitializer::~ScopedCOMInitializer() { + if (SUCCEEDED(hr_)) + CoUninitialize(); + } + + private: + HRESULT hr_; + + DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); +}; + +} // namespace win +} // namespace app + +#else + +namespace app { +namespace win { + +// Do-nothing class for other platforms. +class ScopedCOMInitializer { + public: + ScopedCOMInitializer() {} + ~ScopedCOMInitializer() {} + + private: + DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); +}; + +} // namespace win +} // namespace app + +#endif + +#endif // APP_WIN_SCOPED_COM_INITIALIZER_H_ diff --git a/app/win_util.cc b/app/win/win_util.cc index 3ed9842..f1ac107 100644 --- a/app/win_util.cc +++ b/app/win/win_util.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "app/win_util.h" +#include "app/win/win_util.h" #include <commdlg.h> #include <shellapi.h> @@ -23,14 +23,15 @@ #include "base/win/scoped_hdc.h" #include "base/win/win_util.h" #include "gfx/codec/png_codec.h" +#include "gfx/font.h" #include "gfx/gdi_util.h" -namespace win_util { +namespace app { +namespace win { const int kAutoHideTaskbarThicknessPx = 2; -std::wstring FormatSystemTime(const SYSTEMTIME& time, - const std::wstring& format) { +string16 FormatSystemTime(const SYSTEMTIME& time, const string16& format) { // If the format string is empty, just use the default format. LPCTSTR format_ptr = NULL; if (!format.empty()) @@ -39,15 +40,14 @@ std::wstring FormatSystemTime(const SYSTEMTIME& time, int buffer_size = GetTimeFormat(LOCALE_USER_DEFAULT, NULL, &time, format_ptr, NULL, 0); - std::wstring output; + string16 output; GetTimeFormat(LOCALE_USER_DEFAULT, NULL, &time, format_ptr, WriteInto(&output, buffer_size), buffer_size); return output; } -std::wstring FormatSystemDate(const SYSTEMTIME& date, - const std::wstring& format) { +string16 FormatSystemDate(const SYSTEMTIME& date, const string16& format) { // If the format string is empty, just use the default format. LPCTSTR format_ptr = NULL; if (!format.empty()) @@ -56,13 +56,26 @@ std::wstring FormatSystemDate(const SYSTEMTIME& date, int buffer_size = GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr, NULL, 0); - std::wstring output; + string16 output; GetDateFormat(LOCALE_USER_DEFAULT, NULL, &date, format_ptr, WriteInto(&output, buffer_size), buffer_size); return output; } +bool ConvertToLongPath(const string16& short_path, + string16* long_path) { + wchar_t long_path_buf[MAX_PATH]; + DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf, + MAX_PATH); + if (return_value != 0 && return_value < MAX_PATH) { + *long_path = long_path_buf; + return true; + } + + return false; +} + bool IsDoubleClick(const POINT& origin, const POINT& current, DWORD elapsed_time) { @@ -241,7 +254,7 @@ bool IsWindowActive(HWND hwnd) { ((info.dwWindowStatus & WS_ACTIVECAPTION) != 0); } -bool IsReservedName(const std::wstring& filename) { +bool IsReservedName(const string16& filename) { // This list is taken from the MSDN article "Naming a file" // http://msdn2.microsoft.com/en-us/library/aa365247(VS.85).aspx // I also added clock$ because GetSaveFileName seems to consider it as a @@ -251,14 +264,14 @@ bool IsReservedName(const std::wstring& filename) { L"com6", L"com7", L"com8", L"com9", L"lpt1", L"lpt2", L"lpt3", L"lpt4", L"lpt5", L"lpt6", L"lpt7", L"lpt8", L"lpt9", L"clock$" }; - std::wstring filename_lower = StringToLowerASCII(filename); + string16 filename_lower = StringToLowerASCII(filename); for (int i = 0; i < arraysize(known_devices); ++i) { // Exact match. if (filename_lower == known_devices[i]) return true; // Starts with "DEVICE.". - if (filename_lower.find(std::wstring(known_devices[i]) + L".") == 0) + if (filename_lower.find(string16(known_devices[i]) + L".") == 0) return true; } @@ -280,8 +293,8 @@ bool IsReservedName(const std::wstring& filename) { // RTL locale, we need to make sure that LTR strings are rendered correctly by // adding the appropriate Unicode directionality marks. int MessageBox(HWND hwnd, - const std::wstring& text, - const std::wstring& caption, + const string16& text, + const string16& caption, UINT flags) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) return IDOK; @@ -290,11 +303,11 @@ int MessageBox(HWND hwnd, if (base::i18n::IsRTL()) actual_flags |= MB_RIGHT | MB_RTLREADING; - std::wstring localized_text = text; + string16 localized_text = text; base::i18n::AdjustStringForLocaleDirection(&localized_text); const wchar_t* text_ptr = localized_text.c_str(); - std::wstring localized_caption = caption; + string16 localized_caption = caption; base::i18n::AdjustStringForLocaleDirection(&localized_caption); const wchar_t* caption_ptr = localized_caption.c_str(); @@ -309,4 +322,5 @@ gfx::Font GetWindowTitleFont() { return gfx::Font(caption_font); } -} // namespace win_util +} // namespace win +} // namespace app diff --git a/app/win_util.h b/app/win/win_util.h index 2fcd86b..71b0f78 100644 --- a/app/win_util.h +++ b/app/win/win_util.h @@ -2,103 +2,45 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef APP_WIN_UTIL_H_ -#define APP_WIN_UTIL_H_ +#ifndef APP_WIN_WIN_UTIL_H_ +#define APP_WIN_WIN_UTIL_H_ #pragma once -#include <objbase.h> +#include <windows.h> -#include <string> #include <vector> -#include "base/fix_wp64.h" -#include "base/scoped_handle.h" -#include "gfx/font.h" -#include "gfx/rect.h" +#include "base/string16.h" class FilePath; -namespace win_util { - -// Import ScopedHandle and friends into this namespace for backwards -// compatibility. TODO(darin): clean this up! -using ::ScopedHandle; -using ::ScopedBitmap; - -// Simple scoped memory releaser class for COM allocated memory. -// Example: -// CoMemReleaser<ITEMIDLIST> file_item; -// SHGetSomeInfo(&file_item, ...); -// ... -// return; <-- memory released -template<typename T> -class CoMemReleaser { - public: - explicit CoMemReleaser() : mem_ptr_(NULL) {} - - ~CoMemReleaser() { - if (mem_ptr_) - CoTaskMemFree(mem_ptr_); - } - - T** operator&() { // NOLINT - return &mem_ptr_; - } - - operator T*() { - return mem_ptr_; - } - - private: - T* mem_ptr_; - - DISALLOW_COPY_AND_ASSIGN(CoMemReleaser); -}; - -// Initializes COM in the constructor (STA), and uninitializes COM in the -// destructor. -class ScopedCOMInitializer { - public: - ScopedCOMInitializer() : hr_(CoInitialize(NULL)) { - } - - ScopedCOMInitializer::~ScopedCOMInitializer() { - if (SUCCEEDED(hr_)) - CoUninitialize(); - } - - // Returns the error code from CoInitialize(NULL) - // (called in constructor) - inline HRESULT error_code() const { - return hr_; - } - - protected: - HRESULT hr_; - - private: - DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer); -}; +namespace gfx { +class Font; +class Rect; +} + +namespace app { +namespace win { // Creates a string interpretation of the time of day represented by the given // SYSTEMTIME that's appropriate for the user's default locale. // Format can be an empty string (for the default format), or a "format picture" // as specified in the Windows documentation for GetTimeFormat(). -std::wstring FormatSystemTime(const SYSTEMTIME& time, - const std::wstring& format); +string16 FormatSystemTime(const SYSTEMTIME& time, + const string16& format); // Creates a string interpretation of the date represented by the given // SYSTEMTIME that's appropriate for the user's default locale. // Format can be an empty string (for the default format), or a "format picture" // as specified in the Windows documentation for GetDateFormat(). -std::wstring FormatSystemDate(const SYSTEMTIME& date, - const std::wstring& format); +string16 FormatSystemDate(const SYSTEMTIME& date, + const string16& format); // Returns the long path name given a short path name. A short path name // is a path that follows the 8.3 convention and has ~x in it. If the // path is already a long path name, the function returns the current // path without modification. -bool ConvertToLongPath(const std::wstring& short_path, std::wstring* long_path); +bool ConvertToLongPath(const string16& short_path, string16* long_path); // Returns true if the current point is close enough to the origin point in // space and time that it would be considered a double click. @@ -149,15 +91,15 @@ bool IsWindowActive(HWND hwnd); // Returns whether the specified file name is a reserved name on windows. // This includes names like "com2.zip" (which correspond to devices) and // desktop.ini and thumbs.db which have special meaning to the windows shell. -bool IsReservedName(const std::wstring& filename); +bool IsReservedName(const string16& filename); // A wrapper around Windows' MessageBox function. Using a Chrome specific // MessageBox function allows us to control certain RTL locale flags so that // callers don't have to worry about adding these flags when running in a // right-to-left locale. int MessageBox(HWND hwnd, - const std::wstring& text, - const std::wstring& caption, + const string16& text, + const string16& caption, UINT flags); // Returns the system set window title font. @@ -166,6 +108,7 @@ gfx::Font GetWindowTitleFont(); // The thickness of an auto-hide taskbar in pixels. extern const int kAutoHideTaskbarThicknessPx; -} // namespace win_util +} // namespace win +} // namespace app -#endif // APP_WIN_UTIL_H_ +#endif // APP_WIN_WIN_UTIL_H_ diff --git a/app/win/win_util_unittest.cc b/app/win/win_util_unittest.cc new file mode 100644 index 0000000..0dc4568 --- /dev/null +++ b/app/win/win_util_unittest.cc @@ -0,0 +1,59 @@ +// 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 "app/win/win_util.h" +#include "gfx/rect.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace app { +namespace win { + +TEST(WinUtilTest, EnsureRectIsVisibleInRect) { + gfx::Rect parent_rect(0, 0, 500, 400); + + { + // Child rect x < 0 + gfx::Rect child_rect(-50, 20, 100, 100); + EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); + EXPECT_EQ(gfx::Rect(10, 20, 100, 100), child_rect); + } + + { + // Child rect y < 0 + gfx::Rect child_rect(20, -50, 100, 100); + EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); + EXPECT_EQ(gfx::Rect(20, 10, 100, 100), child_rect); + } + + { + // Child rect right > parent_rect.right + gfx::Rect child_rect(450, 20, 100, 100); + EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); + EXPECT_EQ(gfx::Rect(390, 20, 100, 100), child_rect); + } + + { + // Child rect bottom > parent_rect.bottom + gfx::Rect child_rect(20, 350, 100, 100); + EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); + EXPECT_EQ(gfx::Rect(20, 290, 100, 100), child_rect); + } + + { + // Child rect width > parent_rect.width + gfx::Rect child_rect(20, 20, 700, 100); + EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); + EXPECT_EQ(gfx::Rect(20, 20, 480, 100), child_rect); + } + + { + // Child rect height > parent_rect.height + gfx::Rect child_rect(20, 20, 100, 700); + EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); + EXPECT_EQ(gfx::Rect(20, 20, 100, 380), child_rect); + } +} + +} // namespace win +} // namespace app diff --git a/app/win_util_path.cc b/app/win_util_path.cc deleted file mode 100644 index 5717f4e..0000000 --- a/app/win_util_path.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2009 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 "app/win_util.h" - -namespace win_util { - -bool ConvertToLongPath(const std::wstring& short_path, - std::wstring* long_path) { - wchar_t long_path_buf[MAX_PATH]; - DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf, - MAX_PATH); - if (return_value != 0 && return_value < MAX_PATH) { - *long_path = long_path_buf; - return true; - } - - return false; -} - -} // namespace win_util diff --git a/app/win_util_unittest.cc b/app/win_util_unittest.cc deleted file mode 100644 index 2c0eafc..0000000 --- a/app/win_util_unittest.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "app/win_util.h" -#include "testing/gtest/include/gtest/gtest.h" - -TEST(WinUtilTest, EnsureRectIsVisibleInRect) { - gfx::Rect parent_rect(0, 0, 500, 400); - - { - // Child rect x < 0 - gfx::Rect child_rect(-50, 20, 100, 100); - win_util::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); - EXPECT_EQ(gfx::Rect(10, 20, 100, 100), child_rect); - } - - { - // Child rect y < 0 - gfx::Rect child_rect(20, -50, 100, 100); - win_util::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); - EXPECT_EQ(gfx::Rect(20, 10, 100, 100), child_rect); - } - - { - // Child rect right > parent_rect.right - gfx::Rect child_rect(450, 20, 100, 100); - win_util::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); - EXPECT_EQ(gfx::Rect(390, 20, 100, 100), child_rect); - } - - { - // Child rect bottom > parent_rect.bottom - gfx::Rect child_rect(20, 350, 100, 100); - win_util::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); - EXPECT_EQ(gfx::Rect(20, 290, 100, 100), child_rect); - } - - { - // Child rect width > parent_rect.width - gfx::Rect child_rect(20, 20, 700, 100); - win_util::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); - EXPECT_EQ(gfx::Rect(20, 20, 480, 100), child_rect); - } - - { - // Child rect height > parent_rect.height - gfx::Rect child_rect(20, 20, 100, 700); - win_util::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); - EXPECT_EQ(gfx::Rect(20, 20, 100, 380), child_rect); - } -} - -static const struct filename_case { - const wchar_t* filename; - const wchar_t* filter_selected; - const wchar_t* suggested_ext; - const wchar_t* result; -} filename_cases[] = { - // Test a specific filter (*.jpg). - {L"f", L"*.jpg", L"jpg", L"f.jpg"}, - {L"f.", L"*.jpg", L"jpg", L"f..jpg"}, - {L"f..", L"*.jpg", L"jpg", L"f...jpg"}, - {L"f.jpeg", L"*.jpg", L"jpg", L"f.jpeg"}, - // Further guarantees. - {L"f.jpg.jpg", L"*.jpg", L"jpg", L"f.jpg.jpg"}, - {L"f.exe.jpg", L"*.jpg", L"jpg", L"f.exe.jpg"}, - {L"f.jpg.exe", L"*.jpg", L"jpg", L"f.jpg.exe.jpg"}, - {L"f.exe..", L"*.jpg", L"jpg", L"f.exe...jpg"}, - {L"f.jpg..", L"*.jpg", L"jpg", L"f.jpg...jpg"}, - // Test the All Files filter (*.jpg). - {L"f", L"*.*", L"jpg", L"f"}, - {L"f.", L"*.*", L"jpg", L"f"}, - {L"f..", L"*.*", L"jpg", L"f"}, - {L"f.jpg", L"*.*", L"jpg", L"f.jpg"}, - {L"f.jpeg", L"*.*", L"jpg", L"f.jpeg"}, // Same MIME type (diff. ext). - // Test the empty filter, which should behave identically to the - // All Files filter. - {L"f", L"", L"jpg", L"f"}, - {L"f.", L"", L"jpg", L"f"}, - {L"f..", L"", L"jpg", L"f"}, - {L"f.jpg", L"", L"jpg", L"f.jpg"}, - {L"f.jpeg", L"", L"jpg", L"f.jpeg"}, -}; diff --git a/base/base_switches.cc b/base/base_switches.cc index d907a3a..c95010e 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -23,7 +23,7 @@ const char kFullMemoryCrashReport[] = "full-memory-crash-report"; // Suppresses all error dialogs when present. const char kNoErrorDialogs[] = "noerrdialogs"; -// Disable win_util::MessageBox. This is useful when running as part of +// Disable app::win::MessageBox. This is useful when running as part of // scripts that do not have a user interface. const char kNoMessageBox[] = "no-message-box"; diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 284f30c..118f050 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -18,10 +18,10 @@ #include "app/l10n_util_win.h" #include "app/os_exchange_data.h" #include "app/os_exchange_data_provider_win.h" -#include "app/win_util.h" #include "app/win/drag_source.h" #include "app/win/drop_target.h" #include "app/win/iat_patch_function.h" +#include "app/win/win_util.h" #include "base/auto_reset.h" #include "base/basictypes.h" #include "base/i18n/rtl.h" @@ -924,7 +924,7 @@ bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( // We don't process ALT + numpad digit as accelerators, they are used for // entering special characters. We do translate alt-home. if (e.IsAltDown() && (key != app::VKEY_HOME) && - win_util::IsNumPadDigit(key, e.IsExtendedKey())) + app::win::IsNumPadDigit(key, e.IsExtendedKey())) return true; // Skip accelerators for key combinations omnibox wants to crack. This list @@ -1477,7 +1477,7 @@ void AutocompleteEditViewWin::OnLButtonDown(UINT keys, const CPoint& point) { // double_click_time_ from the current message's time even if the timer has // wrapped in between. const bool is_triple_click = tracking_double_click_ && - win_util::IsDoubleClick(double_click_point_, point, + app::win::IsDoubleClick(double_click_point_, point, GetCurrentMessage()->time - double_click_time_); tracking_double_click_ = false; @@ -1577,7 +1577,7 @@ void AutocompleteEditViewWin::OnMouseMove(UINT keys, const CPoint& point) { return; } - if (tracking_click_[kLeft] && !win_util::IsDrag(click_point_[kLeft], point)) + if (tracking_click_[kLeft] && !app::win::IsDrag(click_point_[kLeft], point)) return; tracking_click_[kLeft] = false; @@ -2395,7 +2395,7 @@ ITextDocument* AutocompleteEditViewWin::GetTextObjectModel() const { } void AutocompleteEditViewWin::StartDragIfNecessary(const CPoint& point) { - if (initiated_drag_ || !win_util::IsDrag(click_point_[kLeft], point)) + if (initiated_drag_ || !app::win::IsDrag(click_point_[kLeft], point)) return; OSExchangeData data; @@ -2551,7 +2551,7 @@ void AutocompleteEditViewWin::SelectAllIfNecessary(MouseButton button, const CPoint& point) { // When the user has clicked and released to give us focus, select all. if (tracking_click_[button] && - !win_util::IsDrag(click_point_[button], point)) { + !app::win::IsDrag(click_point_[button], point)) { // Select all in the reverse direction so as not to scroll the caret // into view and shift the contents jarringly. SelectAll(true); diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 030e1ee..ea9eaca 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -129,7 +129,7 @@ #include <shellapi.h> #include "app/l10n_util_win.h" -#include "app/win_util.h" +#include "app/win/scoped_com_initializer.h" #include "chrome/browser/browser_trial.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/url_fixer_upper.h" @@ -1487,7 +1487,7 @@ int BrowserMain(const MainFunctionParams& parameters) { preconnect_enabled); #if defined(OS_WIN) - win_util::ScopedCOMInitializer com_initializer; + app::win::ScopedCOMInitializer com_initializer; #if defined(GOOGLE_CHROME_BUILD) // Init the RLZ library. This just binds the dll and schedules a task on the diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index bd5573a..7f8154e 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -12,7 +12,7 @@ #include "app/l10n_util.h" #include "app/l10n_util_win.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/command_line.h" #include "base/environment.h" #include "base/i18n/rtl.h" @@ -57,7 +57,7 @@ void WarnAboutMinimumSystemRequirements() { const std::wstring text = l10n_util::GetString(IDS_UNSUPPORTED_OS_PRE_WIN_XP); const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); - win_util::MessageBox(NULL, text, caption, + app::win::MessageBox(NULL, text, caption, MB_OK | MB_ICONWARNING | MB_TOPMOST); } } @@ -75,7 +75,7 @@ void ShowCloseBrowserFirstMessageBox() { const std::wstring text = l10n_util::GetString(IDS_UNINSTALL_CLOSE_APP); const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); const UINT flags = MB_OK | MB_ICONWARNING | MB_TOPMOST; - win_util::MessageBox(NULL, text, caption, flags); + app::win::MessageBox(NULL, text, caption, flags); } int DoUninstallTasks(bool chrome_still_running) { @@ -167,7 +167,7 @@ int HandleIconsCommands(const CommandLine &parsed_command_line) { cp_applet); const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; - if (IDOK == win_util::MessageBox(NULL, msg, caption, flags)) + if (IDOK == app::win::MessageBox(NULL, msg, caption, flags)) ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL); return ResultCodes::NORMAL_EXIT; // Exit as we are not launching browser. } @@ -194,7 +194,7 @@ bool CheckMachineLevelInstall() { l10n_util::GetString(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; - win_util::MessageBox(NULL, text, caption, flags); + app::win::MessageBox(NULL, text, caption, flags); FilePath uninstall_path(InstallUtil::GetChromeUninstallCmd(false, dist)); CommandLine uninstall_cmd(uninstall_path); if (!uninstall_cmd.GetProgram().value().empty()) { diff --git a/chrome/browser/dom_ui/bug_report_ui.cc b/chrome/browser/dom_ui/bug_report_ui.cc index 2641aff..1583243 100644 --- a/chrome/browser/dom_ui/bug_report_ui.cc +++ b/chrome/browser/dom_ui/bug_report_ui.cc @@ -41,7 +41,7 @@ #elif defined(OS_MACOSX) #include "base/mac_util.h" #elif defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #endif #if defined(TOOLKIT_VIEWS) @@ -175,7 +175,7 @@ void RefreshLastScreenshot(NSWindow* window) { #elif defined(OS_MACOSX) mac_util::GrabWindowSnapshot(window, last_screenshot_png, &width, &height); #elif defined(OS_WIN) - win_util::GrabWindowSnapshot(window, last_screenshot_png); + app::win::GrabWindowSnapshot(window, last_screenshot_png); #endif screen_size.set_width(width); diff --git a/chrome/browser/download/base_file.cc b/chrome/browser/download/base_file.cc index 7d84670..9d77233 100644 --- a/chrome/browser/download/base_file.cc +++ b/chrome/browser/download/base_file.cc @@ -13,6 +13,7 @@ #include "chrome/browser/download/download_util.h" #if defined(OS_WIN) +#include "app/win/win_util.h" #include "chrome/common/win_safe_util.h" #elif defined(OS_MACOSX) #include "chrome/browser/ui/cocoa/file_metadata.h" diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc index 035714e..07eb72d 100644 --- a/chrome/browser/download/download_file_manager.cc +++ b/chrome/browser/download/download_file_manager.cc @@ -24,7 +24,6 @@ #include "net/base/io_buffer.h" #if defined(OS_WIN) -#include "app/win_util.h" #include "chrome/common/win_safe_util.h" #elif defined(OS_MACOSX) #include "chrome/browser/ui/cocoa/file_metadata.h" diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index da878b0..69f228e 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -48,10 +48,6 @@ #include "net/base/mime_util.h" #include "net/base/net_util.h" -#if defined(OS_WIN) -#include "app/win_util.h" -#endif - DownloadManager::DownloadManager(DownloadStatusUpdater* status_updater) : shutdown_needed_(false), profile_(NULL), diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 0f84abe..bebfe06 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -71,8 +71,8 @@ #if defined(OS_WIN) #include "app/os_exchange_data_provider_win.h" -#include "app/win_util.h" #include "app/win/drag_source.h" +#include "app/win/win_util.h" #include "base/win/scoped_comptr.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/views/frame/browser_view.h" @@ -248,7 +248,7 @@ void GenerateSafeFileName(const std::string& mime_type, FilePath* file_name) { // Prepend "_" to the file name if it's a reserved name FilePath::StringType leaf_name = file_name->BaseName().value(); DCHECK(!leaf_name.empty()); - if (win_util::IsReservedName(leaf_name)) { + if (app::win::IsReservedName(leaf_name)) { leaf_name = FilePath::StringType(FILE_PATH_LITERAL("_")) + leaf_name; *file_name = file_name->DirName(); if (file_name->value() == FilePath::kCurrentDirectory) { diff --git a/chrome/browser/enumerate_modules_model_win.cc b/chrome/browser/enumerate_modules_model_win.cc index 83dc535..536f4ea 100644 --- a/chrome/browser/enumerate_modules_model_win.cc +++ b/chrome/browser/enumerate_modules_model_win.cc @@ -8,7 +8,7 @@ #include <wintrust.h> #include "app/l10n_util.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/command_line.h" #include "base/environment.h" #include "base/file_path.h" @@ -219,7 +219,7 @@ static void GenerateHash(const std::string& input, std::string* output) { // static void ModuleEnumerator::NormalizeModule(Module* module) { string16 path = module->location; - if (!win_util::ConvertToLongPath(path, &module->location)) + if (!app::win::ConvertToLongPath(path, &module->location)) module->location = path; module->location = l10n_util::ToLower(module->location); diff --git a/chrome/browser/extensions/extensions_startup.cc b/chrome/browser/extensions/extensions_startup.cc index c96d6ee..b44aade 100644 --- a/chrome/browser/extensions/extensions_startup.cc +++ b/chrome/browser/extensions/extensions_startup.cc @@ -12,7 +12,7 @@ #include "chrome/common/chrome_switches.h" #if defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #endif ExtensionsStartupUtil::ExtensionsStartupUtil() : pack_job_succeeded_(false) {} @@ -36,7 +36,7 @@ void ExtensionsStartupUtil::ShowPackExtensionMessage( const std::wstring& caption, const std::wstring& message) { #if defined(OS_WIN) - win_util::MessageBox(NULL, message, caption, MB_OK | MB_SETFOREGROUND); + app::win::MessageBox(NULL, message, caption, MB_OK | MB_SETFOREGROUND); #else // Just send caption & text to stdout on mac & linux. std::string out_text = WideToASCII(caption); diff --git a/chrome/browser/hang_monitor/hung_plugin_action.cc b/chrome/browser/hang_monitor/hung_plugin_action.cc index b7a937c..95025c0 100644 --- a/chrome/browser/hang_monitor/hung_plugin_action.cc +++ b/chrome/browser/hang_monitor/hung_plugin_action.cc @@ -8,7 +8,6 @@ #include "app/l10n_util.h" #include "app/win/hwnd_util.h" -#include "app/win_util.h" #include "chrome/browser/platform_util.h" #include "chrome/common/logging_chrome.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index efa2a0a..34b8cdb 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -16,7 +16,8 @@ #include <vector> #include "app/l10n_util.h" -#include "app/win_util.h" +#include "app/win/scoped_co_mem.h" +#include "app/win/scoped_com_initializer.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/scoped_comptr_win.h" @@ -78,7 +79,7 @@ void IEImporter::StartImport(const ProfileInfo& profile_info, bridge_->NotifyStarted(); // Some IE settings (such as Protected Storage) are obtained via COM APIs. - win_util::ScopedCOMInitializer com_initializer; + app::win::ScopedCOMInitializer com_initializer; if ((items & importer::HOME_PAGE) && !cancelled()) ImportHomepage(); // Doesn't have a UI item. @@ -552,7 +553,7 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, } std::wstring IEImporter::ResolveInternetShortcut(const std::wstring& file) { - win_util::CoMemReleaser<wchar_t> url; + app::win::ScopedCoMem<wchar_t> url; ScopedComPtr<IUniformResourceLocator> url_locator; HRESULT result = url_locator.CreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER); diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 6379e7b..558eb17 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -29,7 +29,7 @@ // TODO(port): Port these files. #if defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #include "chrome/browser/views/importer_lock_view.h" #include "views/window/window.h" #elif defined(OS_MACOSX) @@ -211,7 +211,7 @@ void ImporterHost::StartImportSettings( // credentials. if (profile_info.browser_type == importer::GOOGLE_TOOLBAR5) { if (!toolbar_importer_utils::IsGoogleGAIACookieInstalled()) { - win_util::MessageBox( + app::win::MessageBox( NULL, l10n_util::GetString(IDS_IMPORTER_GOOGLE_LOGIN_TEXT).c_str(), L"", diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index 56ac2cc..d47e9e9 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -17,6 +17,7 @@ #include <vector> +#include "app/win/scoped_com_initializer.h" #include "base/file_util.h" #include "base/message_loop.h" #include "base/path_service.h" @@ -34,7 +35,6 @@ #include "webkit/glue/password_form.h" #if defined(OS_WIN) -#include "app/win_util.h" #include "base/scoped_comptr_win.h" #include "chrome/browser/importer/ie_importer.h" #include "chrome/browser/password_manager/ie7_password.h" @@ -357,7 +357,7 @@ void WritePStore(IPStore* pstore, const GUID* type, const GUID* subtype) { TEST_F(ImporterTest, IEImporter) { // Sets up a favorites folder. - win_util::ScopedCOMInitializer com_init; + app::win::ScopedCOMInitializer com_init; std::wstring path = test_path_.ToWStringHack(); file_util::AppendToPath(&path, L"Favorites"); CreateDirectory(path.c_str(), NULL); diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index 9672d02..f03f653 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -9,8 +9,9 @@ #include <shellapi.h> #include <shlobj.h> +#include "app/win/scoped_co_mem.h" #include "app/win/shell.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" @@ -68,14 +69,14 @@ void ShowItemInFolder(const FilePath& full_path) { if (FAILED(hr)) return; - win_util::CoMemReleaser<ITEMIDLIST> dir_item; + app::win::ScopedCoMem<ITEMIDLIST> dir_item; hr = desktop->ParseDisplayName(NULL, NULL, const_cast<wchar_t *>(dir.value().c_str()), NULL, &dir_item, NULL); if (FAILED(hr)) return; - win_util::CoMemReleaser<ITEMIDLIST> file_item; + app::win::ScopedCoMem<ITEMIDLIST> file_item; hr = desktop->ParseDisplayName(NULL, NULL, const_cast<wchar_t *>(full_path.value().c_str()), NULL, &file_item, NULL); @@ -161,13 +162,13 @@ bool IsVisible(gfx::NativeView view) { void SimpleErrorBox(gfx::NativeWindow parent, const string16& title, const string16& message) { - win_util::MessageBox(parent, message, title, MB_OK | MB_SETFOREGROUND); + app::win::MessageBox(parent, message, title, MB_OK | MB_SETFOREGROUND); } bool SimpleYesNoBox(gfx::NativeWindow parent, const string16& title, const string16& message) { - return win_util::MessageBox(parent, message.c_str(), title.c_str(), + return app::win::MessageBox(parent, message.c_str(), title.c_str(), MB_YESNO | MB_ICONWARNING | MB_SETFOREGROUND) == IDYES; } diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index cacbff6..a1d8f60 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -6,7 +6,6 @@ #include "app/l10n_util.h" #include "app/win/hwnd_util.h" -#include "app/win_util.h" #include "base/base_paths.h" #include "base/command_line.h" #include "base/file_path.h" diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index e3849fb..886111c 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -95,7 +95,8 @@ #include "webkit/plugins/plugin_switches.h" #if defined(OS_WIN) -#include "app/win_util.h" +#include <objbase.h> +#include "app/win/win_util.h" #endif using WebKit::WebCache; @@ -910,7 +911,7 @@ TransportDIB* BrowserRenderProcessHost::MapTransportDIB( TransportDIB::Id dib_id) { #if defined(OS_WIN) // On Windows we need to duplicate the handle from the remote process - HANDLE section = win_util::GetSectionFromProcess( + HANDLE section = app::win::GetSectionFromProcess( dib_id.handle, GetHandle(), false /* read write */); return TransportDIB::Map(section); #elif defined(OS_MACOSX) diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc index 80c609b..1844f67 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.cc +++ b/chrome/browser/tab_contents/thumbnail_generator.cc @@ -23,7 +23,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #if defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #endif // Overview @@ -205,7 +205,7 @@ void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer, // Duplicate the handle to the DIB here because the renderer process does not // have permission. The duplicated handle is owned by the renderer process, // which is responsible for closing it. - TransportDIB::Handle renderer_dib_handle = win_util::GetSectionForProcess( + TransportDIB::Handle renderer_dib_handle = app::win::GetSectionForProcess( thumbnail_dib->handle(), renderer->process()->GetHandle(), false); diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 8835996..98b481d 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -72,10 +72,6 @@ #include "chrome/browser/ui/cocoa/keystone_infobar.h" #endif -#if defined(OS_WIN) -#include "app/win_util.h" -#endif - #if defined(TOOLKIT_GTK) #include "chrome/browser/gtk/gtk_util.h" #endif diff --git a/chrome/browser/ui/views/constrained_window_win.cc b/chrome/browser/ui/views/constrained_window_win.cc index fea24e2..121605f 100644 --- a/chrome/browser/ui/views/constrained_window_win.cc +++ b/chrome/browser/ui/views/constrained_window_win.cc @@ -6,7 +6,7 @@ #include "app/resource_bundle.h" #include "app/win/hwnd_util.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -544,7 +544,7 @@ void ConstrainedWindowFrameView::InitWindowResources() { void ConstrainedWindowFrameView::InitClass() { static bool initialized = false; if (!initialized) { - title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); + title_font_ = new gfx::Font(app::win::GetWindowTitleFont()); initialized = true; } } diff --git a/chrome/browser/ui/views/extensions/extension_install_prompt.cc b/chrome/browser/ui/views/extensions/extension_install_prompt.cc index 1e1ea37..bf04056 100644 --- a/chrome/browser/ui/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/ui/views/extensions/extension_install_prompt.cc @@ -21,10 +21,6 @@ #include "views/window/dialog_delegate.h" #include "views/window/window.h" -#if defined(OS_WIN) -#include "app/win_util.h" -#endif - class Profile; namespace { diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index 2bbe2c9..f1ef85d 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -10,7 +10,7 @@ #include <set> #include "app/win/hwnd_util.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/browser_list.h" @@ -19,6 +19,7 @@ #include "chrome/browser/views/frame/browser_root_view.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/frame/glass_browser_frame_view.h" +#include "gfx/font.h" #include "grit/theme_resources.h" #include "views/screen.h" #include "views/window/window_delegate.h" @@ -40,7 +41,7 @@ BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, // static const gfx::Font& BrowserFrame::GetTitleFont() { - static gfx::Font* title_font = new gfx::Font(win_util::GetWindowTitleFont()); + static gfx::Font* title_font = new gfx::Font(app::win::GetWindowTitleFont()); return *title_font; } diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index f00aef8..e8d65f7 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -83,7 +83,7 @@ #if defined(OS_WIN) #include "app/view_prop.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "chrome/browser/aeropeek_manager.h" #include "chrome/browser/jumplist_win.h" #elif defined(OS_LINUX) @@ -1128,7 +1128,7 @@ void BrowserView::ShowProfileErrorDialog(int message_id) { #if defined(OS_WIN) std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); std::wstring message = l10n_util::GetString(message_id); - win_util::MessageBox(GetNativeHandle(), message, title, + app::win::MessageBox(GetNativeHandle(), message, title, MB_OK | MB_ICONWARNING | MB_TOPMOST); #elif defined(OS_LINUX) std::string title = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc index 01a5344..a33bc8f 100644 --- a/chrome/browser/ui/views/tabs/base_tab.cc +++ b/chrome/browser/ui/views/tabs/base_tab.cc @@ -26,10 +26,6 @@ #include "grit/theme_resources.h" #include "views/controls/button/image_button.h" -#ifdef WIN32 -#include "app/win_util.h" -#endif - // How long the pulse throb takes. static const int kPulseDurationMs = 200; diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.cc b/chrome/browser/ui/views/tabs/base_tab_strip.cc index 3035d30..a013d68 100644 --- a/chrome/browser/ui/views/tabs/base_tab_strip.cc +++ b/chrome/browser/ui/views/tabs/base_tab_strip.cc @@ -12,7 +12,6 @@ #include "views/window/window.h" #if defined(OS_WIN) -#include "app/win_util.h" #include "views/widget/widget_win.h" #endif diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index d8e03f2..a4430ef 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -28,7 +28,7 @@ #include "views/window/window.h" #if defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #include "views/widget/widget_win.h" #elif defined(OS_LINUX) #include "views/widget/widget_gtk.h" @@ -687,7 +687,7 @@ gfx::Rect TabStrip::GetDropBounds(int drop_index, // If the rect doesn't fit on the monitor, push the arrow to the bottom. #if defined(OS_WIN) - gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(drop_bounds); + gfx::Rect monitor_bounds = app::win::GetMonitorBoundsForRect(drop_bounds); *is_beneath = (monitor_bounds.IsEmpty() || !monitor_bounds.Contains(drop_bounds)); #else diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc index 8207db6..062c43b 100644 --- a/chrome/common/chrome_paths_win.cc +++ b/chrome/common/chrome_paths_win.cc @@ -10,7 +10,7 @@ #include <shlobj.h> #include <shobjidl.h> -#include "app/win_util.h" +#include "app/win/scoped_co_mem.h" #include "base/file_path.h" #include "base/path_service.h" #include "chrome/common/chrome_constants.h" @@ -73,7 +73,7 @@ bool GetUserDownloadsDirectory(FilePath* result) { REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR*); GetKnownFolderPath f = reinterpret_cast<GetKnownFolderPath>( GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetKnownFolderPath")); - win_util::CoMemReleaser<wchar_t> path_buf; + app::win::ScopedCoMem<wchar_t> path_buf; if (f && SUCCEEDED(f(FOLDERID_Downloads, 0, NULL, &path_buf))) { *result = FilePath(std::wstring(path_buf)); return true; diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc index 2667cf9..be6cc3b 100644 --- a/chrome/common/sandbox_policy.cc +++ b/chrome/common/sandbox_policy.cc @@ -6,7 +6,7 @@ #include <string> -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/command_line.h" #include "base/debug/debugger.h" #include "base/debug/trace_event.h" @@ -200,9 +200,15 @@ bool AddGenericPolicy(sandbox::TargetPolicy* policy) { FilePath app_dir; if (!PathService::Get(chrome::DIR_APP, &app_dir)) return false; - std::wstring debug_message; - if (!win_util::ConvertToLongPath(app_dir.value(), &debug_message)) + + wchar_t long_path_buf[MAX_PATH]; + DWORD long_path_return_value = GetLongPathName(app_dir.value().c_str(), + long_path_buf, + MAX_PATH); + if (long_path_return_value == 0 || long_path_return_value >= MAX_PATH) return false; + + string16 debug_message(long_path_buf); file_util::AppendToPath(&debug_message, L"debug_message.exe"); result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, sandbox::TargetPolicy::PROCESS_MIN_EXEC, diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc index 5c8f27f..5d0e090 100644 --- a/chrome/gpu/gpu_main.cc +++ b/chrome/gpu/gpu_main.cc @@ -7,6 +7,7 @@ #include "app/app_switches.h" #include "app/gfx/gl/gl_context.h" #include "app/gfx/gl/gl_implementation.h" +#include "app/win/scoped_com_initializer.h" #include "base/environment.h" #include "base/message_loop.h" #include "base/stringprintf.h" @@ -30,10 +31,6 @@ #include "chrome/common/sandbox_mac.h" #endif -#if defined(OS_WIN) -#include "app/win_util.h" -#endif - #if defined(USE_X11) #include "gfx/gtk_util.h" #endif @@ -77,9 +74,7 @@ int GpuMain(const MainFunctionParams& parameters) { MessageLoop main_message_loop(MessageLoop::TYPE_UI); base::PlatformThread::SetName("CrGpuMain"); -#if defined(OS_WIN) - win_util::ScopedCOMInitializer com_initializer; -#endif + app::win::ScopedCOMInitializer com_initializer; #if defined(USE_X11) // The X11 port of the command buffer code assumes it can access the X diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc index 0c64e89..c72de9e 100644 --- a/chrome/gpu/gpu_thread.cc +++ b/chrome/gpu/gpu_thread.cc @@ -8,6 +8,7 @@ #include <vector> #include "app/gfx/gl/gl_context.h" +#include "app/win/scoped_com_initializer.h" #include "base/command_line.h" #include "base/threading/worker_pool.h" #include "build/build_config.h" @@ -17,10 +18,6 @@ #include "chrome/gpu/gpu_info_collector.h" #include "ipc/ipc_channel_handle.h" -#if defined(OS_WIN) -#include "app/win_util.h" -#endif - GpuThread::GpuThread() { } @@ -159,7 +156,7 @@ void GpuThread::OnHang() { // Runs on a worker thread. The GpuThread never terminates voluntarily so it is // safe to assume that its message loop is valid. void GpuThread::CollectDxDiagnostics(GpuThread* thread) { - win_util::ScopedCOMInitializer com_initializer; + app::win::ScopedCOMInitializer com_initializer; DxDiagNode node; gpu_info_collector::GetDxDiagnostics(&node); diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 498df98..1d7a077 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -6,14 +6,7 @@ #include "build/build_config.h" -#if defined(OS_WIN) -#include "app/win_util.h" -#endif #include "base/lazy_instance.h" -#if defined(OS_MACOSX) -#include "base/mac_util.h" -#include "base/mac/scoped_cftyperef.h" -#endif #include "base/scoped_handle.h" #include "base/shared_memory.h" #include "build/build_config.h" @@ -24,17 +17,22 @@ #include "chrome/plugin/npobject_util.h" #include "chrome/plugin/plugin_channel.h" #include "chrome/plugin/plugin_thread.h" +#include "gfx/blit.h" +#include "gfx/canvas.h" +#include "skia/ext/platform_device.h" +#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" +#include "webkit/plugins/npapi/webplugin_delegate_impl.h" + #if defined(OS_MACOSX) +#include "base/mac_util.h" +#include "base/mac/scoped_cftyperef.h" #include "chrome/plugin/webplugin_accelerated_surface_proxy_mac.h" #endif -#include "gfx/blit.h" -#include "gfx/canvas.h" + #if defined(OS_WIN) +#include "app/win/win_util.h" #include "gfx/gdi_util.h" #endif -#include "skia/ext/platform_device.h" -#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" -#include "webkit/plugins/npapi/webplugin_delegate_impl.h" #if defined(USE_X11) #include "app/x11_util_internal.h" @@ -538,7 +536,7 @@ void WebPluginProxy::SetWindowlessBuffer( window_rect.width(), window_rect.height(), true, - win_util::GetSectionFromProcess(windowless_buffer, + app::win::GetSectionFromProcess(windowless_buffer, channel_->renderer_handle(), false))) { windowless_canvas_.reset(); background_canvas_.reset(); @@ -551,7 +549,7 @@ void WebPluginProxy::SetWindowlessBuffer( window_rect.width(), window_rect.height(), true, - win_util::GetSectionFromProcess(background_buffer, + app::win::GetSectionFromProcess(background_buffer, channel_->renderer_handle(), false))) { windowless_canvas_.reset(); background_canvas_.reset(); diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 0d6c15b..0abae79 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -10,7 +10,7 @@ #include "app/app_paths.h" #include "app/resource_bundle.h" -#include "app/win_util.h" +#include "app/win/scoped_com_initializer.h" #include "base/command_line.h" #include "base/debug_util.h" #include "base/file_util.h" @@ -269,7 +269,7 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { if (!ShouldLaunchBrowser()) return; - win_util::ScopedCOMInitializer com; + app::win::ScopedCOMInitializer com; chrome_frame_test::CloseAllIEWindows(); test_http_server_.reset(new test_server::SimpleWebServer(kTestServerPort)); @@ -291,7 +291,7 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { void CFUrlRequestUnittestRunner::ShutDownHostBrowser() { if (ShouldLaunchBrowser()) { - win_util::ScopedCOMInitializer com; + app::win::ScopedCOMInitializer com; chrome_frame_test::CloseAllIEWindows(); } } diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index 0059571..a9b4ec5 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -4,7 +4,7 @@ #include <atlbase.h> #include <atlcom.h> -#include "app/win_util.h" +#include "app/win/scoped_com_initializer.h" #include "chrome_frame/test/test_server.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gmock/include/gmock/gmock.h" @@ -73,7 +73,7 @@ TEST(UrlmonUrlRequestTest, Simple1) { chrome_frame_test::GetTestDataFolder()); mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); - win_util::ScopedCOMInitializer init_com; + app::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); @@ -121,7 +121,7 @@ TEST(UrlmonUrlRequestTest, Head) { test_server::SimpleResponse head_response("/head", ""); server.AddResponse(&head_response); - win_util::ScopedCOMInitializer init_com; + app::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); @@ -157,7 +157,7 @@ TEST(UrlmonUrlRequestTest, Head) { TEST(UrlmonUrlRequestTest, UnreachableUrl) { MockUrlDelegate mock; chrome_frame_test::TimedMsgLoop loop; - win_util::ScopedCOMInitializer init_com; + app::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1", @@ -202,7 +202,7 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) { chrome_frame_test::GetTestDataFolder()); mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); - win_util::ScopedCOMInitializer init_com; + app::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); diff --git a/printing/printed_document_win.cc b/printing/printed_document_win.cc index d157aef..892de34 100644 --- a/printing/printed_document_win.cc +++ b/printing/printed_document_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 "printing/printed_document.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/logging.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -121,9 +121,9 @@ void PrintedDocument::Immutable::SetDocumentDate() { SYSTEMTIME systemtime; GetLocalTime(&systemtime); date_ = - WideToUTF16Hack(win_util::FormatSystemDate(systemtime, std::wstring())); + WideToUTF16Hack(app::win::FormatSystemDate(systemtime, std::wstring())); time_ = - WideToUTF16Hack(win_util::FormatSystemTime(systemtime, std::wstring())); + WideToUTF16Hack(app::win::FormatSystemTime(systemtime, std::wstring())); } void PrintedDocument::DrawHeaderFooter(gfx::NativeDrawingContext context, diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index d559592..581e40f 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -11,7 +11,7 @@ #include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/i18n/rtl.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -644,7 +644,7 @@ void NativeTextfieldWin::OnLButtonDown(UINT keys, const CPoint& point) { // double_click_time_ from the current message's time even if the timer has // wrapped in between. const bool is_triple_click = tracking_double_click_ && - win_util::IsDoubleClick(double_click_point_, point, + app::win::IsDoubleClick(double_click_point_, point, GetCurrentMessage()->time - double_click_time_); tracking_double_click_ = false; diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 68c0f1c..89959cc 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -21,7 +21,7 @@ #if defined(OS_LINUX) #include "app/keyboard_code_conversion_gtk.h" #elif defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/win/win_util.h" // TODO(beng): this should be removed when the OS_WIN hack from // ViewHierarchyChanged is removed. @@ -279,7 +279,7 @@ bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { // We don't translate accelerators for ALT + NumPad digit on Windows, they are // used for entering special characters. We do translate alt-home. if (e.IsAltDown() && (key != app::VKEY_HOME) && - win_util::IsNumPadDigit(key, e.IsExtendedKey())) + app::win::IsNumPadDigit(key, e.IsExtendedKey())) return true; #endif return false; diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc index 8e51e64..b7b3a09 100644 --- a/views/widget/tooltip_manager_win.cc +++ b/views/widget/tooltip_manager_win.cc @@ -8,7 +8,7 @@ #include <limits> #include "app/l10n_util_win.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/i18n/rtl.h" #include "base/logging.h" #include "base/message_loop.h" @@ -228,7 +228,7 @@ bool TooltipManagerWin::SetTooltipPosition(int text_x, int text_y) { // doesn't, return false so that windows positions the tooltip at the // default location. gfx::Rect monitor_bounds = - win_util::GetMonitorBoundsForRect(gfx::Rect(bounds.left,bounds.right, + app::win::GetMonitorBoundsForRect(gfx::Rect(bounds.left,bounds.right, 0, 0)); if (!monitor_bounds.Contains(gfx::Rect(bounds))) { return false; @@ -356,7 +356,7 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) { screen_point.y() + focused_bounds.height() + line_count * tooltip_height_ }; gfx::Rect monitor_bounds = - win_util::GetMonitorBoundsForRect(gfx::Rect(rect_bounds)); + app::win::GetMonitorBoundsForRect(gfx::Rect(rect_bounds)); rect_bounds = gfx::Rect(rect_bounds).AdjustToFit(monitor_bounds).ToRECT(); ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, rect_bounds.top, 0, 0, diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index a5ea141..8bf6a3f 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -9,7 +9,7 @@ #include "app/system_monitor.h" #include "app/view_prop.h" #include "app/win/hwnd_util.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/string_util.h" #include "gfx/canvas_skia.h" #include "gfx/native_theme_win.h" @@ -389,7 +389,7 @@ bool WidgetWin::IsVisible() const { } bool WidgetWin::IsActive() const { - return win_util::IsWindowActive(hwnd()); + return app::win::IsWindowActive(hwnd()); } bool WidgetWin::IsAccessibleWidget() const { diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index 97287e1..002bb37 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -6,9 +6,6 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" -#if defined(OS_WIN) -#include "app/win_util.h" -#endif #include "gfx/canvas.h" #include "gfx/font.h" #include "gfx/path.h" @@ -16,10 +13,15 @@ #include "grit/app_strings.h" #include "views/window/client_view.h" #include "views/window/window_shape.h" +#include "views/window/window_delegate.h" + #if defined(OS_LINUX) #include "views/window/hit_test.h" #endif -#include "views/window/window_delegate.h" + +#if defined(OS_WIN) +#include "app/win/win_util.h" +#endif namespace views { @@ -566,7 +568,7 @@ void CustomFrameView::InitClass() { static bool initialized = false; if (!initialized) { #if defined(OS_WIN) - title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); + title_font_ = new gfx::Font(app::win::GetWindowTitleFont()); #elif defined(OS_LINUX) // TODO(ben): need to resolve what font this is. title_font_ = new gfx::Font(); diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 664e17f..c0f4523 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -10,7 +10,7 @@ #include "app/keyboard_code_conversion_win.h" #include "app/theme_provider.h" #include "app/win/hwnd_util.h" -#include "app/win_util.h" +#include "app/win/win_util.h" #include "base/i18n/rtl.h" #include "base/win/windows_version.h" #include "gfx/canvas_skia_paint.h" @@ -88,7 +88,7 @@ void SetChildBounds(HWND child_window, HWND parent_window, } gfx::Rect actual_bounds = bounds; - win_util::EnsureRectIsVisibleInRect(gfx::Rect(parent_rect), &actual_bounds, + app::win::EnsureRectIsVisibleInRect(gfx::Rect(parent_rect), &actual_bounds, padding); SetWindowPos(child_window, insert_after_window, actual_bounds.x(), @@ -843,9 +843,9 @@ LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { return 0; } } - if (win_util::EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) - client_rect->left += win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { + if (app::win::EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) + client_rect->left += app::win::kAutoHideTaskbarThicknessPx; + if (app::win::EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { if (GetNonClientView()->UseNativeFrame()) { // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of // WM_NCHITTEST, having any nonclient area atop the window causes the @@ -858,13 +858,13 @@ LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { // be no better solution. --client_rect->bottom; } else { - client_rect->top += win_util::kAutoHideTaskbarThicknessPx; + client_rect->top += app::win::kAutoHideTaskbarThicknessPx; } } - if (win_util::EdgeHasTopmostAutoHideTaskbar(ABE_RIGHT, monitor)) - client_rect->right -= win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasTopmostAutoHideTaskbar(ABE_BOTTOM, monitor)) - client_rect->bottom -= win_util::kAutoHideTaskbarThicknessPx; + if (app::win::EdgeHasTopmostAutoHideTaskbar(ABE_RIGHT, monitor)) + client_rect->right -= app::win::kAutoHideTaskbarThicknessPx; + if (app::win::EdgeHasTopmostAutoHideTaskbar(ABE_BOTTOM, monitor)) + client_rect->bottom -= app::win::kAutoHideTaskbarThicknessPx; // We cannot return WVR_REDRAW when there is nonclient area, or Windows // exhibits bugs where client pixels and child HWNDs are mispositioned by diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm index 3cc812b..3ce3369 100644 --- a/webkit/tools/test_shell/mac/webwidget_host.mm +++ b/webkit/tools/test_shell/mac/webwidget_host.mm @@ -41,7 +41,7 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, host->view_ = [[NSView alloc] initWithFrame:content_rect]; [parent_view addSubview:host->view_]; - // win_util::SetWindowUserData(host->hwnd_, host); + // app::win::SetWindowUserData(host->hwnd_, host); host->webwidget_ = WebPopupMenu::create(client); host->webwidget_->resize(WebSize(content_rect.size.width, @@ -154,7 +154,7 @@ WebWidgetHost::WebWidgetHost() } WebWidgetHost::~WebWidgetHost() { - // win_util::SetWindowUserData(hwnd_, 0); + // app::win::SetWindowUserData(hwnd_, 0); webwidget_->close(); } |