diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/aura.gyp | 4 | ||||
-rw-r--r-- | ui/aura/client/default_activation_client.cc (renamed from ui/aura/test/test_activation_client.cc) | 42 | ||||
-rw-r--r-- | ui/aura/client/default_activation_client.h (renamed from ui/aura/test/test_activation_client.h) | 26 | ||||
-rw-r--r-- | ui/aura/test/aura_test_helper.cc | 8 | ||||
-rw-r--r-- | ui/aura/test/aura_test_helper.h | 4 | ||||
-rw-r--r-- | ui/shell/DEPS | 4 | ||||
-rw-r--r-- | ui/shell/README.chromium | 2 | ||||
-rw-r--r-- | ui/shell/minimal_shell.cc | 56 | ||||
-rw-r--r-- | ui/shell/minimal_shell.h | 67 | ||||
-rw-r--r-- | ui/shell/shell.gyp | 21 | ||||
-rw-r--r-- | ui/views/DEPS | 6 | ||||
-rw-r--r-- | ui/views/corewm/compound_event_filter_unittest.cc | 1 | ||||
-rw-r--r-- | ui/views/corewm/input_method_event_filter_unittest.cc | 1 | ||||
-rw-r--r-- | ui/views/examples/content_client/examples_browser_main_parts.cc | 4 | ||||
-rw-r--r-- | ui/views/examples/content_client/examples_browser_main_parts.h | 7 | ||||
-rw-r--r-- | ui/views/views.gyp | 1 |
16 files changed, 208 insertions, 46 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index af6aa7b..539a115 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -44,6 +44,8 @@ 'client/cursor_client.h', 'client/cursor_client_observer.h', 'client/cursor_client_observer.cc', + 'client/default_activation_client.cc', + 'client/default_activation_client.h', 'client/default_capture_client.cc', 'client/default_capture_client.h', 'client/dispatcher_client.cc', @@ -143,8 +145,6 @@ 'test/aura_test_helper.h', 'test/event_generator.cc', 'test/event_generator.h', - 'test/test_activation_client.cc', - 'test/test_activation_client.h', 'test/test_aura_initializer.cc', 'test/test_aura_initializer.h', 'test/test_cursor_client.cc', diff --git a/ui/aura/test/test_activation_client.cc b/ui/aura/client/default_activation_client.cc index 14f6b30..84ff282 100644 --- a/ui/aura/test/test_activation_client.cc +++ b/ui/aura/client/default_activation_client.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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 "ui/aura/test/test_activation_client.h" +#include "ui/aura/client/default_activation_client.h" #include "ui/aura/client/activation_change_observer.h" #include "ui/aura/client/activation_delegate.h" @@ -10,36 +10,36 @@ #include "ui/aura/window.h" namespace aura { -namespace test { +namespace client { //////////////////////////////////////////////////////////////////////////////// -// TestActivationClient, public: +// DefaultActivationClient, public: -TestActivationClient::TestActivationClient(RootWindow* root_window) +DefaultActivationClient::DefaultActivationClient(RootWindow* root_window) : last_active_(NULL) { client::SetActivationClient(root_window, this); } -TestActivationClient::~TestActivationClient() { +DefaultActivationClient::~DefaultActivationClient() { for (unsigned int i = 0; i < active_windows_.size(); ++i) { active_windows_[i]->RemoveObserver(this); } } //////////////////////////////////////////////////////////////////////////////// -// TestActivationClient, client::ActivationClient implementation: +// DefaultActivationClient, client::ActivationClient implementation: -void TestActivationClient::AddObserver( +void DefaultActivationClient::AddObserver( client::ActivationChangeObserver* observer) { observers_.AddObserver(observer); } -void TestActivationClient::RemoveObserver( +void DefaultActivationClient::RemoveObserver( client::ActivationChangeObserver* observer) { observers_.RemoveObserver(observer); } -void TestActivationClient::ActivateWindow(Window* window) { +void DefaultActivationClient::ActivateWindow(Window* window) { Window* last_active = GetActiveWindow(); if (last_active == window) return; @@ -63,7 +63,7 @@ void TestActivationClient::ActivateWindow(Window* window) { observer->OnWindowActivated(window, last_active); } -void TestActivationClient::DeactivateWindow(Window* window) { +void DefaultActivationClient::DeactivateWindow(Window* window) { aura::client::ActivationChangeObserver* observer = aura::client::GetActivationChangeObserver(window); if (observer) @@ -72,33 +72,33 @@ void TestActivationClient::DeactivateWindow(Window* window) { ActivateWindow(last_active_); } -Window* TestActivationClient::GetActiveWindow() { +Window* DefaultActivationClient::GetActiveWindow() { if (active_windows_.empty()) return NULL; return active_windows_.back(); } -Window* TestActivationClient::GetActivatableWindow(Window* window) { +Window* DefaultActivationClient::GetActivatableWindow(Window* window) { return NULL; } -Window* TestActivationClient::GetToplevelWindow(Window* window) { +Window* DefaultActivationClient::GetToplevelWindow(Window* window) { return NULL; } -bool TestActivationClient::OnWillFocusWindow(Window* window, - const ui::Event* event) { +bool DefaultActivationClient::OnWillFocusWindow(Window* window, + const ui::Event* event) { return true; } -bool TestActivationClient::CanActivateWindow(Window* window) const { +bool DefaultActivationClient::CanActivateWindow(Window* window) const { return true; } //////////////////////////////////////////////////////////////////////////////// -// TestActivationClient, WindowObserver implementation: +// DefaultActivationClient, WindowObserver implementation: -void TestActivationClient::OnWindowDestroyed(Window* window) { +void DefaultActivationClient::OnWindowDestroyed(Window* window) { if (window == last_active_) last_active_ = NULL; @@ -116,7 +116,7 @@ void TestActivationClient::OnWindowDestroyed(Window* window) { RemoveActiveWindow(window); } -void TestActivationClient::RemoveActiveWindow(Window* window) { +void DefaultActivationClient::RemoveActiveWindow(Window* window) { for (unsigned int i = 0; i < active_windows_.size(); ++i) { if (active_windows_[i] == window) { active_windows_.erase(active_windows_.begin() + i); @@ -126,5 +126,5 @@ void TestActivationClient::RemoveActiveWindow(Window* window) { } } -} // namespace test +} // namespace client } // namespace aura diff --git a/ui/aura/test/test_activation_client.h b/ui/aura/client/default_activation_client.h index e5eb397..ebf04aa 100644 --- a/ui/aura/test/test_activation_client.h +++ b/ui/aura/client/default_activation_client.h @@ -1,12 +1,13 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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 UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ -#define UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ +#ifndef UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ +#define UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ #include "base/compiler_specific.h" #include "base/logging.h" +#include "ui/aura/aura_export.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/window_observer.h" @@ -16,13 +17,16 @@ namespace client { class ActivationChangeObserver; } -namespace test { +namespace client { -class TestActivationClient : public client::ActivationClient, - public WindowObserver { +// Simple ActivationClient implementation for use by tests and other targets +// that just need basic behavior (e.g. activate windows whenever requested, +// restack windows at the top when they're activated, etc.). +class AURA_EXPORT DefaultActivationClient : public client::ActivationClient, + public WindowObserver { public: - explicit TestActivationClient(RootWindow* root_window); - virtual ~TestActivationClient(); + explicit DefaultActivationClient(RootWindow* root_window); + virtual ~DefaultActivationClient(); // Overridden from client::ActivationClient: virtual void AddObserver(client::ActivationChangeObserver* observer) OVERRIDE; @@ -54,10 +58,10 @@ class TestActivationClient : public client::ActivationClient, ObserverList<client::ActivationChangeObserver> observers_; - DISALLOW_COPY_AND_ASSIGN(TestActivationClient); + DISALLOW_COPY_AND_ASSIGN(DefaultActivationClient); }; -} // namespace test +} // namespace client } // namespace aura -#endif // UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ +#endif // UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc index 6cd9d68..5309514 100644 --- a/ui/aura/test/aura_test_helper.cc +++ b/ui/aura/test/aura_test_helper.cc @@ -7,12 +7,12 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "ui/aura/client/aura_constants.h" +#include "ui/aura/client/default_activation_client.h" #include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/focus_client.h" #include "ui/aura/env.h" #include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" -#include "ui/aura/test/test_activation_client.h" #include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #include "ui/base/ime/dummy_input_method.h" @@ -73,8 +73,8 @@ void AuraTestHelper::SetUp() { focus_client_.reset(new FocusManager); client::SetFocusClient(root_window_.get(), focus_client_.get()); stacking_client_.reset(new TestStackingClient(root_window_.get())); - test_activation_client_.reset( - new test::TestActivationClient(root_window_.get())); + activation_client_.reset( + new client::DefaultActivationClient(root_window_.get())); capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); test_input_method_.reset(new ui::DummyInputMethod); root_window_->SetProperty( @@ -90,7 +90,7 @@ void AuraTestHelper::TearDown() { teardown_called_ = true; test_input_method_.reset(); stacking_client_.reset(); - test_activation_client_.reset(); + activation_client_.reset(); capture_client_.reset(); focus_client_.reset(); root_window_.reset(); diff --git a/ui/aura/test/aura_test_helper.h b/ui/aura/test/aura_test_helper.h index 9973dbd..02f9c31 100644 --- a/ui/aura/test/aura_test_helper.h +++ b/ui/aura/test/aura_test_helper.h @@ -25,11 +25,11 @@ namespace aura { class RootWindow; class TestScreen; namespace client { +class DefaultActivationClient; class DefaultCaptureClient; class FocusClient; } namespace test { -class TestActivationClient; class TestStackingClient; // A helper class owned by tests that does common initialization required for @@ -61,7 +61,7 @@ class AuraTestHelper { bool owns_root_window_; scoped_ptr<RootWindow> root_window_; scoped_ptr<TestStackingClient> stacking_client_; - scoped_ptr<TestActivationClient> test_activation_client_; + scoped_ptr<client::DefaultActivationClient> activation_client_; scoped_ptr<client::DefaultCaptureClient> capture_client_; scoped_ptr<ui::InputMethod> test_input_method_; scoped_ptr<client::FocusClient> focus_client_; diff --git a/ui/shell/DEPS b/ui/shell/DEPS new file mode 100644 index 0000000..78adcc9 --- /dev/null +++ b/ui/shell/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+ui/aura", + "+ui/views", +] diff --git a/ui/shell/README.chromium b/ui/shell/README.chromium new file mode 100644 index 0000000..9678777 --- /dev/null +++ b/ui/shell/README.chromium @@ -0,0 +1,2 @@ +This directory contains a minimal shell implementation built using Aura and +Views. diff --git a/ui/shell/minimal_shell.cc b/ui/shell/minimal_shell.cc new file mode 100644 index 0000000..9c3ca11 --- /dev/null +++ b/ui/shell/minimal_shell.cc @@ -0,0 +1,56 @@ +// Copyright 2013 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 "ui/shell/minimal_shell.h" + +#include "ui/aura/client/default_activation_client.h" +#include "ui/aura/client/default_capture_client.h" +#include "ui/aura/env.h" +#include "ui/aura/focus_manager.h" +#include "ui/aura/root_window.h" +#include "ui/views/corewm/compound_event_filter.h" +#include "ui/views/corewm/input_method_event_filter.h" + +namespace shell { + +MinimalShell::MinimalShell(const gfx::Size& default_window_size) { + aura::Env::CreateInstance(); + root_window_.reset(new aura::RootWindow( + aura::RootWindow::CreateParams( + gfx::Rect(default_window_size)))); + root_window_->Init(); + aura::client::SetStackingClient(root_window_.get(), this); + + focus_client_.reset(new aura::FocusManager); + aura::client::SetFocusClient(root_window_.get(), focus_client_.get()); + + root_window_event_filter_ = new views::corewm::CompoundEventFilter; + // Pass ownership of the filter to the root_window. + root_window_->SetEventFilter(root_window_event_filter_); + + input_method_filter_.reset(new views::corewm::InputMethodEventFilter( + root_window_->GetAcceleratedWidget())); + input_method_filter_->SetInputMethodPropertyInRootWindow( + root_window_.get()); + root_window_event_filter_->AddHandler(input_method_filter_.get()); + + activation_client_.reset( + new aura::client::DefaultActivationClient(root_window_.get())); + + capture_client_.reset( + new aura::client::DefaultCaptureClient(root_window_.get())); +} + +MinimalShell::~MinimalShell() { + root_window_event_filter_->RemoveHandler(input_method_filter_.get()); +} + +aura::Window* MinimalShell::GetDefaultParent( + aura::Window* context, + aura::Window* window, + const gfx::Rect& bounds) { + return root_window_.get(); +} + +} // namespace shell diff --git a/ui/shell/minimal_shell.h b/ui/shell/minimal_shell.h new file mode 100644 index 0000000..f8ae67b --- /dev/null +++ b/ui/shell/minimal_shell.h @@ -0,0 +1,67 @@ +// Copyright 2013 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 UI_SHELL_MINIMAL_SHELL_H_ +#define UI_SHELL_MINIMAL_SHELL_H_ + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "ui/aura/client/stacking_client.h" + +namespace aura { +class RootWindow; +class Window; +namespace client { +class DefaultActivationClient; +class DefaultCaptureClient; +class FocusClient; +} // class client +} // class aura + +namespace gfx { +class Rect; +class Size; +} // class gfx + +namespace views { +namespace corewm { +class CompoundEventFilter; +class InputMethodEventFilter; +} // corewm +} // views + +namespace shell { + +// Creates a minimal environment for running the shell. We can't pull in all of +// ash here, but we can create attach several of the same things we'd find in +// the ash parts of the code. +class MinimalShell : public aura::client::StackingClient { + public: + explicit MinimalShell(const gfx::Size& default_window_size); + virtual ~MinimalShell(); + + aura::RootWindow* root_window() { return root_window_.get(); } + + // Overridden from client::StackingClient: + virtual aura::Window* GetDefaultParent(aura::Window* context, + aura::Window* window, + const gfx::Rect& bounds) OVERRIDE; + + private: + scoped_ptr<aura::RootWindow> root_window_; + + // Owned by RootWindow + views::corewm::CompoundEventFilter* root_window_event_filter_; + + scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; + scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_; + scoped_ptr<aura::client::DefaultActivationClient> activation_client_; + scoped_ptr<aura::client::FocusClient> focus_client_; + + DISALLOW_COPY_AND_ASSIGN(MinimalShell); +}; + +} // namespace shell + +#endif // UI_SHELL_MINIMAL_SHELL_H_ diff --git a/ui/shell/shell.gyp b/ui/shell/shell.gyp new file mode 100644 index 0000000..7c5c595 --- /dev/null +++ b/ui/shell/shell.gyp @@ -0,0 +1,21 @@ +# Copyright 2013 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. + +{ + 'targets': [ + { + 'target_name': 'shell', + 'type': 'static_library', + 'dependencies': [ + '../aura/aura.gyp:aura', + '../views/views.gyp:views', + '../../skia/skia.gyp:skia', + ], + 'sources': [ + 'minimal_shell.cc', + 'minimal_shell.h', + ], + }, + ], +} diff --git a/ui/views/DEPS b/ui/views/DEPS index 483d4c0..80e217e 100644 --- a/ui/views/DEPS +++ b/ui/views/DEPS @@ -11,3 +11,9 @@ include_rules = [ "+ui/gfx", "+ui/native_theme", ] + +specific_include_rules = { + "examples_browser_main_parts\.cc": [ + "+ui/shell" + ], +} diff --git a/ui/views/corewm/compound_event_filter_unittest.cc b/ui/views/corewm/compound_event_filter_unittest.cc index 75ff9f46..11e7d6c 100644 --- a/ui/views/corewm/compound_event_filter_unittest.cc +++ b/ui/views/corewm/compound_event_filter_unittest.cc @@ -10,7 +10,6 @@ #include "ui/aura/root_window.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/event_generator.h" -#include "ui/aura/test/test_activation_client.h" #include "ui/aura/test/test_cursor_client.h" #include "ui/aura/test/test_windows.h" #include "ui/events/event.h" diff --git a/ui/views/corewm/input_method_event_filter_unittest.cc b/ui/views/corewm/input_method_event_filter_unittest.cc index a5927ab..76cabfa 100644 --- a/ui/views/corewm/input_method_event_filter_unittest.cc +++ b/ui/views/corewm/input_method_event_filter_unittest.cc @@ -12,7 +12,6 @@ #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/event_generator.h" #include "ui/aura/test/test_event_handler.h" -#include "ui/aura/test/test_activation_client.h" #include "ui/aura/test/test_windows.h" #if !defined(OS_WIN) && !defined(USE_X11) 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 42ef2b8..9a16191 100644 --- a/ui/views/examples/content_client/examples_browser_main_parts.cc +++ b/ui/views/examples/content_client/examples_browser_main_parts.cc @@ -26,9 +26,9 @@ #endif #if defined(OS_CHROMEOS) -#include "content/shell/browser/minimal_shell.h" #include "ui/aura/root_window.h" #include "ui/aura/test/test_screen.h" +#include "ui/shell/minimal_shell.h" #endif namespace views { @@ -49,7 +49,7 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() { gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); // Set up basic pieces of views::corewm. - minimal_shell_.reset(new content::MinimalShell(gfx::Size(800, 600))); + minimal_shell_.reset(new shell::MinimalShell(gfx::Size(800, 600))); // Ensure the X window gets mapped. minimal_shell_->root_window()->ShowRootWindow(); // Ensure Aura knows where to open new windows. diff --git a/ui/views/examples/content_client/examples_browser_main_parts.h b/ui/views/examples/content_client/examples_browser_main_parts.h index ef7eb05..f272ff8 100644 --- a/ui/views/examples/content_client/examples_browser_main_parts.h +++ b/ui/views/examples/content_client/examples_browser_main_parts.h @@ -10,11 +10,14 @@ #include "content/public/browser/browser_main_parts.h" namespace content { -class MinimalShell; class ShellBrowserContext; struct MainFunctionParams; } +namespace shell { +class MinimalShell; +} + namespace views { class ViewsDelegate; @@ -42,7 +45,7 @@ class ExamplesBrowserMainParts : public content::BrowserMainParts { #if defined(OS_CHROMEOS) // Enable a minimal set of views::corewm to be initialized. - scoped_ptr<content::MinimalShell> minimal_shell_; + scoped_ptr<shell::MinimalShell> minimal_shell_; #endif DISALLOW_COPY_AND_ASSIGN(ExamplesBrowserMainParts); diff --git a/ui/views/views.gyp b/ui/views/views.gyp index fcdade3..f701848 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -1036,6 +1036,7 @@ '../../third_party/icu/icu.gyp:icuuc', '../events/events.gyp:events', '../gfx/gfx.gyp:gfx', + '../shell/shell.gyp:shell', '../ui.gyp:ui', '../ui.gyp:ui_resources', 'views', |