Commit 3c643ba1 authored by oshima@chromium.org's avatar oshima@chromium.org

introduced athena_main_lib

separate the process to initialize environment, and
start the session.

These are necessary step to launch athena in chrome.

BUG=397167

Review URL: https://codereview.chromium.org/485183002

Cr-Commit-Position: refs/heads/master@{#290686}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290686 0039d316-1c4b-4281-b951-d872f2087c98
parent 0dfcae78
...@@ -151,10 +151,6 @@ ...@@ -151,10 +151,6 @@
'resources/athena_resources.gyp:athena_resources', 'resources/athena_resources.gyp:athena_resources',
], ],
'sources': [ 'sources': [
'main/athena_launcher.cc',
'main/athena_launcher.h',
'main/placeholder.cc',
'main/placeholder.h',
'test/athena_test_base.cc', 'test/athena_test_base.cc',
'test/athena_test_base.h', 'test/athena_test_base.h',
'test/athena_test_helper.cc', 'test/athena_test_helper.cc',
...@@ -171,10 +167,11 @@ ...@@ -171,10 +167,11 @@
'target_name': 'athena_unittests', 'target_name': 'athena_unittests',
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'../testing/gtest.gyp:gtest',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest',
'athena_lib', 'athena_lib',
'athena_test_support', 'athena_test_support',
'main/athena_main.gyp:athena_main_lib',
'resources/athena_resources.gyp:athena_pak', 'resources/athena_resources.gyp:athena_pak',
], ],
'sources': [ 'sources': [
......
...@@ -6,15 +6,28 @@ ...@@ -6,15 +6,28 @@
#include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.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/home/public/home_card.h"
#include "athena/input/public/input_manager.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/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/screen/public/screen_manager.h"
#include "athena/system/public/system_ui.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 "athena/wm/public/window_manager.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/aura/window_property.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/views/views_delegate.h"
#include "ui/wm/core/visibility_controller.h" #include "ui/wm/core/visibility_controller.h"
...@@ -23,22 +36,46 @@ ...@@ -23,22 +36,46 @@
#endif #endif
namespace athena { namespace athena {
struct RootWindowState; struct AthenaEnvState;
} }
DECLARE_WINDOW_PROPERTY_TYPE(athena::RootWindowState*); DECLARE_WINDOW_PROPERTY_TYPE(athena::AthenaEnvState*);
namespace athena { namespace athena {
// Athena's per root window state. class VirtualKeyboardObserver;
struct RootWindowState {
// Athena's env state.
struct AthenaEnvState {
scoped_ptr< ::wm::VisibilityController> visibility_client; scoped_ptr< ::wm::VisibilityController> visibility_client;
scoped_ptr<VirtualKeyboardObserver> virtual_keyboard_observer;
}; };
DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::RootWindowState, DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::AthenaEnvState,
kRootWindowStateKey, kAthenaEnvStateKey,
NULL); 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 { class AthenaViewsDelegate : public views::ViewsDelegate {
public: public:
AthenaViewsDelegate() {} AthenaViewsDelegate() {}
...@@ -54,21 +91,26 @@ class AthenaViewsDelegate : public views::ViewsDelegate { ...@@ -54,21 +91,26 @@ class AthenaViewsDelegate : public views::ViewsDelegate {
DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate);
}; };
void StartAthena(aura::Window* root_window, void StartAthenaEnv(aura::Window* root_window) {
athena::ActivityFactory* activity_factory, base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
athena::AppModelBuilder* app_model_builder) {
// Force showing in the experimental app-list view.
command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList);
command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
#if defined(USE_X11) #if defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine(); ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif #endif
views::ViewsDelegate::views_delegate = new AthenaViewsDelegate(); views::ViewsDelegate::views_delegate = new AthenaViewsDelegate();
RootWindowState* root_window_state = new RootWindowState; AthenaEnvState* env_state = new AthenaEnvState;
root_window->SetProperty(kRootWindowStateKey, root_window_state);
// Setup VisibilityClient
env_state->visibility_client.reset(new ::wm::VisibilityController);
root_window_state->visibility_client.reset(new ::wm::VisibilityController);
aura::client::SetVisibilityClient(root_window, aura::client::SetVisibilityClient(root_window,
root_window_state->visibility_client.get()); env_state->visibility_client.get());
athena::SystemUI::Create( athena::SystemUI::Create(
content::BrowserThread::GetMessageLoopProxyForThread( content::BrowserThread::GetMessageLoopProxyForThread(
...@@ -76,10 +118,32 @@ void StartAthena(aura::Window* root_window, ...@@ -76,10 +118,32 @@ void StartAthena(aura::Window* root_window,
athena::InputManager::Create()->OnRootWindowCreated(root_window); athena::InputManager::Create()->OnRootWindowCreated(root_window);
athena::ScreenManager::Create(root_window); athena::ScreenManager::Create(root_window);
athena::WindowManager::Create(); 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::HomeCard::Create(app_model_builder);
athena::ActivityManager::Create(); athena::ActivityManager::Create();
athena::ActivityFactory::RegisterActivityFactory(activity_factory); athena::ActivityFactory::RegisterActivityFactory(activity_factory);
SetupBackgroundImage();
} }
void ShutdownAthena() { void ShutdownAthena() {
......
...@@ -9,14 +9,23 @@ namespace aura { ...@@ -9,14 +9,23 @@ namespace aura {
class Window; class Window;
} }
namespace content {
class BrowserContext;
}
namespace athena { namespace athena {
class ActivityFactory; class ActivityFactory;
class AppModelBuilder; class AppModelBuilder;
// Starts/shuts down the athena shell environment. // Starts/shuts down the athena shell environment.
void StartAthena(aura::Window* root_window, void StartAthenaEnv(aura::Window* root_window);
ActivityFactory* activity_factory,
AppModelBuilder* app_model_builder); void StartAthenaSessionWithContext(content::BrowserContext* context);
// Starts/shuts down the athena shell environment.
void StartAthenaSession(ActivityFactory* activity_factory,
AppModelBuilder* app_model_builder);
void ShutdownAthena(); void ShutdownAthena();
} // namespace athena } // namespace athena
......
...@@ -2,17 +2,10 @@ ...@@ -2,17 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/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_app_window_controller.h"
#include "athena/main/athena_launcher.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/screen/public/screen_manager.h"
#include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -24,12 +17,8 @@ ...@@ -24,12 +17,8 @@
#include "extensions/shell/browser/shell_extension_system.h" #include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/common/switches.h" #include "extensions/shell/common/switches.h"
#include "extensions/shell/renderer/shell_renderer_main_delegate.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/aura/window_tree_host.h"
#include "ui/base/resource/resource_bundle.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" #include "ui/wm/core/visibility_controller.h"
namespace { namespace {
...@@ -38,28 +27,8 @@ namespace { ...@@ -38,28 +27,8 @@ namespace {
// to run athena_main at src/ // to run athena_main at src/
const char kDefaultAppPath[] = const char kDefaultAppPath[] =
"chrome/common/extensions/docs/examples/apps/calculator/app"; "chrome/common/extensions/docs/examples/apps/calculator/app";
} // namespace
// This class observes the change of the virtual keyboard and distribute the } // namespace athena
// 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);
};
class AthenaDesktopController : public extensions::ShellDesktopController { class AthenaDesktopController : public extensions::ShellDesktopController {
public: public:
...@@ -84,10 +53,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { ...@@ -84,10 +53,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
virtual void Start(content::BrowserContext* context) OVERRIDE { virtual void Start(content::BrowserContext* context) OVERRIDE {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 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( base::FilePath app_dir = base::FilePath::FromUTF8Unsafe(
command_line->HasSwitch(extensions::switches::kAppShellAppPath) command_line->HasSwitch(extensions::switches::kAppShellAppPath)
? command_line->GetSwitchValueNative( ? command_line->GetSwitchValueNative(
...@@ -102,21 +67,12 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { ...@@ -102,21 +67,12 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
extension_system->LoadApp(app_absolute_dir); extension_system->LoadApp(app_absolute_dir);
} }
athena::StartAthena( athena::StartAthenaEnv(
extensions::ShellDesktopController::instance()->host()->window(), extensions::ShellDesktopController::instance()->host()->window());
new athena::ContentActivityFactory(), athena::StartAthenaSessionWithContext(context);
new athena::ContentAppModelBuilder(context));
athena::HomeCard::Get()->RegisterSearchProvider(
new athena::UrlSearchProvider(context));
athena::VirtualKeyboardManager::Create(context);
keyboard_observer_.reset(new VirtualKeyboardObserver());
CreateTestPages(context);
CreateDebugWindow();
} }
virtual void Shutdown() OVERRIDE { virtual void Shutdown() OVERRIDE {
keyboard_observer_.reset();
athena::ShutdownAthena(); athena::ShutdownAthena();
} }
...@@ -130,8 +86,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { ...@@ -130,8 +86,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
} }
private: private:
scoped_ptr<VirtualKeyboardObserver> keyboard_observer_;
DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
}; };
......
...@@ -8,12 +8,11 @@ ...@@ -8,12 +8,11 @@
}, },
'targets': [ 'targets': [
{ {
'target_name': 'athena_main', 'target_name': 'athena_main_lib',
'type': 'executable', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'../athena.gyp:athena_lib', '../athena.gyp:athena_lib',
'../athena.gyp:athena_content_lib', '../athena.gyp:athena_content_lib',
'../resources/athena_resources.gyp:athena_pak',
'../resources/athena_resources.gyp:athena_resources', '../resources/athena_resources.gyp:athena_resources',
# debug_widow.cc depends on this. Remove this once debug_window # debug_widow.cc depends on this. Remove this once debug_window
# is removed. # is removed.
...@@ -29,7 +28,6 @@ ...@@ -29,7 +28,6 @@
'../../components/components.gyp:search_engines', '../../components/components.gyp:search_engines',
'../../extensions/shell/app_shell.gyp:app_shell_lib', '../../extensions/shell/app_shell.gyp:app_shell_lib',
'../../skia/skia.gyp:skia', '../../skia/skia.gyp:skia',
'../../ui/accessibility/accessibility.gyp:ax_gen',
'../../ui/app_list/app_list.gyp:app_list', '../../ui/app_list/app_list.gyp:app_list',
'../../ui/chromeos/ui_chromeos.gyp:ui_chromeos', '../../ui/chromeos/ui_chromeos.gyp:ui_chromeos',
'../../ui/keyboard/keyboard.gyp:keyboard', '../../ui/keyboard/keyboard.gyp:keyboard',
...@@ -51,28 +49,23 @@ ...@@ -51,28 +49,23 @@
'debug/network_selector.h', 'debug/network_selector.h',
'url_search_provider.cc', 'url_search_provider.cc',
'url_search_provider.h', 'url_search_provider.h',
'athena_main.cc',
'placeholder.cc', 'placeholder.cc',
'placeholder.h', 'placeholder.h',
], ],
}, },
{ {
'target_name': 'athena_shell', 'target_name': 'athena_main',
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'../../base/base.gyp:base',
'../../base/base.gyp:base_i18n',
'../../skia/skia.gyp:skia',
'../../ui/accessibility/accessibility.gyp:ax_gen', '../../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', '../resources/athena_resources.gyp:athena_pak',
'athena_main_lib',
],
'include_dirs': [
'../..',
], ],
'sources': [ 'sources': [
'athena_shell.cc', 'athena_main.cc',
], ],
} }
], # targets ], # targets
......
...@@ -87,9 +87,9 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -87,9 +87,9 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
// Ensure width != height so tests won't confuse them. // Ensure width != height so tests won't confuse them.
host()->SetBounds(gfx::Rect(host_size)); host()->SetBounds(gfx::Rect(host_size));
athena::StartAthena(root_window(), athena::StartAthenaEnv(root_window());
new SampleActivityFactory(), athena::StartAthenaSession(new SampleActivityFactory(),
new TestAppModelBuilder()); new TestAppModelBuilder());
} }
void AthenaTestHelper::TearDown() { void AthenaTestHelper::TearDown() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment