summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 04:13:30 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 04:13:30 +0000
commitfca90ea83b9eb992c8753544c91696344d345ff0 (patch)
treea33966779edba19bac12eb8c6798c6f577cff4b4
parentae1134914df8824d2c4af4efc0f1711dfe27eb76 (diff)
downloadchromium_src-fca90ea83b9eb992c8753544c91696344d345ff0.zip
chromium_src-fca90ea83b9eb992c8753544c91696344d345ff0.tar.gz
chromium_src-fca90ea83b9eb992c8753544c91696344d345ff0.tar.bz2
ash: Add RootWindowHostFactory class.
This provides a mechanism for creating a RootWindowHost to use in place of the default one that aura::RootWindow will create. This is exposed to consumers of ash through the addition of the CreateRootWindowHostFactory function to the ShellDelegate interface. BUG=124444 TEST=ash_unittests Review URL: https://chromiumcodereview.appspot.com/11360045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173080 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp8
-rw-r--r--ash/display/display_manager.cc9
-rw-r--r--ash/host/root_window_host_factory.cc31
-rw-r--r--ash/host/root_window_host_factory.h33
-rw-r--r--ash/host/root_window_host_factory_win.cc36
-rw-r--r--ash/shell.cc2
-rw-r--r--ash/shell.h6
-rw-r--r--ash/shell/shell_delegate_impl.cc5
-rw-r--r--ash/shell/shell_delegate_impl.h1
-rw-r--r--ash/shell_delegate.h5
-rw-r--r--ash/test/test_shell_delegate.cc5
-rw-r--r--ash/test/test_shell_delegate.h1
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.cc5
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h1
14 files changed, 142 insertions, 6 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index f1257e4..e95d815 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -100,6 +100,9 @@
'focus_cycler.h',
'high_contrast/high_contrast_controller.cc',
'high_contrast/high_contrast_controller.h',
+ 'host/root_window_host_factory.cc',
+ 'host/root_window_host_factory.h',
+ 'host/root_window_host_factory_win.cc',
'keyboard_overlay/keyboard_overlay_delegate.cc',
'keyboard_overlay/keyboard_overlay_delegate.h',
'keyboard_overlay/keyboard_overlay_view.cc',
@@ -441,6 +444,11 @@
['exclude', 'accelerators/nested_dispatcher_controller.h'],
],
}],
+ ['OS=="win"', {
+ 'sources/': [
+ ['exclude', 'host/root_window_host_factory.cc'],
+ ],
+ }],
['OS!="linux"', {
'sources/': [
['exclude', 'system/monitor/tray_monitor.cc'],
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 572f91a..476815b2 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "ash/display/display_controller.h"
+#include "ash/host/root_window_host_factory.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "base/command_line.h"
@@ -320,12 +321,8 @@ void DisplayManager::UpdateDisplays(
RootWindow* DisplayManager::CreateRootWindowForDisplay(
const gfx::Display& display) {
RootWindow::CreateParams params(display.bounds_in_pixel());
-#if defined(OS_WIN)
- if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
- params.host = aura::RemoteRootWindowHostWin::Create(
- display.bounds_in_pixel());
- }
-#endif
+ params.host = Shell::GetInstance()->root_window_host_factory()->
+ CreateRootWindowHost(display.bounds_in_pixel());
aura::RootWindow* root_window = new aura::RootWindow(params);
// No need to remove RootWindowObserver because
// the DisplayManager object outlives RootWindow objects.
diff --git a/ash/host/root_window_host_factory.cc b/ash/host/root_window_host_factory.cc
new file mode 100644
index 0000000..a0dbc0e
--- /dev/null
+++ b/ash/host/root_window_host_factory.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 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 "ash/host/root_window_host_factory.h"
+
+#include "ui/aura/root_window_host.h"
+
+namespace {
+
+class RootWindowHostFactoryImpl : public ash::RootWindowHostFactory {
+ public:
+ RootWindowHostFactoryImpl() {}
+
+ // Overridden from RootWindowHostFactory:
+ virtual aura::RootWindowHost* CreateRootWindowHost(
+ const gfx::Rect& initial_bounds) OVERRIDE {
+ return aura::RootWindowHost::Create(initial_bounds);
+ }
+};
+
+}
+
+namespace ash {
+
+// static
+RootWindowHostFactory* RootWindowHostFactory::Create() {
+ return new RootWindowHostFactoryImpl;
+}
+
+} // namespace ash
diff --git a/ash/host/root_window_host_factory.h b/ash/host/root_window_host_factory.h
new file mode 100644
index 0000000..d357d9b
--- /dev/null
+++ b/ash/host/root_window_host_factory.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 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 ASH_HOST_ROOT_WINDOW_HOST_FACTORY_H_
+#define ASH_HOST_ROOT_WINDOW_HOST_FACTORY_H_
+
+#include "ash/ash_export.h"
+#include "ui/gfx/rect.h"
+
+namespace aura {
+class RootWindowHost;
+}
+
+namespace ash {
+
+class ASH_EXPORT RootWindowHostFactory {
+ public:
+ virtual ~RootWindowHostFactory() {}
+
+ static RootWindowHostFactory* Create();
+
+ // Creates a new aura::RootWindowHost. The caller owns the returned value.
+ virtual aura::RootWindowHost* CreateRootWindowHost(
+ const gfx::Rect& initial_bounds) = 0;
+
+ protected:
+ RootWindowHostFactory() {}
+};
+
+} // namespace ash
+
+#endif // ASH_HOST_ROOT_WINDOW_HOST_FACTORY_H_
diff --git a/ash/host/root_window_host_factory_win.cc b/ash/host/root_window_host_factory_win.cc
new file mode 100644
index 0000000..1703b72
--- /dev/null
+++ b/ash/host/root_window_host_factory_win.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 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 "ash/host/root_window_host_factory.h"
+
+#include "base/win/windows_version.h"
+#include "ui/aura/remote_root_window_host_win.h"
+#include "ui/aura/root_window_host.h"
+
+namespace {
+
+class RootWindowHostFactoryImpl : public ash::RootWindowHostFactory {
+ public:
+ RootWindowHostFactoryImpl() {}
+
+ // Overridden from RootWindowHostFactory:
+ virtual aura::RootWindowHost* CreateRootWindowHost(
+ const gfx::Rect& initial_bounds) OVERRIDE {
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8)
+ return aura::RemoteRootWindowHostWin::Create(initial_bounds);
+
+ return aura::RootWindowHost::Create(initial_bounds);
+ }
+};
+
+}
+
+namespace ash {
+
+// static
+RootWindowHostFactory* RootWindowHostFactory::Create() {
+ return new RootWindowHostFactoryImpl;
+}
+
+} // namespace ash
diff --git a/ash/shell.cc b/ash/shell.cc
index 0d4461c..8050414 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -20,6 +20,7 @@
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/focus_cycler.h"
#include "ash/high_contrast/high_contrast_controller.h"
+#include "ash/host/root_window_host_factory.h"
#include "ash/launcher/launcher_delegate.h"
#include "ash/launcher/launcher_model.h"
#include "ash/magnifier/magnification_controller.h"
@@ -427,6 +428,7 @@ void Shell::Init() {
focus_cycler_.reset(new internal::FocusCycler());
screen_position_controller_.reset(new internal::ScreenPositionController);
+ root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory());
display_controller_.reset(new DisplayController);
display_controller_->InitPrimaryDisplay();
aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow();
diff --git a/ash/shell.h b/ash/shell.h
index 34de721..20b7876 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -78,6 +78,7 @@ class MagnificationController;
class NestedDispatcherController;
class PartialMagnificationController;
class PowerButtonController;
+class RootWindowHostFactory;
class ScreenAsh;
class SessionStateController;
class ShellDelegate;
@@ -423,6 +424,10 @@ class ASH_EXPORT Shell
aura::client::StackingClient* stacking_client();
+ RootWindowHostFactory* root_window_host_factory() {
+ return root_window_host_factory_.get();
+ }
+
private:
FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
@@ -527,6 +532,7 @@ class ASH_EXPORT Shell
scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
scoped_ptr<internal::EventClientImpl> event_client_;
+ scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
// An event filter that rewrites or drops an event.
scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index d53fe07..879ccdd 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -5,6 +5,7 @@
#include "ash/shell/shell_delegate_impl.h"
#include "ash/caps_lock_delegate_stub.h"
+#include "ash/host/root_window_host_factory.h"
#include "ash/shell/example_factory.h"
#include "ash/shell/launcher_delegate_impl.h"
#include "ash/shell/context_menu.h"
@@ -213,5 +214,9 @@ bool ShellDelegateImpl::IsSearchKeyActingAsFunctionKey() const {
return false;
}
+RootWindowHostFactory* ShellDelegateImpl::CreateRootWindowHostFactory() {
+ return RootWindowHostFactory::Create();
+}
+
} // namespace shell
} // namespace ash
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index ea26561..27ad26c 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -69,6 +69,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
aura::RootWindow* root_window) OVERRIDE;
virtual aura::client::StackingClient* CreateStackingClient() OVERRIDE;
virtual bool IsSearchKeyActingAsFunctionKey() const OVERRIDE;
+ virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE;
private:
// Used to update Launcher. Owned by main.
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 96064e5..e6fc43f 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -41,6 +41,7 @@ class CapsLockDelegate;
class LauncherDelegate;
class LauncherModel;
struct LauncherItem;
+class RootWindowHostFactory;
class SystemTrayDelegate;
class UserWallpaperDelegate;
@@ -218,6 +219,10 @@ class ASH_EXPORT ShellDelegate {
// True if the user's preferences have the Search key acting as a Function key
// modifier for accessing extended keyboard shortcuts.
virtual bool IsSearchKeyActingAsFunctionKey() const = 0;
+
+ // Creates a root window host factory. Shell takes ownership of the returned
+ // value.
+ virtual RootWindowHostFactory* CreateRootWindowHostFactory() = 0;
};
} // namespace ash
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index c57e41e..2cc556b 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "ash/caps_lock_delegate_stub.h"
+#include "ash/host/root_window_host_factory.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/test_launcher_delegate.h"
@@ -203,6 +204,10 @@ bool TestShellDelegate::IsSearchKeyActingAsFunctionKey() const {
return is_search_key_acting_as_function_key_;
}
+RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() {
+ return RootWindowHostFactory::Create();
+}
+
void TestShellDelegate::SetSessionStarted(bool session_started) {
session_started_ = session_started;
if (session_started)
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 398e0f4..4c1f9e2 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -67,6 +67,7 @@ class TestShellDelegate : public ShellDelegate {
virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE;
virtual aura::client::StackingClient* CreateStackingClient() OVERRIDE;
virtual bool IsSearchKeyActingAsFunctionKey() const OVERRIDE;
+ virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE;
int num_exit_requests() const { return num_exit_requests_; }
void set_is_search_key_acting_as_function_key(bool b) {
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index 0f1483c..d0d9b70 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/ash/chrome_shell_delegate.h"
+#include "ash/host/root_window_host_factory.h"
#include "ash/launcher/launcher_types.h"
#include "ash/magnifier/magnifier_constants.h"
#include "ash/system/tray/system_tray_delegate.h"
@@ -549,6 +550,10 @@ bool ChromeShellDelegate::IsSearchKeyActingAsFunctionKey() const {
#endif
}
+ash::RootWindowHostFactory* ChromeShellDelegate::CreateRootWindowHostFactory() {
+ return ash::RootWindowHostFactory::Create();
+}
+
void ChromeShellDelegate::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index c01943d..13f3e5d 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -83,6 +83,7 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE;
virtual aura::client::StackingClient* CreateStackingClient() OVERRIDE;
virtual bool IsSearchKeyActingAsFunctionKey() const OVERRIDE;
+ virtual ash::RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE;
// content::NotificationObserver override:
virtual void Observe(int type,