summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2014-08-25 14:32:49 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-25 21:35:50 +0000
commit1629c184e328e7263e93042de97af58651ebe510 (patch)
tree5d91c6827fc18651b95c6530c7da403a162ea8e0 /athena
parentd27cb086ffcbfdc4c3f5b1d1d483b28dff5bd26c (diff)
downloadchromium_src-1629c184e328e7263e93042de97af58651ebe510.zip
chromium_src-1629c184e328e7263e93042de97af58651ebe510.tar.gz
chromium_src-1629c184e328e7263e93042de97af58651ebe510.tar.bz2
Separate athena's startup process from AppShell's
* Introduced DesktopController interface. app_shell's Init process stays in ShellDesktopController * Removed ShellAppWindowController * Athena has its own AthenaDesktopController * Intorduced AthenaEnv. This is now used for both AthenaMain and Unit test. * Removed ScreenManagerDelegate and integrate it into AthenaEnv. * Moved FocusController to ScreenManager, and removed CreateFocusRules() BUG=397167 TBR=sky@chromium.org Review URL: https://codereview.chromium.org/480353006 Cr-Commit-Position: refs/heads/master@{#291763}
Diffstat (limited to 'athena')
-rw-r--r--athena/athena.gyp5
-rw-r--r--athena/env/DEPS9
-rw-r--r--athena/env/athena_env_impl.cc260
-rw-r--r--athena/env/public/DEPS4
-rw-r--r--athena/env/public/athena_env.h39
-rw-r--r--athena/home/DEPS1
-rw-r--r--athena/home/home_card_impl.cc3
-rw-r--r--athena/main/DEPS1
-rw-r--r--athena/main/athena_launcher.cc12
-rw-r--r--athena/main/athena_launcher.h5
-rw-r--r--athena/main/athena_main.cc70
-rw-r--r--athena/main/athena_main.gyp2
-rw-r--r--athena/screen/public/screen_manager.h10
-rw-r--r--athena/screen/public/screen_manager_delegate.h27
-rw-r--r--athena/screen/screen_manager_impl.cc40
-rw-r--r--athena/test/DEPS3
-rw-r--r--athena/test/athena_test_base.h4
-rw-r--r--athena/test/athena_test_helper.cc63
-rw-r--r--athena/test/athena_test_helper.h10
-rw-r--r--athena/test/test_screen_manager_delegate.cc24
-rw-r--r--athena/test/test_screen_manager_delegate.h36
21 files changed, 391 insertions, 237 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index 836f947..e59cbea 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -48,6 +48,8 @@
'common/fill_layout_manager.h',
'common/switches.cc',
'common/switches.h',
+ 'env/athena_env_impl.cc',
+ 'env/public/athena_env.h',
'home/app_list_view_delegate.cc',
'home/app_list_view_delegate.h',
'home/athena_start_page_view.cc',
@@ -65,7 +67,6 @@
'screen/background_controller.cc',
'screen/background_controller.h',
'screen/public/screen_manager.h',
- 'screen/public/screen_manager_delegate.h',
'screen/screen_accelerator_handler.cc',
'screen/screen_accelerator_handler.h',
'screen/screen_manager_impl.cc',
@@ -187,8 +188,6 @@
'test/test_app_content_control_delegate_impl.cc',
'test/test_app_model_builder.cc',
'test/test_app_model_builder.h',
- 'test/test_screen_manager_delegate.cc',
- 'test/test_screen_manager_delegate.h',
'wm/test/window_manager_impl_test_api.cc',
'wm/test/window_manager_impl_test_api.h',
],
diff --git a/athena/env/DEPS b/athena/env/DEPS
new file mode 100644
index 0000000..bcac64e
--- /dev/null
+++ b/athena/env/DEPS
@@ -0,0 +1,9 @@
+include_rules = [
+ "+chromeos/dbus",
+ "+ui/aura",
+ "+ui/base",
+ "+ui/chromeos",
+ "+ui/display",
+ "+ui/gfx",
+ "+ui/wm",
+]
diff --git a/athena/env/athena_env_impl.cc b/athena/env/athena_env_impl.cc
new file mode 100644
index 0000000..d94291b
--- /dev/null
+++ b/athena/env/athena_env_impl.cc
@@ -0,0 +1,260 @@
+// Copyright 2014 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 "athena/env/public/athena_env.h"
+
+#include "athena/common/fill_layout_manager.h"
+#include "base/sys_info.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/cursor_client.h"
+#include "ui/aura/client/default_capture_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/test/test_screen.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/aura/window_tree_host_observer.h"
+#include "ui/base/cursor/cursor.h"
+#include "ui/base/cursor/image_cursors.h"
+#include "ui/chromeos/user_activity_power_manager_notifier.h"
+#include "ui/display/chromeos/display_configurator.h"
+#include "ui/display/types/chromeos/display_mode.h"
+#include "ui/display/types/chromeos/display_snapshot.h"
+#include "ui/gfx/screen.h"
+#include "ui/wm/core/compound_event_filter.h"
+#include "ui/wm/core/cursor_manager.h"
+#include "ui/wm/core/input_method_event_filter.h"
+#include "ui/wm/core/native_cursor_manager.h"
+#include "ui/wm/core/native_cursor_manager_delegate.h"
+#include "ui/wm/core/user_activity_detector.h"
+
+namespace athena {
+
+namespace {
+
+AthenaEnv* instance = NULL;
+
+// A class that bridges the gap between CursorManager and Aura. It borrows
+// heavily from AshNativeCursorManager.
+class AthenaNativeCursorManager : public wm::NativeCursorManager {
+ public:
+ explicit AthenaNativeCursorManager(aura::WindowTreeHost* host)
+ : host_(host), image_cursors_(new ui::ImageCursors) {}
+ virtual ~AthenaNativeCursorManager() {}
+
+ // wm::NativeCursorManager overrides.
+ virtual void SetDisplay(const gfx::Display& display,
+ wm::NativeCursorManagerDelegate* delegate) OVERRIDE {
+ if (image_cursors_->SetDisplay(display, display.device_scale_factor()))
+ SetCursor(delegate->GetCursor(), delegate);
+ }
+
+ virtual void SetCursor(gfx::NativeCursor cursor,
+ wm::NativeCursorManagerDelegate* delegate) OVERRIDE {
+ image_cursors_->SetPlatformCursor(&cursor);
+ cursor.set_device_scale_factor(image_cursors_->GetScale());
+ delegate->CommitCursor(cursor);
+
+ if (delegate->IsCursorVisible())
+ ApplyCursor(cursor);
+ }
+
+ virtual void SetVisibility(
+ bool visible,
+ wm::NativeCursorManagerDelegate* delegate) OVERRIDE {
+ delegate->CommitVisibility(visible);
+
+ if (visible) {
+ SetCursor(delegate->GetCursor(), delegate);
+ } else {
+ gfx::NativeCursor invisible_cursor(ui::kCursorNone);
+ image_cursors_->SetPlatformCursor(&invisible_cursor);
+ ApplyCursor(invisible_cursor);
+ }
+ }
+
+ virtual void SetCursorSet(
+ ui::CursorSetType cursor_set,
+ wm::NativeCursorManagerDelegate* delegate) OVERRIDE {
+ image_cursors_->SetCursorSet(cursor_set);
+ delegate->CommitCursorSet(cursor_set);
+ if (delegate->IsCursorVisible())
+ SetCursor(delegate->GetCursor(), delegate);
+ }
+
+ virtual void SetMouseEventsEnabled(
+ bool enabled,
+ wm::NativeCursorManagerDelegate* delegate) OVERRIDE {
+ delegate->CommitMouseEventsEnabled(enabled);
+ SetVisibility(delegate->IsCursorVisible(), delegate);
+ }
+
+ private:
+ // Sets |cursor| as the active cursor within Aura.
+ void ApplyCursor(gfx::NativeCursor cursor) { host_->SetCursor(cursor); }
+
+ aura::WindowTreeHost* host_; // Not owned.
+
+ scoped_ptr<ui::ImageCursors> image_cursors_;
+
+ DISALLOW_COPY_AND_ASSIGN(AthenaNativeCursorManager);
+};
+
+class AthenaEnvImpl : public AthenaEnv,
+ public aura::WindowTreeHostObserver,
+ public ui::DisplayConfigurator::Observer {
+ public:
+ AthenaEnvImpl() : display_configurator_(new ui::DisplayConfigurator) {
+ display_configurator_->Init(false);
+ display_configurator_->ForceInitialConfigure(0);
+ display_configurator_->AddObserver(this);
+
+ gfx::Size screen_size = GetPrimaryDisplaySize();
+ if (screen_size.IsEmpty()) {
+ // TODO(oshima): Remove this hack.
+ if (base::SysInfo::IsRunningOnChromeOS())
+ screen_size.SetSize(2560, 1600);
+ else
+ screen_size.SetSize(1280, 720);
+ }
+ screen_.reset(aura::TestScreen::Create(screen_size));
+
+ gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
+ host_.reset(screen_->CreateHostForPrimaryDisplay());
+ host_->InitHost();
+
+ aura::Window* root_window = GetHost()->window();
+ input_method_filter_.reset(
+ new wm::InputMethodEventFilter(host_->GetAcceleratedWidget()));
+ input_method_filter_->SetInputMethodPropertyInRootWindow(root_window);
+
+ root_window_event_filter_.reset(new wm::CompoundEventFilter);
+ host_->window()->AddPreTargetHandler(root_window_event_filter_.get());
+
+ input_method_filter_.reset(
+ new wm::InputMethodEventFilter(host_->GetAcceleratedWidget()));
+ input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window());
+ root_window_event_filter_->AddHandler(input_method_filter_.get());
+
+ capture_client_.reset(
+ new aura::client::DefaultCaptureClient(host_->window()));
+
+ // Ensure new windows fill the display.
+ root_window->SetLayoutManager(new FillLayoutManager(root_window));
+
+ cursor_manager_.reset(
+ new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>(
+ new AthenaNativeCursorManager(host_.get()))));
+ cursor_manager_->SetDisplay(
+ gfx::Screen::GetNativeScreen()->GetPrimaryDisplay());
+ cursor_manager_->SetCursor(ui::kCursorPointer);
+ aura::client::SetCursorClient(host_->window(), cursor_manager_.get());
+
+ user_activity_detector_.reset(new wm::UserActivityDetector);
+ host_->event_processor()->GetRootTarget()->AddPreTargetHandler(
+ user_activity_detector_.get());
+ user_activity_notifier_.reset(new ui::UserActivityPowerManagerNotifier(
+ user_activity_detector_.get()));
+
+ host_->AddObserver(this);
+ host_->Show();
+
+ DCHECK(!instance);
+ instance = this;
+ }
+
+ virtual ~AthenaEnvImpl() {
+ instance = NULL;
+
+ host_->RemoveObserver(this);
+ if (input_method_filter_)
+ root_window_event_filter_->RemoveHandler(input_method_filter_.get());
+ if (user_activity_detector_) {
+ host_->event_processor()->GetRootTarget()->RemovePreTargetHandler(
+ user_activity_detector_.get());
+ }
+ root_window_event_filter_.reset();
+ capture_client_.reset();
+ input_method_filter_.reset();
+ cursor_manager_.reset();
+ user_activity_notifier_.reset();
+ user_activity_detector_.reset();
+
+ input_method_filter_.reset();
+ host_.reset();
+ screen_.reset();
+ gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL);
+
+ aura::Env::DeleteInstance();
+
+ display_configurator_->RemoveObserver(this);
+ display_configurator_.reset();
+ }
+
+ private:
+ virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); }
+
+ // AthenaEnv:
+ virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) OVERRIDE {
+ screen_->SetWorkAreaInsets(insets);
+ }
+
+ // ui::DisplayConfigurator::Observer:
+ virtual void OnDisplayModeChanged(const std::vector<
+ ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE {
+ gfx::Size size = GetPrimaryDisplaySize();
+ if (!size.IsEmpty())
+ host_->UpdateRootWindowSize(size);
+ }
+
+ // aura::WindowTreeHostObserver:
+ virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE {
+ base::MessageLoopForUI::current()->PostTask(
+ FROM_HERE, base::MessageLoop::QuitClosure());
+ }
+
+ gfx::Size GetPrimaryDisplaySize() const {
+ const std::vector<ui::DisplayConfigurator::DisplayState>& displays =
+ display_configurator_->cached_displays();
+ if (displays.empty())
+ return gfx::Size();
+ const ui::DisplayMode* mode = displays[0].display->current_mode();
+ return mode ? mode->size() : gfx::Size();
+ }
+
+ scoped_ptr<aura::TestScreen> screen_;
+ scoped_ptr<aura::WindowTreeHost> host_;
+
+ scoped_ptr<wm::InputMethodEventFilter> input_method_filter_;
+ scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_;
+ scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
+ scoped_ptr<wm::CursorManager> cursor_manager_;
+ scoped_ptr<wm::UserActivityDetector> user_activity_detector_;
+ scoped_ptr<ui::DisplayConfigurator> display_configurator_;
+ scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
+
+ DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl);
+};
+
+} // namespace
+
+// static
+void AthenaEnv::Create() {
+ DCHECK(!instance);
+ new AthenaEnvImpl();
+}
+
+AthenaEnv* AthenaEnv::Get() {
+ DCHECK(instance);
+ return instance;
+}
+
+// static
+
+// static
+void AthenaEnv::Shutdown() {
+ DCHECK(instance);
+ delete instance;
+}
+
+} // namespace athena
diff --git a/athena/env/public/DEPS b/athena/env/public/DEPS
new file mode 100644
index 0000000..c97ecd3
--- /dev/null
+++ b/athena/env/public/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "-athena/env",
+ "+athena/athena_export.h",
+]
diff --git a/athena/env/public/athena_env.h b/athena/env/public/athena_env.h
new file mode 100644
index 0000000..703a87f
--- /dev/null
+++ b/athena/env/public/athena_env.h
@@ -0,0 +1,39 @@
+// Copyright 2014 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 ATHENA_ENV_PUBLIC_ATHENA_ENV_H_
+#define ATHENA_ENV_PUBLIC_ATHENA_ENV_H_
+
+#include "athena/athena_export.h"
+
+namespace gfx {
+class Insets;
+}
+
+namespace aura {
+class WindowTreeHost;
+}
+
+namespace athena {
+
+// AthenaEnv creates/shuts down the environment necessary to
+// start Athena shell.
+class ATHENA_EXPORT AthenaEnv {
+ public:
+ static void Create();
+ static AthenaEnv* Get();
+ static void Shutdown();
+
+ virtual ~AthenaEnv() {}
+
+ // Returns the single WindowTreeHost for the primary display.
+ virtual aura::WindowTreeHost* GetHost() = 0;
+
+ // Sets the insets for the primary displays's work area.
+ virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) = 0;
+};
+
+} // namespace athena
+
+#endif // ATHENA_ENV_PUBLIC_ATHENA_ENV_H_
diff --git a/athena/home/DEPS b/athena/home/DEPS
index 93860d06..768b162 100644
--- a/athena/home/DEPS
+++ b/athena/home/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+athena/env/public",
"+athena/input/public",
"+athena/screen/public",
"+athena/wm/public",
diff --git a/athena/home/home_card_impl.cc b/athena/home/home_card_impl.cc
index 7b73bc2..a82234b 100644
--- a/athena/home/home_card_impl.cc
+++ b/athena/home/home_card_impl.cc
@@ -8,6 +8,7 @@
#include <limits>
#include "athena/common/container_priorities.h"
+#include "athena/env/public/athena_env.h"
#include "athena/home/app_list_view_delegate.h"
#include "athena/home/athena_start_page_view.h"
#include "athena/home/minimized_home.h"
@@ -526,7 +527,7 @@ void HomeCardImpl::Init() {
int work_area_bottom_inset =
GetBoundsForState(GetNativeWindow()->bounds(),
HomeCard::VISIBLE_MINIMIZED).height();
- ScreenManager::Get()->SetWorkAreaInsets(
+ AthenaEnv::Get()->SetDisplayWorkAreaInsets(
gfx::Insets(0, 0, work_area_bottom_inset, 0));
}
diff --git a/athena/main/DEPS b/athena/main/DEPS
index c92113c..2dee0498 100644
--- a/athena/main/DEPS
+++ b/athena/main/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+athena/activity/public",
"+athena/content/public",
+ "+athena/env/public",
"+athena/extensions/public",
"+athena/home/public",
"+athena/input/public",
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index 700b869..d34be25 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -9,6 +9,7 @@
#include "athena/content/public/app_registry.h"
#include "athena/content/public/content_activity_factory.h"
#include "athena/content/public/content_app_model_builder.h"
+#include "athena/env/public/athena_env.h"
#include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/home_card.h"
#include "athena/home/public/home_card.h"
@@ -26,6 +27,7 @@
#include "base/memory/scoped_ptr.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/aura/window_property.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_controller_observer.h"
#include "ui/native_theme/native_theme_switches.h"
@@ -92,9 +94,9 @@ class AthenaViewsDelegate : public views::ViewsDelegate {
DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate);
};
-void StartAthenaEnv(aura::Window* root_window,
- athena::ScreenManagerDelegate* delegate,
- scoped_refptr<base::TaskRunner> file_runner) {
+void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) {
+ athena::AthenaEnv::Create();
+
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Force showing in the experimental app-list view.
@@ -111,13 +113,14 @@ void StartAthenaEnv(aura::Window* root_window,
// Setup VisibilityClient
env_state->visibility_client.reset(new ::wm::VisibilityController);
+ aura::Window* root_window = athena::AthenaEnv::Get()->GetHost()->window();
aura::client::SetVisibilityClient(root_window,
env_state->visibility_client.get());
athena::SystemUI::Create(file_runner);
athena::InputManager::Create()->OnRootWindowCreated(root_window);
- athena::ScreenManager::Create(delegate, root_window);
+ athena::ScreenManager::Create(root_window);
athena::WindowManager::Create();
athena::AppRegistry::Create();
SetupBackgroundImage();
@@ -159,6 +162,7 @@ void ShutdownAthena() {
athena::InputManager::Shutdown();
athena::SystemUI::Shutdown();
athena::ExtensionsDelegate::Shutdown();
+ athena::AthenaEnv::Shutdown();
delete views::ViewsDelegate::views_delegate;
}
diff --git a/athena/main/athena_launcher.h b/athena/main/athena_launcher.h
index c256e7d..cf08dc7 100644
--- a/athena/main/athena_launcher.h
+++ b/athena/main/athena_launcher.h
@@ -22,12 +22,9 @@ class BrowserContext;
namespace athena {
class ActivityFactory;
class AppModelBuilder;
-class ScreenManagerDelegate;
// Starts down the athena shell environment.
-void StartAthenaEnv(aura::Window* root_window,
- ScreenManagerDelegate* screen_manager_delegate,
- scoped_refptr<base::TaskRunner> file_runner);
+void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner);
void StartAthenaSessionWithContext(content::BrowserContext* context);
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index 3d5408e..29cbd56 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -2,20 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "athena/activity/public/activity_factory.h"
+#include "athena/activity/public/activity_manager.h"
#include "athena/content/public/web_contents_view_delegate_creator.h"
-#include "athena/main/athena_app_window_controller.h"
+#include "athena/env/public/athena_env.h"
#include "athena/main/athena_launcher.h"
#include "athena/screen/public/screen_manager.h"
-#include "athena/screen/public/screen_manager_delegate.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "content/public/app/content_main.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/shell/app/shell_main_delegate.h"
+#include "extensions/shell/browser/desktop_controller.h"
+#include "extensions/shell/browser/shell_app_window.h"
#include "extensions/shell/browser/shell_browser_main_delegate.h"
#include "extensions/shell/browser/shell_content_browser_client.h"
-#include "extensions/shell/browser/shell_desktop_controller.h"
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/common/switches.h"
#include "ui/aura/window_tree_host.h"
@@ -31,40 +33,33 @@ const char kDefaultAppPath[] =
} // namespace athena
-class AthenaDesktopController : public extensions::ShellDesktopController {
+class AthenaDesktopController : public extensions::DesktopController {
public:
AthenaDesktopController() {}
virtual ~AthenaDesktopController() {}
private:
- // extensions::ShellDesktopController:
- virtual wm::FocusRules* CreateFocusRules() OVERRIDE {
- return athena::ScreenManager::CreateFocusRules();
+ // extensions::DesktopController:
+ virtual aura::WindowTreeHost* GetHost() OVERRIDE {
+ return athena::AthenaEnv::Get()->GetHost();
}
- DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController);
-};
-
-class AthenaScreenManagerDelegate : public athena::ScreenManagerDelegate {
- public:
- explicit AthenaScreenManagerDelegate(
- extensions::ShellDesktopController* controller)
- : controller_(controller) {
- }
-
- virtual ~AthenaScreenManagerDelegate() {
+ // Creates a new app window and adds it to the desktop. The desktop maintains
+ // ownership of the window.
+ virtual extensions::ShellAppWindow* CreateAppWindow(
+ content::BrowserContext* context,
+ const extensions::Extension* extension) OVERRIDE {
+ extensions::ShellAppWindow* app_window = new extensions::ShellAppWindow();
+ app_window->Init(context, extension, gfx::Size(100, 100));
+ athena::ActivityManager::Get()->AddActivity(
+ athena::ActivityFactory::Get()->CreateAppActivity(app_window));
+ return app_window;
}
- private:
- // athena::ScreenManagerDelegate:
- virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE {
- controller_->SetDisplayWorkAreaInsets(insets);
- }
-
- // Not owned.
- extensions::ShellDesktopController* controller_;
+ // Closes and destroys the app windows.
+ virtual void CloseAppWindows() OVERRIDE {}
- DISALLOW_COPY_AND_ASSIGN(AthenaScreenManagerDelegate);
+ DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController);
};
class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
@@ -90,14 +85,8 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
extension_system->LoadApp(app_absolute_dir);
}
- extensions::ShellDesktopController* desktop_controller =
- extensions::ShellDesktopController::instance();
- screen_manager_delegate_.reset(
- new AthenaScreenManagerDelegate(desktop_controller));
- athena::StartAthenaEnv(desktop_controller->host()->window(),
- screen_manager_delegate_.get(),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::FILE));
+ athena::StartAthenaEnv(content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::FILE));
athena::StartAthenaSessionWithContext(context);
}
@@ -105,18 +94,11 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
athena::ShutdownAthena();
}
- virtual extensions::ShellDesktopController* CreateDesktopController()
- OVERRIDE {
- // TODO(mukai): create Athena's own ShellDesktopController subclass so that
- // it can initialize its own window manager logic.
- extensions::ShellDesktopController* desktop = new AthenaDesktopController();
- desktop->SetAppWindowController(new athena::AthenaAppWindowController());
- return desktop;
+ virtual extensions::DesktopController* CreateDesktopController() OVERRIDE {
+ return new AthenaDesktopController();
}
private:
- scoped_ptr<AthenaScreenManagerDelegate> screen_manager_delegate_;
-
DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
};
diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp
index ca41290..21d6e55 100644
--- a/athena/main/athena_main.gyp
+++ b/athena/main/athena_main.gyp
@@ -63,8 +63,6 @@
'../..',
],
'sources': [
- 'athena_app_window_controller.cc',
- 'athena_app_window_controller.h',
'athena_main.cc',
],
}
diff --git a/athena/screen/public/screen_manager.h b/athena/screen/public/screen_manager.h
index efaa7e8..52dd805 100644
--- a/athena/screen/public/screen_manager.h
+++ b/athena/screen/public/screen_manager.h
@@ -51,16 +51,12 @@ class ATHENA_EXPORT ScreenManager {
// Creates, returns and deletes the singleton object of the ScreenManager
// implementation.
- static ScreenManager* Create(ScreenManagerDelegate* delegate,
- aura::Window* root);
+ static ScreenManager* Create(aura::Window* root);
static ScreenManager* Get();
static void Shutdown();
virtual ~ScreenManager() {}
- // Sets the screen's work area insets.
- virtual void SetWorkAreaInsets(const gfx::Insets& insets) = 0;
-
// Creates the container window that is used when creating a normal
// widget without specific parent.
virtual aura::Window* CreateDefaultContainer(
@@ -83,10 +79,6 @@ class ATHENA_EXPORT ScreenManager {
// Returns the LayerAnimator to use to animate the entire screen (e.g. fade
// screen to white).
virtual ui::LayerAnimator* GetScreenAnimator() = 0;
-
- // Create a focus rules.
- // TODO(oshima): Make this virtual function.
- static wm::FocusRules* CreateFocusRules();
};
} // namespace athena
diff --git a/athena/screen/public/screen_manager_delegate.h b/athena/screen/public/screen_manager_delegate.h
deleted file mode 100644
index dab259546..0000000
--- a/athena/screen/public/screen_manager_delegate.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 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 ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
-#define ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
-
-#include "athena/athena_export.h"
-
-namespace gfx {
-class Insets;
-}
-
-namespace athena {
-
-// Delegate of the ScreenManager.
-class ATHENA_EXPORT ScreenManagerDelegate {
- public:
- virtual ~ScreenManagerDelegate() {}
-
- // Sets the screen's work area insets.
- virtual void SetWorkAreaInsets(const gfx::Insets& insets) = 0;
-};
-
-} // namespace athena
-
-#endif // ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index 166055c..a154d52 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -8,7 +8,6 @@
#include "athena/common/fill_layout_manager.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/screen/background_controller.h"
-#include "athena/screen/public/screen_manager_delegate.h"
#include "athena/screen/screen_accelerator_handler.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -25,6 +24,7 @@
#include "ui/gfx/screen.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/capture_controller.h"
+#include "ui/wm/core/focus_controller.h"
namespace athena {
namespace {
@@ -192,14 +192,13 @@ class AthenaEventTargeter : public aura::WindowTargeter,
class ScreenManagerImpl : public ScreenManager {
public:
- ScreenManagerImpl(ScreenManagerDelegate* delegate, aura::Window* root_window);
+ ScreenManagerImpl(aura::Window* root_window);
virtual ~ScreenManagerImpl();
void Init();
private:
// ScreenManager:
- virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE;
virtual aura::Window* CreateDefaultContainer(
const ContainerParams& params) OVERRIDE;
virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
@@ -209,10 +208,10 @@ class ScreenManagerImpl : public ScreenManager {
virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE;
// Not owned.
- ScreenManagerDelegate* delegate_;
aura::Window* root_window_;
aura::Window* background_window_;
+ scoped_ptr<aura::client::FocusClient> focus_client_;
scoped_ptr<BackgroundController> background_controller_;
scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
scoped_ptr<AcceleratorHandler> accelerator_handler_;
@@ -222,10 +221,8 @@ class ScreenManagerImpl : public ScreenManager {
DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl);
};
-ScreenManagerImpl::ScreenManagerImpl(ScreenManagerDelegate* delegate,
- aura::Window* root_window)
- : delegate_(delegate),
- root_window_(root_window) {
+ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window)
+ : root_window_(root_window) {
DCHECK(root_window_);
DCHECK(!instance);
instance = this;
@@ -234,10 +231,23 @@ ScreenManagerImpl::ScreenManagerImpl(ScreenManagerDelegate* delegate,
ScreenManagerImpl::~ScreenManagerImpl() {
aura::client::SetScreenPositionClient(root_window_, NULL);
aura::client::SetWindowTreeClient(root_window_, NULL);
+ wm::FocusController* focus_controller =
+ static_cast<wm::FocusController*>(focus_client_.get());
+ root_window_->RemovePreTargetHandler(focus_controller);
+ aura::client::SetActivationClient(root_window_, NULL);
+ aura::client::SetFocusClient(root_window_, NULL);
instance = NULL;
}
void ScreenManagerImpl::Init() {
+ wm::FocusController* focus_controller =
+ new wm::FocusController(new AthenaFocusRules());
+
+ aura::client::SetFocusClient(root_window_, focus_controller);
+ root_window_->AddPreTargetHandler(focus_controller);
+ aura::client::SetActivationClient(root_window_, focus_controller);
+ focus_client_.reset(focus_controller);
+
// TODO(oshima): Move the background out from ScreenManager.
root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
background_window_ =
@@ -251,10 +261,6 @@ void ScreenManagerImpl::Init() {
accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
}
-void ScreenManagerImpl::SetWorkAreaInsets(const gfx::Insets& insets) {
- delegate_->SetWorkAreaInsets(insets);
-}
-
aura::Window* ScreenManagerImpl::CreateDefaultContainer(
const ContainerParams& params) {
aura::Window* container = CreateContainer(params);
@@ -365,9 +371,8 @@ ScreenManager::ContainerParams::ContainerParams(const std::string& n,
}
// static
-ScreenManager* ScreenManager::Create(ScreenManagerDelegate* delegate,
- aura::Window* root_window) {
- (new ScreenManagerImpl(delegate, root_window))->Init();
+ScreenManager* ScreenManager::Create(aura::Window* root_window) {
+ (new ScreenManagerImpl(root_window))->Init();
DCHECK(instance);
return instance;
}
@@ -385,9 +390,4 @@ void ScreenManager::Shutdown() {
DCHECK(!instance);
}
-// static
-wm::FocusRules* ScreenManager::CreateFocusRules() {
- return new AthenaFocusRules();
-}
-
} // namespace athena
diff --git a/athena/test/DEPS b/athena/test/DEPS
index 503ed30..c5c2dc4 100644
--- a/athena/test/DEPS
+++ b/athena/test/DEPS
@@ -1,10 +1,11 @@
include_rules = [
"+athena/activity/public",
"+athena/content/public",
+ "+athena/env/public",
"+athena/extensions/public",
"+athena/home/public",
- "+athena/main",
"+athena/screen/public",
+ "+athena/main",
"+chromeos/dbus",
"+third_party/skia/include",
"+ui/app_list",
diff --git a/athena/test/athena_test_base.h b/athena/test/athena_test_base.h
index 0cd88d9..8ab8285 100644
--- a/athena/test/athena_test_base.h
+++ b/athena/test/athena_test_base.h
@@ -34,8 +34,8 @@ class AthenaTestBase : public testing::Test {
scoped_ptr<aura::Window> CreateTestWindow(aura::WindowDelegate* delegate,
const gfx::Rect& bounds);
- aura::Window* root_window() { return helper_->root_window(); }
- aura::WindowTreeHost* host() { return helper_->host(); }
+ aura::Window* root_window() { return helper_->GetRootWindow(); }
+ aura::WindowTreeHost* host() { return helper_->GetHost(); }
private:
bool setup_called_;
diff --git a/athena/test/athena_test_helper.cc b/athena/test/athena_test_helper.cc
index e99b002..b2353d5 100644
--- a/athena/test/athena_test_helper.cc
+++ b/athena/test/athena_test_helper.cc
@@ -4,28 +4,20 @@
#include "athena/test/athena_test_helper.h"
+#include "athena/env/public/athena_env.h"
#include "athena/extensions/public/extensions_delegate.h"
#include "athena/main/athena_launcher.h"
-#include "athena/screen/public/screen_manager.h"
#include "athena/test/sample_activity_factory.h"
#include "athena/test/test_app_model_builder.h"
-#include "athena/test/test_screen_manager_delegate.h"
-#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/threading/thread.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "ui/app_list/app_list_switches.h"
-#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/input_state_lookup.h"
#include "ui/aura/test/env_test_helper.h"
-#include "ui/aura/test/test_focus_client.h"
-#include "ui/aura/test/test_screen.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
-#include "ui/gfx/screen.h"
#include "ui/wm/core/focus_controller.h"
#include "ui/wm/core/input_method_event_filter.h"
@@ -56,12 +48,8 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
file_thread_->StartWithOptions(options);
- // Force showing in the experimental app-list view.
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- app_list::switches::kEnableExperimentalAppList);
-
chromeos::DBusThreadManager::InitializeWithStub();
-
+ ui::InitializeInputMethodForTesting();
aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(context_factory);
@@ -70,33 +58,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
aura::test::EnvTestHelper(aura::Env::GetInstance())
.SetInputStateLookup(scoped_ptr<aura::InputStateLookup>());
- ui::InitializeInputMethodForTesting();
-
- const gfx::Size host_size(800, 600);
- test_screen_.reset(aura::TestScreen::Create(host_size));
- gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
- host_.reset(test_screen_->CreateHostForPrimaryDisplay());
- screen_manager_delegate_.reset(
- new TestScreenManagerDelegate(test_screen_.get()));
-
- input_method_filter_.reset(new ::wm::InputMethodEventFilter(
- root_window()->GetHost()->GetAcceleratedWidget()));
- input_method_filter_->SetInputMethodPropertyInRootWindow(
- root_window());
-
- wm::FocusController* focus_controller =
- new wm::FocusController(ScreenManager::CreateFocusRules());
- aura::client::SetFocusClient(root_window(), focus_controller);
- root_window()->AddPreTargetHandler(focus_controller);
- aura::client::SetActivationClient(root_window(), focus_controller);
- focus_client_.reset(focus_controller);
-
- root_window()->Show();
- // Ensure width != height so tests won't confuse them.
- host()->SetBounds(gfx::Rect(host_size));
-
- athena::StartAthenaEnv(root_window(), screen_manager_delegate_.get(),
- file_thread_->message_loop_proxy());
+ athena::StartAthenaEnv(file_thread_->message_loop_proxy());
athena::ExtensionsDelegate::CreateExtensionsDelegateForTest();
athena::StartAthenaSession(new SampleActivityFactory(),
new TestAppModelBuilder());
@@ -106,25 +68,22 @@ void AthenaTestHelper::TearDown() {
teardown_called_ = true;
athena::ShutdownAthena();
-
- aura::client::SetFocusClient(root_window(), NULL);
- focus_client_.reset();
- input_method_filter_.reset();
-
- host_.reset();
- ui::GestureRecognizer::Reset();
- test_screen_.reset();
- gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL);
+ aura::Env::DeleteInstance();
#if defined(USE_X11)
ui::test::ResetXCursorCache();
#endif
ui::ShutdownInputMethodForTesting();
-
chromeos::DBusThreadManager::Shutdown();
+}
- aura::Env::DeleteInstance();
+aura::Window* AthenaTestHelper::GetRootWindow() {
+ return GetHost()->window();
+}
+
+aura::WindowTreeHost* AthenaTestHelper::GetHost() {
+ return AthenaEnv::Get()->GetHost();
}
void AthenaTestHelper::RunAllPendingInMessageLoop() {
diff --git a/athena/test/athena_test_helper.h b/athena/test/athena_test_helper.h
index 0e15599..db46013 100644
--- a/athena/test/athena_test_helper.h
+++ b/athena/test/athena_test_helper.h
@@ -34,7 +34,6 @@ class InputMethodEventFilter;
namespace athena {
namespace test {
-class TestScreenManagerDelegate;
// A helper class owned by tests that does common initialization required for
// Athena use. This class creates a root window with clients and other objects
@@ -54,8 +53,8 @@ class AthenaTestHelper {
// Flushes message loop.
void RunAllPendingInMessageLoop();
- aura::Window* root_window() { return host_->window(); }
- aura::WindowTreeHost* host() { return host_.get(); }
+ aura::Window* GetRootWindow();
+ aura::WindowTreeHost* GetHost();
private:
bool setup_called_;
@@ -63,11 +62,6 @@ class AthenaTestHelper {
base::MessageLoopForUI* message_loop_;
- scoped_ptr<aura::WindowTreeHost> host_;
- scoped_ptr<aura::TestScreen> test_screen_;
- scoped_ptr<TestScreenManagerDelegate> screen_manager_delegate_;
- scoped_ptr<aura::client::FocusClient> focus_client_;
- scoped_ptr< ::wm::InputMethodEventFilter> input_method_filter_;
scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
scoped_ptr<base::Thread> file_thread_;
diff --git a/athena/test/test_screen_manager_delegate.cc b/athena/test/test_screen_manager_delegate.cc
deleted file mode 100644
index b3d9916..0000000
--- a/athena/test/test_screen_manager_delegate.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 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 "athena/test/test_screen_manager_delegate.h"
-
-#include "ui/aura/test/test_screen.h"
-
-namespace athena {
-namespace test {
-
-TestScreenManagerDelegate::TestScreenManagerDelegate(aura::TestScreen* screen)
- : screen_(screen) {
-}
-
-TestScreenManagerDelegate::~TestScreenManagerDelegate() {
-}
-
-void TestScreenManagerDelegate::SetWorkAreaInsets(const gfx::Insets& insets) {
- screen_->SetWorkAreaInsets(insets);
-}
-
-} // namespace test
-} // namespace athena
diff --git a/athena/test/test_screen_manager_delegate.h b/athena/test/test_screen_manager_delegate.h
deleted file mode 100644
index 9b7a146..0000000
--- a/athena/test/test_screen_manager_delegate.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2014 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 ATHENA_TEST_TEST_SCREEN_MANAGER_DELEGATE_H_
-#define ATHENA_TEST_TEST_SCREEN_MANAGER_DELEGATE_H_
-
-#include "athena/screen/public/screen_manager_delegate.h"
-#include "base/macros.h"
-
-namespace aura {
-class TestScreen;
-}
-
-namespace athena {
-namespace test {
-
-class TestScreenManagerDelegate : public ScreenManagerDelegate {
- public:
- explicit TestScreenManagerDelegate(aura::TestScreen* screen);
- virtual ~TestScreenManagerDelegate();
-
- private:
- // ScreenManagerDelegate:
- virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE;
-
- // Not owned.
- aura::TestScreen* screen_;
-
- DISALLOW_COPY_AND_ASSIGN(TestScreenManagerDelegate);
-};
-
-} // namespace test
-} // namespace athena
-
-#endif // ATHENA_TEST_TEST_SCREEN_MANAGER_DELEGATE_H_