summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--athena/athena.gyp7
-rw-r--r--athena/main/athena_launcher.cc92
-rw-r--r--athena/main/athena_launcher.h15
-rw-r--r--athena/main/athena_main.cc54
-rw-r--r--athena/main/athena_main.gyp23
-rw-r--r--athena/test/athena_test_helper.cc6
6 files changed, 107 insertions, 90 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index da4bd4d..2ccd3b5 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -151,10 +151,6 @@
'resources/athena_resources.gyp:athena_resources',
],
'sources': [
- 'main/athena_launcher.cc',
- 'main/athena_launcher.h',
- 'main/placeholder.cc',
- 'main/placeholder.h',
'test/athena_test_base.cc',
'test/athena_test_base.h',
'test/athena_test_helper.cc',
@@ -171,10 +167,11 @@
'target_name': 'athena_unittests',
'type': 'executable',
'dependencies': [
- '../testing/gtest.gyp:gtest',
'../skia/skia.gyp:skia',
+ '../testing/gtest.gyp:gtest',
'athena_lib',
'athena_test_support',
+ 'main/athena_main.gyp:athena_main_lib',
'resources/athena_resources.gyp:athena_pak',
],
'sources': [
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index fdfbfe9..6932435 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -6,15 +6,28 @@
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
+#include "athena/content/public/content_activity_factory.h"
+#include "athena/content/public/content_app_model_builder.h"
+#include "athena/home/public/home_card.h"
#include "athena/home/public/home_card.h"
#include "athena/input/public/input_manager.h"
+#include "athena/main/debug/debug_window.h"
+#include "athena/main/placeholder.h"
#include "athena/main/placeholder.h"
+#include "athena/main/url_search_provider.h"
+#include "athena/screen/public/screen_manager.h"
#include "athena/screen/public/screen_manager.h"
#include "athena/system/public/system_ui.h"
+#include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
#include "athena/wm/public/window_manager.h"
+#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_thread.h"
+#include "ui/app_list/app_list_switches.h"
#include "ui/aura/window_property.h"
+#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_controller_observer.h"
+#include "ui/native_theme/native_theme_switches.h"
#include "ui/views/views_delegate.h"
#include "ui/wm/core/visibility_controller.h"
@@ -23,22 +36,46 @@
#endif
namespace athena {
-struct RootWindowState;
+struct AthenaEnvState;
}
-DECLARE_WINDOW_PROPERTY_TYPE(athena::RootWindowState*);
+DECLARE_WINDOW_PROPERTY_TYPE(athena::AthenaEnvState*);
namespace athena {
-// Athena's per root window state.
-struct RootWindowState {
+class VirtualKeyboardObserver;
+
+// Athena's env state.
+struct AthenaEnvState {
scoped_ptr< ::wm::VisibilityController> visibility_client;
+ scoped_ptr<VirtualKeyboardObserver> virtual_keyboard_observer;
};
-DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::RootWindowState,
- kRootWindowStateKey,
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::AthenaEnvState,
+ kAthenaEnvStateKey,
NULL);
+// This class observes the change of the virtual keyboard and distribute the
+// change to appropriate modules of athena.
+// TODO(oshima): move the VK bounds logic to screen manager.
+class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver {
+ public:
+ VirtualKeyboardObserver() {
+ keyboard::KeyboardController::GetInstance()->AddObserver(this);
+ }
+
+ virtual ~VirtualKeyboardObserver() {
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ }
+
+ private:
+ virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE {
+ HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds);
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver);
+};
+
class AthenaViewsDelegate : public views::ViewsDelegate {
public:
AthenaViewsDelegate() {}
@@ -54,21 +91,26 @@ class AthenaViewsDelegate : public views::ViewsDelegate {
DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate);
};
-void StartAthena(aura::Window* root_window,
- athena::ActivityFactory* activity_factory,
- athena::AppModelBuilder* app_model_builder) {
+void StartAthenaEnv(aura::Window* root_window) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+
+ // Force showing in the experimental app-list view.
+ command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList);
+ command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
+
#if defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
views::ViewsDelegate::views_delegate = new AthenaViewsDelegate();
- RootWindowState* root_window_state = new RootWindowState;
- root_window->SetProperty(kRootWindowStateKey, root_window_state);
+ AthenaEnvState* env_state = new AthenaEnvState;
+
+ // Setup VisibilityClient
+ env_state->visibility_client.reset(new ::wm::VisibilityController);
- root_window_state->visibility_client.reset(new ::wm::VisibilityController);
aura::client::SetVisibilityClient(root_window,
- root_window_state->visibility_client.get());
+ env_state->visibility_client.get());
athena::SystemUI::Create(
content::BrowserThread::GetMessageLoopProxyForThread(
@@ -76,10 +118,32 @@ void StartAthena(aura::Window* root_window,
athena::InputManager::Create()->OnRootWindowCreated(root_window);
athena::ScreenManager::Create(root_window);
athena::WindowManager::Create();
+ SetupBackgroundImage();
+
+ athena::ScreenManager::Get()->GetContext()->SetProperty(
+ kAthenaEnvStateKey, env_state);
+}
+
+void StartAthenaSessionWithContext(content::BrowserContext* context) {
+ StartAthenaSession(new athena::ContentActivityFactory(),
+ new athena::ContentAppModelBuilder(context));
+ athena::VirtualKeyboardManager::Create(context);
+ athena::HomeCard::Get()->RegisterSearchProvider(
+ new athena::UrlSearchProvider(context));
+ AthenaEnvState* env_state =
+ athena::ScreenManager::Get()->GetContext()->GetProperty(
+ kAthenaEnvStateKey);
+
+ env_state->virtual_keyboard_observer.reset(new VirtualKeyboardObserver);
+ CreateTestPages(context);
+ CreateDebugWindow();
+}
+
+void StartAthenaSession(athena::ActivityFactory* activity_factory,
+ athena::AppModelBuilder* app_model_builder) {
athena::HomeCard::Create(app_model_builder);
athena::ActivityManager::Create();
athena::ActivityFactory::RegisterActivityFactory(activity_factory);
- SetupBackgroundImage();
}
void ShutdownAthena() {
diff --git a/athena/main/athena_launcher.h b/athena/main/athena_launcher.h
index 6ea439f..8069927 100644
--- a/athena/main/athena_launcher.h
+++ b/athena/main/athena_launcher.h
@@ -9,14 +9,23 @@ namespace aura {
class Window;
}
+namespace content {
+class BrowserContext;
+}
+
namespace athena {
class ActivityFactory;
class AppModelBuilder;
// Starts/shuts down the athena shell environment.
-void StartAthena(aura::Window* root_window,
- ActivityFactory* activity_factory,
- AppModelBuilder* app_model_builder);
+void StartAthenaEnv(aura::Window* root_window);
+
+void StartAthenaSessionWithContext(content::BrowserContext* context);
+
+// Starts/shuts down the athena shell environment.
+void StartAthenaSession(ActivityFactory* activity_factory,
+ AppModelBuilder* app_model_builder);
+
void ShutdownAthena();
} // namespace athena
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index 8ce7236..4cd30b1 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -2,17 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "athena/content/public/content_activity_factory.h"
-#include "athena/content/public/content_app_model_builder.h"
#include "athena/content/public/web_contents_view_delegate_creator.h"
-#include "athena/home/public/home_card.h"
#include "athena/main/athena_app_window_controller.h"
#include "athena/main/athena_launcher.h"
-#include "athena/main/debug/debug_window.h"
-#include "athena/main/placeholder.h"
-#include "athena/main/url_search_provider.h"
#include "athena/screen/public/screen_manager.h"
-#include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -24,12 +17,8 @@
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/common/switches.h"
#include "extensions/shell/renderer/shell_renderer_main_delegate.h"
-#include "ui/app_list/app_list_switches.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_observer.h"
-#include "ui/native_theme/native_theme_switches.h"
#include "ui/wm/core/visibility_controller.h"
namespace {
@@ -38,28 +27,8 @@ namespace {
// to run athena_main at src/
const char kDefaultAppPath[] =
"chrome/common/extensions/docs/examples/apps/calculator/app";
-} // namespace
-// This class observes the change of the virtual keyboard and distribute the
-// change to appropriate modules of athena.
-// TODO(oshima): move the VK bounds logic to screen manager.
-class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver {
- public:
- VirtualKeyboardObserver() {
- keyboard::KeyboardController::GetInstance()->AddObserver(this);
- }
-
- virtual ~VirtualKeyboardObserver() {
- keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
- }
-
- private:
- virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE {
- athena::HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds);
- }
-
- DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver);
-};
+} // namespace athena
class AthenaDesktopController : public extensions::ShellDesktopController {
public:
@@ -84,10 +53,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
virtual void Start(content::BrowserContext* context) OVERRIDE {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- // Force showing in the experimental app-list view.
- command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList);
- command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
-
base::FilePath app_dir = base::FilePath::FromUTF8Unsafe(
command_line->HasSwitch(extensions::switches::kAppShellAppPath)
? command_line->GetSwitchValueNative(
@@ -102,21 +67,12 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
extension_system->LoadApp(app_absolute_dir);
}
- athena::StartAthena(
- extensions::ShellDesktopController::instance()->host()->window(),
- new athena::ContentActivityFactory(),
- new athena::ContentAppModelBuilder(context));
- athena::HomeCard::Get()->RegisterSearchProvider(
- new athena::UrlSearchProvider(context));
- athena::VirtualKeyboardManager::Create(context);
- keyboard_observer_.reset(new VirtualKeyboardObserver());
-
- CreateTestPages(context);
- CreateDebugWindow();
+ athena::StartAthenaEnv(
+ extensions::ShellDesktopController::instance()->host()->window());
+ athena::StartAthenaSessionWithContext(context);
}
virtual void Shutdown() OVERRIDE {
- keyboard_observer_.reset();
athena::ShutdownAthena();
}
@@ -130,8 +86,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
}
private:
- scoped_ptr<VirtualKeyboardObserver> keyboard_observer_;
-
DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
};
diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp
index 1b818b1..c4641a8 100644
--- a/athena/main/athena_main.gyp
+++ b/athena/main/athena_main.gyp
@@ -8,12 +8,11 @@
},
'targets': [
{
- 'target_name': 'athena_main',
- 'type': 'executable',
+ 'target_name': 'athena_main_lib',
+ 'type': 'static_library',
'dependencies': [
'../athena.gyp:athena_lib',
'../athena.gyp:athena_content_lib',
- '../resources/athena_resources.gyp:athena_pak',
'../resources/athena_resources.gyp:athena_resources',
# debug_widow.cc depends on this. Remove this once debug_window
# is removed.
@@ -29,7 +28,6 @@
'../../components/components.gyp:search_engines',
'../../extensions/shell/app_shell.gyp:app_shell_lib',
'../../skia/skia.gyp:skia',
- '../../ui/accessibility/accessibility.gyp:ax_gen',
'../../ui/app_list/app_list.gyp:app_list',
'../../ui/chromeos/ui_chromeos.gyp:ui_chromeos',
'../../ui/keyboard/keyboard.gyp:keyboard',
@@ -51,28 +49,23 @@
'debug/network_selector.h',
'url_search_provider.cc',
'url_search_provider.h',
- 'athena_main.cc',
'placeholder.cc',
'placeholder.h',
],
},
{
- 'target_name': 'athena_shell',
+ 'target_name': 'athena_main',
'type': 'executable',
'dependencies': [
- '../../base/base.gyp:base',
- '../../base/base.gyp:base_i18n',
- '../../skia/skia.gyp:skia',
'../../ui/accessibility/accessibility.gyp:ax_gen',
- '../../ui/aura/aura.gyp:aura',
- '../../ui/compositor/compositor.gyp:compositor_test_support',
- '../../ui/gfx/gfx.gyp:gfx',
- '../athena.gyp:athena_lib',
- '../athena.gyp:athena_test_support',
'../resources/athena_resources.gyp:athena_pak',
+ 'athena_main_lib',
+ ],
+ 'include_dirs': [
+ '../..',
],
'sources': [
- 'athena_shell.cc',
+ 'athena_main.cc',
],
}
], # targets
diff --git a/athena/test/athena_test_helper.cc b/athena/test/athena_test_helper.cc
index 8f5df97..f8916a1 100644
--- a/athena/test/athena_test_helper.cc
+++ b/athena/test/athena_test_helper.cc
@@ -87,9 +87,9 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
// Ensure width != height so tests won't confuse them.
host()->SetBounds(gfx::Rect(host_size));
- athena::StartAthena(root_window(),
- new SampleActivityFactory(),
- new TestAppModelBuilder());
+ athena::StartAthenaEnv(root_window());
+ athena::StartAthenaSession(new SampleActivityFactory(),
+ new TestAppModelBuilder());
}
void AthenaTestHelper::TearDown() {