summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 21:16:15 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 21:16:15 +0000
commitdf80961a3adc894a49c2a633c05570ea448eed05 (patch)
treeebe737a060d043c0ecf9531e8864de37cc5ed146
parent2bad4d4829c6f6e4bd6390ef56e773fc0f18f943 (diff)
downloadchromium_src-df80961a3adc894a49c2a633c05570ea448eed05.zip
chromium_src-df80961a3adc894a49c2a633c05570ea448eed05.tar.gz
chromium_src-df80961a3adc894a49c2a633c05570ea448eed05.tar.bz2
Make the SetCursorResourceModuleName function in the CursorLoaderWin class a static function and remove it from the
CursorLoader and CursorClient interface. This function is currently called from the ctor of the ChromeContentBrowserClient class which ensures that it happens when the browser starts up and avoids any race conditions due to code attempting to read the module name before it was set. This ensures that the non standard webkit cursors can be loaded correctly when needed. Fixes bug https://code.google.com/p/chromium/issues/detail?id=257983 Bug=257983 R=sky@chromium.org Review URL: https://codereview.chromium.org/18132011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210625 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/ash_native_cursor_manager.cc6
-rw-r--r--ash/wm/ash_native_cursor_manager.h2
-rw-r--r--ash/wm/ash_native_cursor_manager_unittest.cc5
-rw-r--r--ash/wm/image_cursors.cc4
-rw-r--r--ash/wm/image_cursors.h3
-rw-r--r--chrome/browser/chrome_content_browser_client.cc7
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc7
-rw-r--r--ui/aura/client/cursor_client.h4
-rw-r--r--ui/aura/test/test_cursor_client.cc3
-rw-r--r--ui/aura/test/test_cursor_client.h1
-rw-r--r--ui/base/cursor/cursor_loader.h4
-rw-r--r--ui/base/cursor/cursor_loader_null.cc1
-rw-r--r--ui/base/cursor/cursor_loader_win.cc12
-rw-r--r--ui/base/cursor/cursor_loader_win.h8
-rw-r--r--ui/base/cursor/cursor_loader_x11.h2
-rw-r--r--ui/views/corewm/cursor_manager.cc4
-rw-r--r--ui/views/corewm/cursor_manager.h1
-rw-r--r--ui/views/corewm/cursor_manager_unittest.cc3
-rw-r--r--ui/views/corewm/native_cursor_manager.h4
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc5
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_cursor_manager.h1
21 files changed, 23 insertions, 64 deletions
diff --git a/ash/wm/ash_native_cursor_manager.cc b/ash/wm/ash_native_cursor_manager.cc
index a52858f..4f2f39e 100644
--- a/ash/wm/ash_native_cursor_manager.cc
+++ b/ash/wm/ash_native_cursor_manager.cc
@@ -119,10 +119,4 @@ void AshNativeCursorManager::SetMouseEventsEnabled(
NotifyMouseEventsEnableStateChange(enabled);
}
-void AshNativeCursorManager::SetCursorResourceModule(
- const base::string16& module_name) {
- image_cursors_->SetCursorResourceModule(module_name);
-}
-
-
} // namespace ash
diff --git a/ash/wm/ash_native_cursor_manager.h b/ash/wm/ash_native_cursor_manager.h
index 60eec94..5ea9ec9 100644
--- a/ash/wm/ash_native_cursor_manager.h
+++ b/ash/wm/ash_native_cursor_manager.h
@@ -52,8 +52,6 @@ class ASH_EXPORT AshNativeCursorManager
virtual void SetMouseEventsEnabled(
bool enabled,
views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE;
- virtual void SetCursorResourceModule(
- const base::string16& module_name) OVERRIDE;
// The cursor location where the cursor was disabled.
gfx::Point disabled_cursor_location_;
diff --git a/ash/wm/ash_native_cursor_manager_unittest.cc b/ash/wm/ash_native_cursor_manager_unittest.cc
index f8160e4..bd748ed 100644
--- a/ash/wm/ash_native_cursor_manager_unittest.cc
+++ b/ash/wm/ash_native_cursor_manager_unittest.cc
@@ -16,6 +16,7 @@
#if defined(OS_WIN)
#include "base/win/windows_version.h"
+#include "ui/base/cursor/cursor_loader_win.h"
#endif
using views::corewm::CursorManager;
@@ -57,7 +58,7 @@ TEST_F(AshNativeCursorManagerTest, LockCursor) {
CursorManagerTestApi test_api(cursor_manager);
gfx::Display display(0);
#if defined(OS_WIN)
- cursor_manager->SetCursorResourceModule(L"ash_unittests.exe");
+ ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe");
#endif
cursor_manager->SetCursor(ui::kCursorCopy);
EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
@@ -105,7 +106,7 @@ TEST_F(AshNativeCursorManagerTest, SetCursor) {
CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
CursorManagerTestApi test_api(cursor_manager);
#if defined(OS_WIN)
- cursor_manager->SetCursorResourceModule(L"ash_unittests.exe");
+ ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe");
#endif
cursor_manager->SetCursor(ui::kCursorCopy);
EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
diff --git a/ash/wm/image_cursors.cc b/ash/wm/image_cursors.cc
index d89cfa7..33b3582 100644
--- a/ash/wm/image_cursors.cc
+++ b/ash/wm/image_cursors.cc
@@ -137,8 +137,4 @@ void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) {
cursor_loader_->SetPlatformCursor(cursor);
}
-void ImageCursors::SetCursorResourceModule(const base::string16& module_name) {
- cursor_loader_->SetCursorResourceModule(module_name);
-}
-
} // namespace ash
diff --git a/ash/wm/image_cursors.h b/ash/wm/image_cursors.h
index 8f0ab2b..72c004f 100644
--- a/ash/wm/image_cursors.h
+++ b/ash/wm/image_cursors.h
@@ -43,9 +43,6 @@ class ASH_EXPORT ImageCursors {
// Sets the platform cursor based on the native type of |cursor|.
void SetPlatformCursor(gfx::NativeCursor* cursor);
- // Sets the cursor resource module name for non system cursors.
- void SetCursorResourceModule(const base::string16& module_name);
-
private:
// Reloads the all loaded cursors in the cursor loader.
void ReloadCursors();
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 5abfa6c..a33e0e5 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -143,6 +143,9 @@
#if defined(OS_WIN)
#include "chrome/browser/chrome_browser_main_win.h"
#include "sandbox/win/src/sandbox_policy.h"
+#if defined(USE_AURA)
+#include "ui/base/cursor/cursor_loader_win.h"
+#endif
#elif defined(OS_MACOSX)
#include "chrome/browser/chrome_browser_main_mac.h"
#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
@@ -506,6 +509,10 @@ ChromeContentBrowserClient::ChromeContentBrowserClient() {
permissions_policy_delegate_.reset(
new extensions::BrowserPermissionsPolicyDelegate());
+
+#if defined(OS_WIN) && defined(USE_AURA)
+ ui::CursorLoaderWin::SetCursorResourceModule(GetResourceDllName());
+#endif
}
ChromeContentBrowserClient::~ChromeContentBrowserClient() {
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index c40223e..b521087 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -2904,13 +2904,6 @@ void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root_window);
if (cursor_client) {
-#if defined(OS_WIN)
- if (GetContentClient() && GetContentClient()->browser() &&
- GetContentClient()->browser()->GetResourceDllName()) {
- cursor_client->SetCursorResourceModule(
- GetContentClient()->browser()->GetResourceDllName());
- }
-#endif
cursor_client->SetCursor(cursor);
}
}
diff --git a/ui/aura/client/cursor_client.h b/ui/aura/client/cursor_client.h
index 4769cea..acdf255 100644
--- a/ui/aura/client/cursor_client.h
+++ b/ui/aura/client/cursor_client.h
@@ -60,10 +60,6 @@ class AURA_EXPORT CursorClient {
// EnableMouseEvents/DisableMouseEvents.
virtual void UnlockCursor() = 0;
- // Used to pass the cursor resource module name to the cursor loader. This is
- // typically used to load non system cursors.
- virtual void SetCursorResourceModule(const base::string16& module_name) = 0;
-
// Used to add or remove a CursorClientObserver.
virtual void AddObserver(CursorClientObserver* observer) = 0;
virtual void RemoveObserver(CursorClientObserver* observer) = 0;
diff --git a/ui/aura/test/test_cursor_client.cc b/ui/aura/test/test_cursor_client.cc
index 21e8e33..b82abbf 100644
--- a/ui/aura/test/test_cursor_client.cc
+++ b/ui/aura/test/test_cursor_client.cc
@@ -63,9 +63,6 @@ void TestCursorClient::LockCursor() {
void TestCursorClient::UnlockCursor() {
}
-void TestCursorClient::SetCursorResourceModule(const string16& module_name) {
-}
-
void TestCursorClient::AddObserver(
aura::client::CursorClientObserver* observer) {
observers_.AddObserver(observer);
diff --git a/ui/aura/test/test_cursor_client.h b/ui/aura/test/test_cursor_client.h
index e4b364b..62ccf7f 100644
--- a/ui/aura/test/test_cursor_client.h
+++ b/ui/aura/test/test_cursor_client.h
@@ -29,7 +29,6 @@ class TestCursorClient : public aura::client::CursorClient {
virtual void SetDisplay(const gfx::Display& display) OVERRIDE;
virtual void LockCursor() OVERRIDE;
virtual void UnlockCursor() OVERRIDE;
- virtual void SetCursorResourceModule(const string16& module_name) OVERRIDE;
virtual void AddObserver(
aura::client::CursorClientObserver* observer) OVERRIDE;
virtual void RemoveObserver(
diff --git a/ui/base/cursor/cursor_loader.h b/ui/base/cursor/cursor_loader.h
index f8a8a53..d54d298 100644
--- a/ui/base/cursor/cursor_loader.h
+++ b/ui/base/cursor/cursor_loader.h
@@ -60,10 +60,6 @@ class UI_EXPORT CursorLoader {
// Sets the platform cursor based on the native type of |cursor|.
virtual void SetPlatformCursor(gfx::NativeCursor* cursor) = 0;
- // Used to pass the cursor resource module name to the cursor loader. This is
- // typically used to load non system cursors.
- virtual void SetCursorResourceModule(const string16& module_name) = 0;
-
// Creates a CursorLoader.
static CursorLoader* Create();
diff --git a/ui/base/cursor/cursor_loader_null.cc b/ui/base/cursor/cursor_loader_null.cc
index ec1dde3..51ced4c 100644
--- a/ui/base/cursor/cursor_loader_null.cc
+++ b/ui/base/cursor/cursor_loader_null.cc
@@ -21,6 +21,5 @@ void CursorLoaderNull::LoadAnimatedCursor(int id,
int frame_delay_ms) {}
void CursorLoaderNull::UnloadAll() {}
void CursorLoaderNull::SetPlatformCursor(gfx::NativeCursor* cursor) {}
-void CursorLoaderNull::SetCursorResourceModule(const string16& module_name) {}
} // namespace ui
diff --git a/ui/base/cursor/cursor_loader_win.cc b/ui/base/cursor/cursor_loader_win.cc
index 95738be..f8aa3a4 100644
--- a/ui/base/cursor/cursor_loader_win.cc
+++ b/ui/base/cursor/cursor_loader_win.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/lazy_instance.h"
+#include "base/strings/string16.h"
#include "ui/base/cursor/cursor_loader_win.h"
#include "grit/ui_unscaled_resources.h"
@@ -11,6 +13,8 @@ namespace ui {
namespace {
+base::LazyInstance<string16> g_cursor_resource_module_name;
+
const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) {
switch (native_cursor.native_type()) {
case kCursorNull:
@@ -148,9 +152,10 @@ void CursorLoaderWin::SetPlatformCursor(gfx::NativeCursor* cursor) {
} else {
const wchar_t* cursor_id = GetCursorId(*cursor);
PlatformCursor platform_cursor = LoadCursor(NULL, cursor_id);
- if (!platform_cursor && !cursor_resource_module_name_.empty()) {
+ if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) {
platform_cursor = LoadCursor(
- GetModuleHandle(cursor_resource_module_name_.c_str()), cursor_id);
+ GetModuleHandle(g_cursor_resource_module_name.Get().c_str()),
+ cursor_id);
}
cursor->SetPlatformCursor(platform_cursor);
}
@@ -158,8 +163,9 @@ void CursorLoaderWin::SetPlatformCursor(gfx::NativeCursor* cursor) {
#endif
}
+// static
void CursorLoaderWin::SetCursorResourceModule(const string16& module_name) {
- cursor_resource_module_name_ = module_name;
+ g_cursor_resource_module_name.Get() = module_name;
}
} // namespace ui
diff --git a/ui/base/cursor/cursor_loader_win.h b/ui/base/cursor/cursor_loader_win.h
index 7e1ff60..362486e 100644
--- a/ui/base/cursor/cursor_loader_win.h
+++ b/ui/base/cursor/cursor_loader_win.h
@@ -6,7 +6,6 @@
#define UI_BASE_CURSOR_CURSOR_LOADER_WIN_H_
#include "base/compiler_specific.h"
-#include "base/strings/string16.h"
#include "ui/base/cursor/cursor_loader.h"
namespace ui {
@@ -26,11 +25,12 @@ class UI_EXPORT CursorLoaderWin : public CursorLoader {
int frame_delay_ms) OVERRIDE;
virtual void UnloadAll() OVERRIDE;
virtual void SetPlatformCursor(gfx::NativeCursor* cursor) OVERRIDE;
- virtual void SetCursorResourceModule(const string16& module_name) OVERRIDE;
- private:
- string16 cursor_resource_module_name_;
+ // Used to pass the cursor resource module name to the cursor loader. This is
+ // typically used to load non system cursors.
+ static void SetCursorResourceModule(const string16& module_name);
+ private:
DISALLOW_COPY_AND_ASSIGN(CursorLoaderWin);
};
diff --git a/ui/base/cursor/cursor_loader_x11.h b/ui/base/cursor/cursor_loader_x11.h
index 2b740f8..4947ca0 100644
--- a/ui/base/cursor/cursor_loader_x11.h
+++ b/ui/base/cursor/cursor_loader_x11.h
@@ -31,8 +31,6 @@ class UI_EXPORT CursorLoaderX11 : public CursorLoader {
int frame_delay_ms) OVERRIDE;
virtual void UnloadAll() OVERRIDE;
virtual void SetPlatformCursor(gfx::NativeCursor* cursor) OVERRIDE;
- virtual void SetCursorResourceModule(const string16& module_name) OVERRIDE {
- }
private:
// Returns true if we have an image resource loaded for the |native_cursor|.
diff --git a/ui/views/corewm/cursor_manager.cc b/ui/views/corewm/cursor_manager.cc
index 57a7ee8..5c4dc81 100644
--- a/ui/views/corewm/cursor_manager.cc
+++ b/ui/views/corewm/cursor_manager.cc
@@ -172,10 +172,6 @@ void CursorManager::UnlockCursor() {
}
}
-void CursorManager::SetCursorResourceModule(const string16& module_name) {
- delegate_->SetCursorResourceModule(module_name);
-}
-
void CursorManager::AddObserver(
aura::client::CursorClientObserver* observer) {
observers_.AddObserver(observer);
diff --git a/ui/views/corewm/cursor_manager.h b/ui/views/corewm/cursor_manager.h
index 0dc3688..9e31640 100644
--- a/ui/views/corewm/cursor_manager.h
+++ b/ui/views/corewm/cursor_manager.h
@@ -53,7 +53,6 @@ class VIEWS_EXPORT CursorManager : public aura::client::CursorClient,
virtual void SetDisplay(const gfx::Display& display) OVERRIDE;
virtual void LockCursor() OVERRIDE;
virtual void UnlockCursor() OVERRIDE;
- virtual void SetCursorResourceModule(const string16& module_name) OVERRIDE;
virtual void AddObserver(
aura::client::CursorClientObserver* observer) OVERRIDE;
virtual void RemoveObserver(
diff --git a/ui/views/corewm/cursor_manager_unittest.cc b/ui/views/corewm/cursor_manager_unittest.cc
index 87ea475..650d5b8 100644
--- a/ui/views/corewm/cursor_manager_unittest.cc
+++ b/ui/views/corewm/cursor_manager_unittest.cc
@@ -44,9 +44,6 @@ class TestingCursorManager : public views::corewm::NativeCursorManager {
delegate->CommitScale(scale);
}
- virtual void SetCursorResourceModule(const string16& module_name) OVERRIDE {
- }
-
private:
gfx::NativeCursor cursor_;
};
diff --git a/ui/views/corewm/native_cursor_manager.h b/ui/views/corewm/native_cursor_manager.h
index bd9d678..c38fb34 100644
--- a/ui/views/corewm/native_cursor_manager.h
+++ b/ui/views/corewm/native_cursor_manager.h
@@ -54,10 +54,6 @@ class VIEWS_EXPORT NativeCursorManager {
virtual void SetMouseEventsEnabled(
bool enabled,
views::corewm::NativeCursorManagerDelegate* delegate) = 0;
-
- // Used to pass the cursor resource module name to the cursor loader. This is
- // typically used to load non system cursors.
- virtual void SetCursorResourceModule(const string16& module_name) = 0;
};
} // namespace corewm
diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
index e4d48b8..856738f 100644
--- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
@@ -82,9 +82,4 @@ void DesktopNativeCursorManager::SetMouseEventsEnabled(
root_window_->OnMouseEventsEnableStateChanged(enabled);
}
-void DesktopNativeCursorManager::SetCursorResourceModule(
- const string16& module_name) {
- cursor_loader_->SetCursorResourceModule(module_name);
-}
-
} // namespace views
diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h
index 3058830..cbee0c4 100644
--- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h
+++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h
@@ -52,7 +52,6 @@ class VIEWS_EXPORT DesktopNativeCursorManager
virtual void SetMouseEventsEnabled(
bool enabled,
views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE;
- virtual void SetCursorResourceModule(const string16& module_name) OVERRIDE;
aura::RootWindow* root_window_;
scoped_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater_;