summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 21:47:58 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 21:47:58 +0000
commitfa69f2b688dd5fcefe3484aaa9b7d99175bc1bb9 (patch)
tree1d9c539da5aab9ef57883d5f871d91bffdbd9f6b
parent15b4290d997471abce904d693291808e8205ddd3 (diff)
downloadchromium_src-fa69f2b688dd5fcefe3484aaa9b7d99175bc1bb9.zip
chromium_src-fa69f2b688dd5fcefe3484aaa9b7d99175bc1bb9.tar.gz
chromium_src-fa69f2b688dd5fcefe3484aaa9b7d99175bc1bb9.tar.bz2
Makes Env contain a ContextFactory
This way when creating the Compositor we can supply the ContextFactory from the thread local Env to it. This is part of making aura thread safe. BUG=none TEST=none R=ben@chromium.org Review URL: https://codereview.chromium.org/296053009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272332 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/shell/browser/shell_desktop_controller.cc4
-rw-r--r--ash/shell.cc4
-rw-r--r--ash/shell/content_client/shell_browser_main_parts.cc2
-rw-r--r--ash/shell/window_watcher_unittest.cc2
-rw-r--r--ash/shell_init_params.cc8
-rw-r--r--ash/shell_init_params.h6
-rw-r--r--ash/test/ash_test_helper.cc4
-rw-r--r--chrome/browser/ui/ash/ash_init.cc2
-rw-r--r--chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc7
-rw-r--r--chrome/test/base/browser_with_test_window_test.cc6
-rw-r--r--chrome/test/base/view_event_test_base.cc7
-rw-r--r--content/browser/browser_main_loop.cc7
-rw-r--r--content/browser/compositor/software_browser_compositor_output_surface_unittest.cc6
-rw-r--r--content/browser/compositor/software_output_device_ozone_unittest.cc6
-rw-r--r--content/browser/media/capture/desktop_capture_device_aura_unittest.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura_unittest.cc5
-rw-r--r--content/public/test/test_renderer_host.cc5
-rw-r--r--content/shell/browser/shell_views.cc4
-rw-r--r--mojo/aura/window_tree_host_mojo.cc1
-rw-r--r--ui/aura/bench/bench_main.cc1
-rw-r--r--ui/aura/demo/demo_main.cc1
-rw-r--r--ui/aura/env.cc3
-rw-r--r--ui/aura/env.h8
-rw-r--r--ui/aura/test/aura_test_base.cc5
-rw-r--r--ui/aura/test/aura_test_helper.cc3
-rw-r--r--ui/aura/test/aura_test_helper.h3
-rw-r--r--ui/aura/window_tree_host.cc7
-rw-r--r--ui/keyboard/keyboard_controller_unittest.cc6
-rw-r--r--ui/snapshot/snapshot_aura_unittest.cc6
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.cc4
-rw-r--r--ui/views/test/test_views_delegate.cc12
-rw-r--r--ui/views/test/test_views_delegate.h9
-rw-r--r--ui/views/test/views_test_base.cc5
-rw-r--r--ui/views/test/views_test_helper.cc3
-rw-r--r--ui/views/test/views_test_helper.h7
-rw-r--r--ui/views/test/views_test_helper_aura.cc11
-rw-r--r--ui/views/test/views_test_helper_aura.h4
-rw-r--r--ui/wm/test/wm_test_helper.cc4
-rw-r--r--ui/wm/test/wm_test_helper.h7
39 files changed, 131 insertions, 69 deletions
diff --git a/apps/shell/browser/shell_desktop_controller.cc b/apps/shell/browser/shell_desktop_controller.cc
index ead33f1..124d89f 100644
--- a/apps/shell/browser/shell_desktop_controller.cc
+++ b/apps/shell/browser/shell_desktop_controller.cc
@@ -5,6 +5,7 @@
#include "apps/shell/browser/shell_desktop_controller.h"
#include "apps/shell/browser/shell_app_window.h"
+#include "content/public/browser/context_factory.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/layout_manager.h"
@@ -226,7 +227,8 @@ void ShellDesktopController::CreateRootWindow() {
gfx::Size size = GetPrimaryDisplaySize();
if (size.IsEmpty())
size = gfx::Size(800, 600);
- wm_test_helper_.reset(new wm::WMTestHelper(size));
+ wm_test_helper_.reset(
+ new wm::WMTestHelper(size, content::GetContextFactory()));
// Ensure new windows fill the display.
aura::WindowTreeHost* host = wm_test_helper_->host();
diff --git a/ash/shell.cc b/ash/shell.cc
index d2322d8..c0a1765 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -843,10 +843,8 @@ void Shell::Init(const ShellInitParams& init_params) {
// Shelf, and WallPaper could be created by the factory.
views::FocusManagerFactory::Install(new AshFocusManagerFactory);
- // Env creates the compositor. Historically it seems to have been implicitly
- // initialized first by the ActivationController, but now that FocusController
- // no longer does this we need to do it explicitly.
aura::Env::CreateInstance(true);
+ aura::Env::GetInstance()->set_context_factory(init_params.context_factory);
// The WindowModalityController needs to be at the front of the input event
// pretarget handler list to ensure that it processes input events when modal
diff --git a/ash/shell/content_client/shell_browser_main_parts.cc b/ash/shell/content_client/shell_browser_main_parts.cc
index 8accc93..cb84b46 100644
--- a/ash/shell/content_client/shell_browser_main_parts.cc
+++ b/ash/shell/content_client/shell_browser_main_parts.cc
@@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
+#include "content/public/browser/context_factory.h"
#include "content/public/common/content_switches.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_net_log.h"
@@ -124,6 +125,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
ash::ShellInitParams init_params;
init_params.delegate = delegate_;
+ init_params.context_factory = content::GetContextFactory();
ash::Shell::CreateInstance(init_params);
delegate_->set_browser_context(browser_context_.get());
ash::Shell::GetInstance()->CreateShelf();
diff --git a/ash/shell/window_watcher_unittest.cc b/ash/shell/window_watcher_unittest.cc
index dd5ea40..c3b5dcf 100644
--- a/ash/shell/window_watcher_unittest.cc
+++ b/ash/shell/window_watcher_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/shell_init_params.h"
#include "ash/system/user/login_status.h"
#include "ash/test/ash_test_base.h"
+#include "ui/aura/env.h"
#include "ui/aura/window_tree_host.h"
namespace ash {
@@ -25,6 +26,7 @@ TEST_F(WindowWatcherTest, ShellDeleteInstance) {
shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl;
ash::ShellInitParams init_params;
+ init_params.context_factory = aura::Env::GetInstance()->context_factory();
init_params.delegate = delegate;
Shell::CreateInstance(init_params);
Shell::GetPrimaryRootWindow()->GetHost()->Show();
diff --git a/ash/shell_init_params.cc b/ash/shell_init_params.cc
index 87e5be8..bba57c6 100644
--- a/ash/shell_init_params.cc
+++ b/ash/shell_init_params.cc
@@ -8,11 +8,13 @@
namespace ash {
+ShellInitParams::ShellInitParams()
+ : delegate(NULL),
+ context_factory(NULL)
#if defined(OS_WIN)
-ShellInitParams::ShellInitParams() : delegate(NULL), remote_hwnd(NULL) {}
-#else
-ShellInitParams::ShellInitParams() : delegate(NULL) {}
+ , remote_hwnd(NULL)
#endif
+ {}
ShellInitParams::~ShellInitParams() {}
diff --git a/ash/shell_init_params.h b/ash/shell_init_params.h
index 52b894e..9a681fae 100644
--- a/ash/shell_init_params.h
+++ b/ash/shell_init_params.h
@@ -13,6 +13,10 @@
#include "ash/ash_export.h"
+namespace ui {
+class ContextFactory;
+}
+
namespace ash {
class ShellDelegate;
@@ -23,6 +27,8 @@ struct ASH_EXPORT ShellInitParams {
ShellDelegate* delegate;
+ ui::ContextFactory* context_factory;
+
#if defined(OS_WIN)
HWND remote_hwnd;
#endif
diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc
index 3dd9455..ceb2910 100644
--- a/ash/test/ash_test_helper.cc
+++ b/ash/test/ash_test_helper.cc
@@ -65,7 +65,8 @@ void AshTestHelper::SetUp(bool start_session) {
ui::InitializeInputMethodForTesting();
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
// Creates Shell and hook with Desktop.
if (!test_shell_delegate_)
@@ -87,6 +88,7 @@ void AshTestHelper::SetUp(bool start_session) {
#endif
ShellInitParams init_params;
init_params.delegate = test_shell_delegate_;
+ init_params.context_factory = context_factory;
ash::Shell::CreateInstance(init_params);
aura::test::EnvTestHelper(aura::Env::GetInstance()).SetInputStateLookup(
scoped_ptr<aura::InputStateLookup>());
diff --git a/chrome/browser/ui/ash/ash_init.cc b/chrome/browser/ui/ash/ash_init.cc
index 06ab94e..78e617b 100644
--- a/chrome/browser/ui/ash/ash_init.cc
+++ b/chrome/browser/ui/ash/ash_init.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/ash/screenshot_taker.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/context_factory.h"
#include "ui/aura/env.h"
#include "ui/aura/window_tree_host.h"
@@ -62,6 +63,7 @@ void OpenAsh(gfx::AcceleratedWidget remote_window) {
ash::ShellInitParams shell_init_params;
// Shell takes ownership of ChromeShellDelegate.
shell_init_params.delegate = new ChromeShellDelegate;
+ shell_init_params.context_factory = content::GetContextFactory();
#if defined(OS_WIN)
shell_init_params.remote_hwnd = remote_window;
#endif
diff --git a/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc
index 49328c7..023489d 100644
--- a/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc
+++ b/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc
@@ -52,6 +52,7 @@ class AccessibilityViewsDelegate : public views::TestViewsDelegate {
view, event_type);
}
+ private:
DISALLOW_COPY_AND_ASSIGN(AccessibilityViewsDelegate);
};
@@ -110,10 +111,11 @@ class AccessibilityEventRouterViewsTest
#if defined(USE_AURA)
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif // USE_AURA
EnableAccessibilityAndListenToFocusNotifications();
@@ -126,7 +128,6 @@ class AccessibilityEventRouterViewsTest
ui::TerminateContextFactoryForTests();
#endif
delete views::ViewsDelegate::views_delegate;
- views::ViewsDelegate::views_delegate = NULL;
// The Widget's FocusManager is deleted using DeleteSoon - this
// forces it to be deleted now, so we don't have any memory leaks
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index 5d7cd98..022ad4d 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -19,6 +19,7 @@
#if defined(USE_AURA)
#include "ui/aura/test/aura_test_helper.h"
+#include "ui/compositor/compositor.h"
#include "ui/compositor/test/context_factories_for_test.h"
#include "ui/wm/core/default_activation_client.h"
#endif
@@ -68,11 +69,12 @@ void BrowserWithTestWindowTest::SetUp() {
#elif defined(USE_AURA)
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
aura_test_helper_.reset(new aura::test::AuraTestHelper(
base::MessageLoopForUI::current()));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif // USE_AURA
#if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS)
diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc
index 043bc30..d3c4f1c 100644
--- a/chrome/test/base/view_event_test_base.cc
+++ b/chrome/test/base/view_event_test_base.cc
@@ -109,7 +109,8 @@ void ViewEventTestBase::SetUp() {
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
#if defined(OS_CHROMEOS)
// Ash Shell can't just live on its own without a browser process, we need to
@@ -122,6 +123,7 @@ void ViewEventTestBase::SetUp() {
new ash::test::TestShellDelegate();
ash::ShellInitParams init_params;
init_params.delegate = shell_delegate;
+ init_params.context_factory = context_factory;
ash::Shell::CreateInstance(init_params);
shell_delegate->test_session_state_delegate()
->SetActiveUserSessionStarted(true);
@@ -133,12 +135,13 @@ void ViewEventTestBase::SetUp() {
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
aura::Env::CreateInstance(true);
+ aura::Env::GetInstance()->set_context_factory(context_factory);
#elif defined(USE_AURA)
// Instead of using the ash shell, use an AuraTestHelper to create and manage
// the test screen.
aura_test_helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
context = aura_test_helper_->root_window();
#endif
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 6f2a7e4..8799798 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -67,6 +67,7 @@
#endif
#if defined(USE_AURA)
+#include "content/public/browser/context_factory.h"
#include "ui/aura/env.h"
#endif
@@ -942,6 +943,12 @@ int BrowserMainLoop::BrowserThreadsStarted() {
}
BrowserGpuChannelHostFactory::Initialize(established_gpu_channel);
ImageTransportFactory::Initialize();
+#if defined(USE_AURA)
+ if (aura::Env::GetInstance()) {
+ aura::Env::GetInstance()->set_context_factory(
+ content::GetContextFactory());
+ }
+#endif
}
#elif defined(OS_ANDROID)
established_gpu_channel = true;
diff --git a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc
index 1efd102..79c3364 100644
--- a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc
+++ b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc
@@ -90,9 +90,11 @@ SoftwareBrowserCompositorOutputSurfaceTest::
void SoftwareBrowserCompositorOutputSurfaceTest::SetUp() {
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
- compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget));
+ compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
+ context_factory));
surface_proxy_ =
new content::BrowserCompositorOutputSurfaceProxy(&surface_map_);
}
diff --git a/content/browser/compositor/software_output_device_ozone_unittest.cc b/content/browser/compositor/software_output_device_ozone_unittest.cc
index dcacbd0..009bd89 100644
--- a/content/browser/compositor/software_output_device_ozone_unittest.cc
+++ b/content/browser/compositor/software_output_device_ozone_unittest.cc
@@ -99,13 +99,15 @@ SoftwareOutputDeviceOzoneTest::~SoftwareOutputDeviceOzoneTest() {
}
void SoftwareOutputDeviceOzoneTest::SetUp() {
- ui::InitializeContextFactoryForTests(enable_pixel_output_);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output_);
surface_factory_.reset(new MockSurfaceFactoryOzone());
const gfx::Size size(500, 400);
compositor_.reset(new ui::Compositor(
- gfx::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget()));
+ gfx::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget(),
+ context_factory));
compositor_->SetScaleAndSize(1.0f, size);
output_device_.reset(new content::SoftwareOutputDeviceOzone(
diff --git a/content/browser/media/capture/desktop_capture_device_aura_unittest.cc b/content/browser/media/capture/desktop_capture_device_aura_unittest.cc
index 608c574..3cfccf0 100644
--- a/content/browser/media/capture/desktop_capture_device_aura_unittest.cc
+++ b/content/browser/media/capture/desktop_capture_device_aura_unittest.cc
@@ -63,9 +63,10 @@ class DesktopCaptureDeviceAuraTest : public testing::Test {
virtual void SetUp() OVERRIDE {
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
- helper_->SetUp();
+ helper_->SetUp(context_factory);
new wm::DefaultActivationClient(helper_->root_window());
// We need a window to cover desktop area so that DesktopCaptureDeviceAura
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
index 592eac2..2a418df 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
@@ -209,10 +209,11 @@ class RenderWidgetHostViewAuraTest : public testing::Test {
: browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {}
void SetUpEnvironment() {
+ ui::ContextFactory* context_factory = new ui::InProcessContextFactory;
ImageTransportFactory::InitializeForUnitTests(
- scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory));
+ scoped_ptr<ui::ContextFactory>(context_factory));
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
browser_context_.reset(new TestBrowserContext);
diff --git a/content/public/test/test_renderer_host.cc b/content/public/test/test_renderer_host.cc
index abaa4ce..45e8306 100644
--- a/content/public/test/test_renderer_host.cc
+++ b/content/public/test/test_renderer_host.cc
@@ -170,11 +170,12 @@ void RenderViewHostTestHarness::SetUp() {
#if defined(USE_AURA)
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
aura_test_helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif
diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc
index fcc98d7..dcdd890 100644
--- a/content/shell/browser/shell_views.cc
+++ b/content/shell/browser/shell_views.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/context_factory.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/context_menu_params.h"
@@ -424,7 +425,8 @@ void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
chromeos::DBusThreadManager::Initialize();
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create());
- wm_test_helper_ = new wm::WMTestHelper(default_window_size);
+ wm_test_helper_ = new wm::WMTestHelper(default_window_size,
+ GetContextFactory());
#else
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
diff --git a/mojo/aura/window_tree_host_mojo.cc b/mojo/aura/window_tree_host_mojo.cc
index e028e0c..b060447 100644
--- a/mojo/aura/window_tree_host_mojo.cc
+++ b/mojo/aura/window_tree_host_mojo.cc
@@ -48,6 +48,7 @@ WindowTreeHostMojo::WindowTreeHostMojo(
}
context_factory_ = new ContextFactoryMojo(gles2_handle.Pass());
ui::ContextFactory::SetInstance(context_factory_);
+ aura::Env::GetInstance()->set_context_factory(context_factory_);
CHECK(context_factory_) << "No GL bindings.";
native_viewport_->CreateGLES2Context(gles2_client_handle.Pass());
diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc
index f2eadee4..53a5c6e 100644
--- a/ui/aura/bench/bench_main.cc
+++ b/ui/aura/bench/bench_main.cc
@@ -305,6 +305,7 @@ int main(int argc, char** argv) {
base::MessageLoopForUI message_loop;
aura::Env::CreateInstance(true);
+ aura::Env::GetInstance()->set_context_factory(context_factory.get());
scoped_ptr<aura::TestScreen> test_screen(
aura::TestScreen::CreateFullscreen());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get());
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index a8716e1..f0f8bff 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -129,6 +129,7 @@ int DemoMain() {
base::MessageLoopForUI message_loop;
aura::Env::CreateInstance(true);
+ aura::Env::GetInstance()->set_context_factory(context_factory.get());
scoped_ptr<aura::TestScreen> test_screen(aura::TestScreen::Create());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get());
scoped_ptr<aura::WindowTreeHost> host(
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index baa6618..71a43c9 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -66,7 +66,8 @@ bool Env::IsMouseButtonDown() const {
Env::Env()
: mouse_button_flags_(0),
is_touch_down_(false),
- input_state_lookup_(InputStateLookup::Create().Pass()) {
+ input_state_lookup_(InputStateLookup::Create().Pass()),
+ context_factory_(NULL) {
DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL);
lazy_tls_ptr.Pointer()->Set(this);
}
diff --git a/ui/aura/env.h b/ui/aura/env.h
index 9818213..fc83ac8 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -13,6 +13,7 @@
#include "ui/gfx/point.h"
namespace ui {
+class ContextFactory;
class PlatformEventSource;
}
namespace aura {
@@ -59,6 +60,11 @@ class AURA_EXPORT Env : public ui::EventTarget {
bool is_touch_down() const { return is_touch_down_; }
void set_touch_down(bool value) { is_touch_down_ = value; }
+ void set_context_factory(ui::ContextFactory* context_factory) {
+ context_factory_ = context_factory;
+ }
+ ui::ContextFactory* context_factory() { return context_factory_; }
+
private:
friend class test::EnvTestHelper;
friend class Window;
@@ -95,6 +101,8 @@ class AURA_EXPORT Env : public ui::EventTarget {
scoped_ptr<InputStateLookup> input_state_lookup_;
scoped_ptr<ui::PlatformEventSource> event_source_;
+ ui::ContextFactory* context_factory_;
+
DISALLOW_COPY_AND_ASSIGN(Env);
};
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index e49a1e0..9811281 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -73,10 +73,11 @@ void AuraTestBase::SetUp() {
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
helper_.reset(new AuraTestHelper(&message_loop_));
- helper_->SetUp();
+ helper_->SetUp(context_factory);
}
void AuraTestBase::TearDown() {
diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc
index 5823922..1b56512 100644
--- a/ui/aura/test/aura_test_helper.cc
+++ b/ui/aura/test/aura_test_helper.cc
@@ -52,10 +52,11 @@ AuraTestHelper::~AuraTestHelper() {
<< "AuraTestHelper::TearDown() never called.";
}
-void AuraTestHelper::SetUp() {
+void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) {
setup_called_ = true;
Env::CreateInstance(true);
+ Env::GetInstance()->set_context_factory(context_factory);
// Unit tests generally don't want to query the system, rather use the state
// from RootWindow.
EnvTestHelper(Env::GetInstance()).SetInputStateLookup(
diff --git a/ui/aura/test/aura_test_helper.h b/ui/aura/test/aura_test_helper.h
index 05d59ab..d547b0c 100644
--- a/ui/aura/test/aura_test_helper.h
+++ b/ui/aura/test/aura_test_helper.h
@@ -15,6 +15,7 @@ class MessageLoopForUI;
}
namespace ui {
+class ContextFactory;
class InputMethod;
class ScopedAnimationDurationScaleMode;
}
@@ -37,7 +38,7 @@ class AuraTestHelper {
~AuraTestHelper();
// Creates and initializes (shows and sizes) the RootWindow for use in tests.
- void SetUp();
+ void SetUp(ui::ContextFactory* context_factory);
// Clean up objects that are created for tests. This also deletes the Env
// object.
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc
index 2118c2e..9ac7cf7a 100644
--- a/ui/aura/window_tree_host.cc
+++ b/ui/aura/window_tree_host.cc
@@ -198,8 +198,11 @@ void WindowTreeHost::DestroyDispatcher() {
void WindowTreeHost::CreateCompositor(
gfx::AcceleratedWidget accelerated_widget) {
- compositor_.reset(new ui::Compositor(GetAcceleratedWidget()));
- DCHECK(compositor_.get());
+ DCHECK(Env::GetInstance());
+ ui::ContextFactory* context_factory = Env::GetInstance()->context_factory();
+ DCHECK(context_factory);
+ compositor_.reset(
+ new ui::Compositor(GetAcceleratedWidget(), context_factory));
// TODO(beng): I think this setup should probably all move to a "accelerated
// widget available" function.
if (!dispatcher()) {
diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc
index 3e3418e..f264493 100644
--- a/ui/keyboard/keyboard_controller_unittest.cc
+++ b/ui/keyboard/keyboard_controller_unittest.cc
@@ -18,6 +18,7 @@
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/input_method_factory.h"
#include "ui/base/ime/text_input_client.h"
+#include "ui/compositor/compositor.h"
#include "ui/compositor/layer_type.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/test/context_factories_for_test.h"
@@ -165,10 +166,11 @@ class KeyboardControllerTest : public testing::Test {
virtual void SetUp() OVERRIDE {
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
ui::SetUpInputMethodFactoryForTesting();
focus_controller_.reset(new TestFocusController(root_window()));
diff --git a/ui/snapshot/snapshot_aura_unittest.cc b/ui/snapshot/snapshot_aura_unittest.cc
index eee20b3..f8a2a94 100644
--- a/ui/snapshot/snapshot_aura_unittest.cc
+++ b/ui/snapshot/snapshot_aura_unittest.cc
@@ -13,6 +13,7 @@
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/test/context_factories_for_test.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
@@ -89,11 +90,12 @@ class SnapshotAuraTest : public testing::Test {
// The ContextFactory must exist before any Compositors are created.
// Snapshot test tests real drawing and readback, so needs pixel output.
bool enable_pixel_output = true;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
- helper_->SetUp();
+ helper_->SetUp(context_factory);
new ::wm::DefaultActivationClient(helper_->root_window());
}
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc
index 121678f..159b931 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.cc
+++ b/ui/views/examples/content_client/examples_browser_main_parts.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
+#include "content/public/browser/context_factory.h"
#include "content/public/common/content_switches.h"
#include "content/shell/browser/shell_browser_context.h"
#include "ui/aura/env.h"
@@ -54,7 +55,8 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create());
// Set up basic pieces of views::corewm.
- wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600)));
+ wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600),
+ content::GetContextFactory()));
// Ensure the X window gets mapped.
wm_test_helper_->host()->Show();
// Ensure Aura knows where to open new windows.
diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc
index 7a4b78d..0d437ea 100644
--- a/ui/views/test/test_views_delegate.cc
+++ b/ui/views/test/test_views_delegate.cc
@@ -15,11 +15,7 @@ namespace views {
TestViewsDelegate::TestViewsDelegate()
: use_desktop_native_widgets_(false),
- use_transparent_windows_(false)
-#if defined(USE_AURA)
- , context_factory_(NULL)
-#endif
- {
+ use_transparent_windows_(false) {
DCHECK(!ViewsDelegate::views_delegate);
ViewsDelegate::views_delegate = this;
#if defined(USE_AURA)
@@ -46,10 +42,4 @@ void TestViewsDelegate::OnBeforeWidgetInit(
#endif // !defined(OS_CHROMEOS)
}
-#if defined(USE_AURA)
-ui::ContextFactory* TestViewsDelegate::GetContextFactory() {
- return context_factory_;
-}
-#endif
-
} // namespace views
diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h
index 384d7ac..626bc79 100644
--- a/ui/views/test/test_views_delegate.h
+++ b/ui/views/test/test_views_delegate.h
@@ -30,19 +30,10 @@ class TestViewsDelegate : public ViewsDelegate {
use_transparent_windows_ = transparent;
}
-#if defined(USE_AURA)
- void set_context_factory(ui::ContextFactory* context_factory) {
- context_factory_ = context_factory;
- }
-#endif
-
// ViewsDelegate:
virtual void OnBeforeWidgetInit(
Widget::InitParams* params,
internal::NativeWidgetDelegate* delegate) OVERRIDE;
-#if defined(USE_AURA)
- virtual ui::ContextFactory* GetContextFactory() OVERRIDE;
-#endif
private:
bool use_desktop_native_widgets_;
diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc
index 5b7f5c1..eba69ac 100644
--- a/ui/views/test/views_test_base.cc
+++ b/ui/views/test/views_test_base.cc
@@ -31,9 +31,10 @@ void ViewsTestBase::SetUp() {
views_delegate_.reset(new TestViewsDelegate());
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
- test_helper_.reset(ViewsTestHelper::Create(&message_loop_));
+ test_helper_.reset(ViewsTestHelper::Create(&message_loop_, context_factory));
test_helper_->SetUp();
ui::InitializeInputMethodForTesting();
}
diff --git a/ui/views/test/views_test_helper.cc b/ui/views/test/views_test_helper.cc
index 25476d9..c0268f4 100644
--- a/ui/views/test/views_test_helper.cc
+++ b/ui/views/test/views_test_helper.cc
@@ -8,7 +8,8 @@ namespace views {
#if !defined(USE_AURA)
// static
-ViewsTestHelper* ViewsTestHelper::Create(base::MessageLoopForUI* message_loop) {
+ViewsTestHelper* ViewsTestHelper::Create(base::MessageLoopForUI* message_loop,
+ ui::ContextFactory* context_factory) {
return new ViewsTestHelper;
}
#endif
diff --git a/ui/views/test/views_test_helper.h b/ui/views/test/views_test_helper.h
index 06a49d5..53bac2f6 100644
--- a/ui/views/test/views_test_helper.h
+++ b/ui/views/test/views_test_helper.h
@@ -11,6 +11,10 @@ namespace base {
class MessageLoopForUI;
}
+namespace ui {
+class ContextFactory;
+}
+
namespace views {
// A helper class owned by tests that performs platform specific initialization
@@ -21,7 +25,8 @@ class ViewsTestHelper {
virtual ~ViewsTestHelper();
// Create a platform specific instance.
- static ViewsTestHelper* Create(base::MessageLoopForUI* message_loop);
+ static ViewsTestHelper* Create(base::MessageLoopForUI* message_loop,
+ ui::ContextFactory* context_factory);
// Creates objects that are needed for tests.
virtual void SetUp();
diff --git a/ui/views/test/views_test_helper_aura.cc b/ui/views/test/views_test_helper_aura.cc
index e78e7a9..2f50b86 100644
--- a/ui/views/test/views_test_helper_aura.cc
+++ b/ui/views/test/views_test_helper_aura.cc
@@ -12,11 +12,14 @@
namespace views {
// static
-ViewsTestHelper* ViewsTestHelper::Create(base::MessageLoopForUI* message_loop) {
- return new ViewsTestHelperAura(message_loop);
+ViewsTestHelper* ViewsTestHelper::Create(base::MessageLoopForUI* message_loop,
+ ui::ContextFactory* context_factory) {
+ return new ViewsTestHelperAura(message_loop, context_factory);
}
-ViewsTestHelperAura::ViewsTestHelperAura(base::MessageLoopForUI* message_loop) {
+ViewsTestHelperAura::ViewsTestHelperAura(base::MessageLoopForUI* message_loop,
+ ui::ContextFactory* context_factory)
+ : context_factory_(context_factory) {
aura_test_helper_.reset(new aura::test::AuraTestHelper(message_loop));
}
@@ -24,7 +27,7 @@ ViewsTestHelperAura::~ViewsTestHelperAura() {
}
void ViewsTestHelperAura::SetUp() {
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory_);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
wm_state_.reset(new wm::WMState);
}
diff --git a/ui/views/test/views_test_helper_aura.h b/ui/views/test/views_test_helper_aura.h
index 1d6227a..b94bc36 100644
--- a/ui/views/test/views_test_helper_aura.h
+++ b/ui/views/test/views_test_helper_aura.h
@@ -28,7 +28,8 @@ namespace views {
class ViewsTestHelperAura : public ViewsTestHelper {
public:
- explicit ViewsTestHelperAura(base::MessageLoopForUI* message_loop);
+ ViewsTestHelperAura(base::MessageLoopForUI* message_loop,
+ ui::ContextFactory* context_factory);
virtual ~ViewsTestHelperAura();
// Overridden from ViewsTestHelper:
@@ -37,6 +38,7 @@ class ViewsTestHelperAura : public ViewsTestHelper {
virtual gfx::NativeView GetContext() OVERRIDE;
private:
+ ui::ContextFactory* context_factory_;
scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
scoped_ptr<wm::WMState> wm_state_;
diff --git a/ui/wm/test/wm_test_helper.cc b/ui/wm/test/wm_test_helper.cc
index 9a9af61..c74ddfe 100644
--- a/ui/wm/test/wm_test_helper.cc
+++ b/ui/wm/test/wm_test_helper.cc
@@ -14,8 +14,10 @@
namespace wm {
-WMTestHelper::WMTestHelper(const gfx::Size& default_window_size) {
+WMTestHelper::WMTestHelper(const gfx::Size& default_window_size,
+ ui::ContextFactory* context_factory) {
aura::Env::CreateInstance(true);
+ aura::Env::GetInstance()->set_context_factory(context_factory);
host_.reset(aura::WindowTreeHost::Create(gfx::Rect(default_window_size)));
host_->InitHost();
aura::client::SetWindowTreeClient(host_->window(), this);
diff --git a/ui/wm/test/wm_test_helper.h b/ui/wm/test/wm_test_helper.h
index 52707a4..79e15ff 100644
--- a/ui/wm/test/wm_test_helper.h
+++ b/ui/wm/test/wm_test_helper.h
@@ -24,6 +24,10 @@ class Rect;
class Size;
}
+namespace ui {
+class ContextFactory;
+}
+
namespace wm {
class CompoundEventFilter;
@@ -34,7 +38,8 @@ class InputMethodEventFilter;
// the ash parts of the code.
class WMTestHelper : public aura::client::WindowTreeClient {
public:
- explicit WMTestHelper(const gfx::Size& default_window_size);
+ WMTestHelper(const gfx::Size& default_window_size,
+ ui::ContextFactory* context_factory);
virtual ~WMTestHelper();
aura::WindowTreeHost* host() { return host_.get(); }