Commit 1629c184 authored by oshima's avatar oshima Committed by Commit bot

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}
parent d27cb086
......@@ -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',
],
......
include_rules = [
"+chromeos/dbus",
"+ui/aura",
"+ui/base",
"+ui/chromeos",
"+ui/display",
"+ui/gfx",
"+ui/wm",
]
// 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
include_rules = [
"-athena/env",
"+athena/athena_export.h",
]
......@@ -2,8 +2,8 @@
// 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_
#ifndef ATHENA_ENV_PUBLIC_ATHENA_ENV_H_
#define ATHENA_ENV_PUBLIC_ATHENA_ENV_H_
#include "athena/athena_export.h"
......@@ -11,17 +11,29 @@ namespace gfx {
class Insets;
}
namespace aura {
class WindowTreeHost;
}
namespace athena {
// Delegate of the ScreenManager.
class ATHENA_EXPORT ScreenManagerDelegate {
// AthenaEnv creates/shuts down the environment necessary to
// start Athena shell.
class ATHENA_EXPORT AthenaEnv {
public:
virtual ~ScreenManagerDelegate() {}
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 screen's work area insets.
virtual void SetWorkAreaInsets(const gfx::Insets& insets) = 0;
// Sets the insets for the primary displays's work area.
virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) = 0;
};
} // namespace athena
#endif // ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
#endif // ATHENA_ENV_PUBLIC_ATHENA_ENV_H_
include_rules = [
"+athena/env/public",
"+athena/input/public",
"+athena/screen/public",
"+athena/wm/public",
......
......@@ -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));
}
......
include_rules = [
"+athena/activity/public",
"+athena/content/public",
"+athena/env/public",
"+athena/extensions/public",
"+athena/home/public",
"+athena/input/public",
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
};
......
......@@ -63,8 +63,6 @@
'../..',
],
'sources': [
'athena_app_window_controller.cc',
'athena_app_window_controller.h',
'athena_main.cc',
],
}
......
......@@ -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
......
......@@ -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
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",
......
......@@ -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_;
......
......@@ -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() {
......
......@@ -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_;
......
// 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
// 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_
......@@ -51,8 +51,8 @@
'browser/api/shell_extensions_api_client.h',
'browser/default_shell_browser_main_delegate.cc',
'browser/default_shell_browser_main_delegate.h',
'browser/default_shell_app_window_controller.cc',
'browser/default_shell_app_window_controller.h',
'browser/desktop_controller.cc',
'browser/desktop_controller.h',
'browser/media_capture_util.cc',
'browser/media_capture_util.h',
'browser/shell_app_sorting.cc',
......
......@@ -7,8 +7,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/common/extension.h"
#include "extensions/shell/browser/desktop_controller.h"
#include "extensions/shell/browser/shell_app_window.h"
#include "extensions/shell/browser/shell_desktop_controller.h"
#include "extensions/shell/common/api/shell.h"
using base::DictionaryValue;
......@@ -54,9 +54,8 @@ ExtensionFunction::ResponseAction ShellCreateWindowFunction::Run() {
return RespondNow(Error(kInvalidArguments));
// The desktop keeps ownership of the window.
ShellAppWindow* app_window =
ShellDesktopController::instance()->CreateAppWindow(browser_context(),
extension());
ShellAppWindow* app_window = DesktopController::instance()->CreateAppWindow(
browser_context(), extension());
app_window->LoadURL(url);
// Create the reply to send to the renderer.
......
// 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 "extensions/shell/browser/default_shell_app_window_controller.h"
#include "base/logging.h"
#include "extensions/shell/browser/shell_app_window.h"
#include "extensions/shell/browser/shell_desktop_controller.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
namespace extensions {
DefaultShellAppWindowController::DefaultShellAppWindowController(
ShellDesktopController* shell_desktop_controller)
: shell_desktop_controller_(shell_desktop_controller) {
DCHECK(shell_desktop_controller_);
}
DefaultShellAppWindowController::~DefaultShellAppWindowController() {
// The app window must be explicitly closed before desktop teardown.
DCHECK(!app_window_);
}
ShellAppWindow* DefaultShellAppWindowController::CreateAppWindow(
content::BrowserContext* context,
const Extension* extension) {
aura::Window* root_window = shell_desktop_controller_->host()->window();
app_window_.reset(new ShellAppWindow);
app_window_->Init(context, extension, root_window->bounds().size());
// Attach the web contents view to our window hierarchy.
aura::Window* content = app_window_->GetNativeWindow();
root_window->AddChild(content);
content->Show();
return app_window_.get();
}
void DefaultShellAppWindowController::CloseAppWindows() {
app_window_.reset();
}
} // namespace extensions
// 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 EXTENSIONS_SHELL_BROWSER_DEFAULT_SHELL_APP_WINDOW_CONTROLLER_H_
#define EXTENSIONS_SHELL_BROWSER_DEFAULT_SHELL_APP_WINDOW_CONTROLLER_H_
#include "extensions/shell/browser/shell_app_window_controller.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
namespace extensions {
class ShellDesktopController;
// The default shell app window controller for app_shell. It manages only one
// app_window.
class DefaultShellAppWindowController : public ShellAppWindowController {
public:
explicit DefaultShellAppWindowController(
ShellDesktopController* shell_desktop_controller);
virtual ~DefaultShellAppWindowController();
// ShellAppWindowController implementation.
virtual ShellAppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension) OVERRIDE;
virtual void CloseAppWindows() OVERRIDE;
private:
ShellDesktopController* shell_desktop_controller_; // Not owned
// The desktop supports a single app window.
scoped_ptr<ShellAppWindow> app_window_;
DISALLOW_COPY_AND_ASSIGN(DefaultShellAppWindowController);
};
} // namespace extensions
#endif // EXTENSIONS_SHELL_BROWSER_DEFAULT_SHELL_APP_WINDOW_CONTROLLER_H_
......@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "extensions/shell/browser/default_shell_app_window_controller.h"
#include "extensions/shell/browser/shell_desktop_controller.h"
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/common/switches.h"
......@@ -42,11 +41,8 @@ void DefaultShellBrowserMainDelegate::Start(
void DefaultShellBrowserMainDelegate::Shutdown() {
}
ShellDesktopController*
DefaultShellBrowserMainDelegate::CreateDesktopController() {
ShellDesktopController* desktop = new ShellDesktopController();
desktop->SetAppWindowController(new DefaultShellAppWindowController(desktop));
return desktop;
DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
return new ShellDesktopController();
}
} // namespace extensions
......@@ -21,7 +21,7 @@ class DefaultShellBrowserMainDelegate : public ShellBrowserMainDelegate {
// ShellBrowserMainDelegate:
virtual void Start(content::BrowserContext* context) OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual ShellDesktopController* CreateDesktopController() OVERRIDE;
virtual DesktopController* CreateDesktopController() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DefaultShellBrowserMainDelegate);
......
// 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 "extensions/shell/browser/desktop_controller.h"
#include "base/logging.h"
#include "base/macros.h"
namespace extensions {
namespace {
DesktopController* g_instance = NULL;
} // namespace
// static
DesktopController* DesktopController::instance() {
return g_instance;
}
DesktopController::DesktopController() {
CHECK(!g_instance) << "DesktopController already exists";
g_instance = this;
}
DesktopController::~DesktopController() {
DCHECK(g_instance);
g_instance = NULL;
}
} // namespace extensions
// 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 EXTENSIONS_SHELL_BROWSER_DESKTOP_CONTROLLER_H_
#define EXTENSIONS_SHELL_BROWSER_DESKTOP_CONTROLLER_H_
namespace aura {
class WindowTreeHost;
}
namespace content {
class BrowserContext;
}
namespace extensions {
class Extension;
class ShellAppWindow;
// DesktopController is an interface to construct the window environment in
// extensions shell. ShellDesktopController provides a default implementation
// for
// app_shell, and embedder (such as athena) can provide its own.
class DesktopController {
public:
DesktopController();
virtual ~DesktopController();
// Returns the single instance of the desktop. (Stateless functions like
// ShellAppWindowCreateFunction need to be able to access the desktop, so
// we need a singleton somewhere).
static DesktopController* instance();
// Returns the WindowTreeHost created by this DesktopController.
virtual aura::WindowTreeHost* GetHost() = 0;
// Creates a new app window and adds it to the desktop. The desktop maintains
// ownership of the window. The window must be closed before |extension| is
// destroyed.
virtual ShellAppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension) = 0;
// Closes and destroys the app windows.
virtual void CloseAppWindows() = 0;
};
} // namespace extensinos
#endif // EXTENSIONS_SHELL_BROWSER_DESKTOP_CONTROLLER_H_
......@@ -11,7 +11,7 @@ class BrowserContext;
namespace extensions {
class ShellDesktopController;
class DesktopController;
class ShellBrowserMainDelegate {
public:
......@@ -28,7 +28,7 @@ class ShellBrowserMainDelegate {
// Creates the ShellDesktopController instance to initialize the root window
// and window manager. Subclass may return its subclass to customize the
// windo manager.
virtual ShellDesktopController* CreateDesktopController() = 0;
virtual DesktopController* CreateDesktopController() = 0;
};
} // namespace extensions
......
......@@ -27,9 +27,9 @@ class NetLog;
namespace extensions {
class DesktopController;
class ShellBrowserContext;
class ShellBrowserMainDelegate;
class ShellDesktopController;
class ShellExtensionsBrowserClient;
class ShellExtensionsClient;
class ShellExtensionSystem;
......@@ -67,7 +67,7 @@ class ShellBrowserMainParts : public content::BrowserMainParts {
#if defined(OS_CHROMEOS)
scoped_ptr<ShellNetworkController> network_controller_;
#endif
scoped_ptr<ShellDesktopController> desktop_controller_;
scoped_ptr<DesktopController> desktop_controller_;
scoped_ptr<ShellBrowserContext> browser_context_;
scoped_ptr<ShellExtensionsClient> extensions_client_;
scoped_ptr<ShellExtensionsBrowserClient> extensions_browser_client_;
......
......@@ -5,7 +5,7 @@
#include "extensions/shell/browser/shell_desktop_controller.h"
#include "base/command_line.h"
#include "extensions/shell/browser/shell_app_window_controller.h"
#include "extensions/shell/browser/shell_app_window.h"
#include "extensions/shell/common/switches.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/default_capture_client.h"
......@@ -151,13 +151,9 @@ class AppsFocusRules : public wm::BaseFocusRules {
DISALLOW_COPY_AND_ASSIGN(AppsFocusRules);
};
ShellDesktopController* g_instance = NULL;
} // namespace
ShellDesktopController::ShellDesktopController() {
CHECK(!g_instance) << "ShellDesktopController already exists";
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
AddObserver(this);
......@@ -168,13 +164,10 @@ ShellDesktopController::ShellDesktopController() {
#endif
CreateRootWindow();
g_instance = this;
}
ShellDesktopController::~ShellDesktopController() {
app_window_controller_.reset();
g_instance = NULL;
app_window_.reset();
DestroyRootWindow();
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
......@@ -182,30 +175,28 @@ ShellDesktopController::~ShellDesktopController() {
#endif
}
// static
ShellDesktopController* ShellDesktopController::instance() {
return g_instance;
}
void ShellDesktopController::SetAppWindowController(
ShellAppWindowController* app_window_controller) {
app_window_controller_.reset(app_window_controller);
aura::WindowTreeHost* ShellDesktopController::GetHost() {
return host_.get();
}
ShellAppWindow* ShellDesktopController::CreateAppWindow(
content::BrowserContext* context,
const Extension* extension) {
return app_window_controller_->CreateAppWindow(context, extension);
}
aura::Window* root_window = GetHost()->window();
void ShellDesktopController::CloseAppWindows() {
if (app_window_controller_)
app_window_controller_->CloseAppWindows();
app_window_.reset(new ShellAppWindow);
app_window_->Init(context, extension, root_window->bounds().size());
// Attach the web contents view to our window hierarchy.
aura::Window* content = app_window_->GetNativeWindow();
root_window->AddChild(content);
content->Show();
return app_window_.get();
}
void ShellDesktopController::SetDisplayWorkAreaInsets(
const gfx::Insets& insets) {
test_screen_->SetWorkAreaInsets(insets);
void ShellDesktopController::CloseAppWindows() {
app_window_.reset();
}
aura::Window* ShellDesktopController::GetDefaultParent(
......@@ -243,7 +234,7 @@ void ShellDesktopController::OnHostCloseRequested(
void ShellDesktopController::InitWindowManager() {
wm::FocusController* focus_controller =
new wm::FocusController(CreateFocusRules());
new wm::FocusController(new AppsFocusRules());
aura::client::SetFocusClient(host_->window(), focus_controller);
host_->window()->AddPreTargetHandler(focus_controller);
aura::client::SetActivationClient(host_->window(), focus_controller);
......@@ -277,10 +268,6 @@ void ShellDesktopController::InitWindowManager() {
#endif
}
wm::FocusRules* ShellDesktopController::CreateFocusRules() {
return new AppsFocusRules();
}
void ShellDesktopController::CreateRootWindow() {
// Set up basic pieces of ui::wm.
gfx::Size size;
......
......@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "extensions/shell/browser/desktop_controller.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/window_tree_host_observer.h"
......@@ -31,7 +32,6 @@ class BrowserContext;
}
namespace gfx {
class Insets;
class Size;
}
......@@ -44,7 +44,6 @@ class UserActivityPowerManagerNotifier;
namespace wm {
class CompoundEventFilter;
class CursorManager;
class FocusRules;
class InputMethodEventFilter;
class UserActivityDetector;
}
......@@ -56,7 +55,8 @@ class ShellAppWindow;
class ShellAppWindowController;
// Handles desktop-related tasks for app_shell.
class ShellDesktopController : public aura::client::WindowTreeClient,
class ShellDesktopController : public DesktopController,
public aura::client::WindowTreeClient,
#if defined(OS_CHROMEOS)
public chromeos::PowerManagerClient::Observer,
public ui::DisplayConfigurator::Observer,
......@@ -66,28 +66,11 @@ class ShellDesktopController : public aura::client::WindowTreeClient,
ShellDesktopController();
virtual ~ShellDesktopController();
// Returns the single instance of the desktop. (Stateless functions like
// ShellAppWindowCreateFunction need to be able to access the desktop, so
// we need a singleton somewhere).
static ShellDesktopController* instance();
aura::WindowTreeHost* host() { return host_.get(); }
// Sets the controller to create/close the app windows. Takes the ownership of
// |app_window_controller|.
void SetAppWindowController(ShellAppWindowController* app_window_controller);
// Creates a new app window and adds it to the desktop. The desktop maintains
// ownership of the window. The window must be closed before |extension| is
// destroyed.
ShellAppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension);
// Closes and destroys the app windows.
void CloseAppWindows();
// Sets the screen's work area insets.
void SetDisplayWorkAreaInsets(const gfx::Insets& insets);
// DesktopController:
virtual aura::WindowTreeHost* GetHost() OVERRIDE;
virtual ShellAppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension) OVERRIDE;
virtual void CloseAppWindows() OVERRIDE;
// aura::client::WindowTreeClient overrides:
virtual aura::Window* GetDefaultParent(aura::Window* context,
......@@ -113,9 +96,6 @@ class ShellDesktopController : public aura::client::WindowTreeClient,
// initialize different sets of the clients.
virtual void InitWindowManager();
// Creates a focus rule that is to be used in the InitWindowManager.
virtual wm::FocusRules* CreateFocusRules();
private:
// Creates the window that hosts the app.
void CreateRootWindow();
......@@ -151,7 +131,7 @@ class ShellDesktopController : public aura::client::WindowTreeClient,
#endif
// The desktop supports a single app window.
scoped_ptr<ShellAppWindowController> app_window_controller_;
scoped_ptr<ShellAppWindow> app_window_;
DISALLOW_COPY_AND_ASSIGN(ShellDesktopController);
};
......
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