summaryrefslogtreecommitdiffstats
path: root/extensions/shell
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/shell')
-rw-r--r--extensions/shell/BUILD.gn7
-rw-r--r--extensions/shell/app/shell_main_delegate.cc7
-rw-r--r--extensions/shell/app/shell_main_delegate.h3
-rw-r--r--extensions/shell/app_shell.gyp22
-rw-r--r--extensions/shell/browser/DEPS1
-rw-r--r--extensions/shell/browser/default_shell_browser_main_delegate.cc11
-rw-r--r--extensions/shell/browser/desktop_controller.h18
-rw-r--r--extensions/shell/browser/shell_app_window_client.cc11
-rw-r--r--extensions/shell/browser/shell_app_window_client.h2
-rw-r--r--extensions/shell/browser/shell_app_window_client_aura.cc23
-rw-r--r--extensions/shell/browser/shell_browser_main_delegate.h6
-rw-r--r--extensions/shell/browser/shell_browser_main_parts.cc10
-rw-r--r--extensions/shell/browser/shell_desktop_controller_aura.cc (renamed from extensions/shell/browser/shell_desktop_controller.cc)50
-rw-r--r--extensions/shell/browser/shell_desktop_controller_aura.h (renamed from extensions/shell/browser/shell_desktop_controller.h)37
-rw-r--r--extensions/shell/browser/shell_desktop_controller_aura_unittest.cc (renamed from extensions/shell/browser/shell_desktop_controller_unittest.cc)16
-rw-r--r--extensions/shell/browser/shell_native_app_window.cc66
-rw-r--r--extensions/shell/browser/shell_native_app_window.h12
-rw-r--r--extensions/shell/browser/shell_native_app_window_aura.cc71
-rw-r--r--extensions/shell/browser/shell_native_app_window_aura.h36
-rw-r--r--extensions/shell/browser/shell_native_app_window_aura_unittest.cc74
-rw-r--r--extensions/shell/test/shell_test.cc4
21 files changed, 330 insertions, 157 deletions
diff --git a/extensions/shell/BUILD.gn b/extensions/shell/BUILD.gn
index d30429e..ccaf688 100644
--- a/extensions/shell/BUILD.gn
+++ b/extensions/shell/BUILD.gn
@@ -68,6 +68,7 @@ source_set("app_shell_lib") {
"browser/shell_app_delegate.h",
"browser/shell_app_window_client.cc",
"browser/shell_app_window_client.h",
+ "browser/shell_app_window_client_aura.cc",
"browser/shell_audio_controller_chromeos.cc",
"browser/shell_audio_controller_chromeos.h",
"browser/shell_browser_context.cc",
@@ -79,8 +80,8 @@ source_set("app_shell_lib") {
"browser/shell_browser_main_parts.h",
"browser/shell_content_browser_client.cc",
"browser/shell_content_browser_client.h",
- "browser/shell_desktop_controller.cc",
- "browser/shell_desktop_controller.h",
+ "browser/shell_desktop_controller_aura.cc",
+ "browser/shell_desktop_controller_aura.h",
"browser/shell_device_client.cc",
"browser/shell_device_client.h",
"browser/shell_display_info_provider.cc",
@@ -97,6 +98,8 @@ source_set("app_shell_lib") {
"browser/shell_extensions_browser_client.h",
"browser/shell_native_app_window.cc",
"browser/shell_native_app_window.h",
+ "browser/shell_native_app_window_aura.cc",
+ "browser/shell_native_app_window_aura.h",
"browser/shell_network_controller_chromeos.cc",
"browser/shell_network_controller_chromeos.h",
"browser/shell_network_delegate.cc",
diff --git a/extensions/shell/app/shell_main_delegate.cc b/extensions/shell/app/shell_main_delegate.cc
index d7aa5ab..69f0e61 100644
--- a/extensions/shell/app/shell_main_delegate.cc
+++ b/extensions/shell/app/shell_main_delegate.cc
@@ -26,8 +26,10 @@
#include "components/nacl/common/nacl_switches.h"
#if defined(OS_LINUX)
#include "components/nacl/common/nacl_paths.h"
-#include "components/nacl/zygote/nacl_fork_delegate_linux.h"
#endif // OS_LINUX
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
+#include "components/nacl/zygote/nacl_fork_delegate_linux.h"
+#endif // OS_POSIX && !OS_MACOSX && !OS_ANDROID
#endif // !DISABLE_NACL
namespace {
@@ -140,6 +142,9 @@ bool ShellMainDelegate::ProcessNeedsResourceBundle(
#if !defined(DISABLE_NACL)
process_type == switches::kNaClLoaderProcess ||
#endif
+#if defined(OS_MACOSX)
+ process_type == switches::kGpuProcess ||
+#endif
process_type == switches::kUtilityProcess;
}
diff --git a/extensions/shell/app/shell_main_delegate.h b/extensions/shell/app/shell_main_delegate.h
index 587de92..e736602 100644
--- a/extensions/shell/app/shell_main_delegate.h
+++ b/extensions/shell/app/shell_main_delegate.h
@@ -30,7 +30,8 @@ class ShellMainDelegate : public content::ContentMainDelegate {
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
+ !defined(OS_IOS)
void ZygoteStarting(
ScopedVector<content::ZygoteForkDelegate>* delegates) override;
#endif
diff --git a/extensions/shell/app_shell.gyp b/extensions/shell/app_shell.gyp
index bdbe699..ef9b246 100644
--- a/extensions/shell/app_shell.gyp
+++ b/extensions/shell/app_shell.gyp
@@ -38,7 +38,6 @@
'<(DEPTH)/mojo/mojo_base.gyp:mojo_environment_chromium',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
- '<(DEPTH)/ui/wm/wm.gyp:wm',
'<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
],
'include_dirs': [
@@ -72,8 +71,6 @@
'browser/shell_browser_main_parts.h',
'browser/shell_content_browser_client.cc',
'browser/shell_content_browser_client.h',
- 'browser/shell_desktop_controller.cc',
- 'browser/shell_desktop_controller.h',
'browser/shell_device_client.cc',
'browser/shell_device_client.h',
'browser/shell_display_info_provider.cc',
@@ -121,6 +118,18 @@
'utility/shell_content_utility_client.h',
],
'conditions': [
+ ['use_aura==1', {
+ 'dependencies': [
+ '<(DEPTH)/ui/wm/wm.gyp:wm',
+ ],
+ 'sources': [
+ 'browser/shell_app_window_client_aura.cc',
+ 'browser/shell_desktop_controller_aura.cc',
+ 'browser/shell_desktop_controller_aura.h',
+ 'browser/shell_native_app_window_aura.cc',
+ 'browser/shell_native_app_window_aura.h',
+ ],
+ }],
['chromeos==1', {
'dependencies': [
'<(DEPTH)/chromeos/chromeos.gyp:chromeos',
@@ -253,7 +262,7 @@
'../test/extensions_unittests_main.cc',
'browser/api/identity/identity_api_unittest.cc',
'browser/shell_audio_controller_chromeos_unittest.cc',
- 'browser/shell_desktop_controller_unittest.cc',
+ 'browser/shell_native_app_window_aura_unittest.cc',
'browser/shell_oauth2_token_service_unittest.cc',
'common/shell_content_client_unittest.cc'
],
@@ -263,6 +272,11 @@
'browser/shell_nacl_browser_delegate_unittest.cc',
],
}],
+ ['use_aura==1', {
+ 'sources': [
+ 'browser/shell_desktop_controller_aura_unittest.cc',
+ ],
+ }],
['chromeos==1', {
'dependencies': [
'<(DEPTH)/chromeos/chromeos.gyp:chromeos_test_support_without_gmock',
diff --git a/extensions/shell/browser/DEPS b/extensions/shell/browser/DEPS
index 032cdb0..f2175f2 100644
--- a/extensions/shell/browser/DEPS
+++ b/extensions/shell/browser/DEPS
@@ -27,6 +27,7 @@ include_rules = [
"+ppapi",
"+storage/browser/quota",
"+sync/api",
+ "+third_party/skia/include",
# Additional UI dependencies for app_shell. Note that no particular UI toolkit
# is supported; only Aura and some necessary bits to set up display surfaces.
diff --git a/extensions/shell/browser/default_shell_browser_main_delegate.cc b/extensions/shell/browser/default_shell_browser_main_delegate.cc
index 877926b..978d273 100644
--- a/extensions/shell/browser/default_shell_browser_main_delegate.cc
+++ b/extensions/shell/browser/default_shell_browser_main_delegate.cc
@@ -9,9 +9,12 @@
#include "base/files/file_util.h"
#include "base/strings/string_tokenizer.h"
#include "extensions/common/switches.h"
-#include "extensions/shell/browser/shell_desktop_controller.h"
#include "extensions/shell/browser/shell_extension_system.h"
+#if defined(USE_AURA)
+#include "extensions/shell/browser/shell_desktop_controller_aura.h"
+#endif
+
namespace extensions {
DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
@@ -62,7 +65,11 @@ void DefaultShellBrowserMainDelegate::Shutdown() {
}
DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
- return new ShellDesktopController();
+#if defined(USE_AURA)
+ return new ShellDesktopControllerAura();
+#else
+ return NULL;
+#endif
}
} // namespace extensions
diff --git a/extensions/shell/browser/desktop_controller.h b/extensions/shell/browser/desktop_controller.h
index 40a4e53..84e02fe 100644
--- a/extensions/shell/browser/desktop_controller.h
+++ b/extensions/shell/browser/desktop_controller.h
@@ -5,6 +5,8 @@
#ifndef EXTENSIONS_SHELL_BROWSER_DESKTOP_CONTROLLER_H_
#define EXTENSIONS_SHELL_BROWSER_DESKTOP_CONTROLLER_H_
+#include "ui/gfx/native_widget_types.h"
+
namespace aura {
class Window;
class WindowTreeHost;
@@ -14,14 +16,19 @@ namespace content {
class BrowserContext;
}
+namespace gfx {
+class Size;
+}
+
namespace extensions {
class AppWindow;
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.
+// extensions shell. ShellDesktopControllerAura provides a default
+// implementation for app_shell, and other embedders (such as athena) can
+// provide their own.
// TODO(jamescook|oshima): Clean up this interface now that there is only one
// way to create an app window.
class DesktopController {
@@ -34,8 +41,9 @@ class DesktopController {
// we need a singleton somewhere).
static DesktopController* instance();
- // Returns the WindowTreeHost created by this DesktopController.
- virtual aura::WindowTreeHost* GetHost() = 0;
+ // Get the size of the window created by this DesktopController. This should
+ // typically be full-screen.
+ virtual gfx::Size GetWindowSize() = 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
@@ -44,7 +52,7 @@ class DesktopController {
const Extension* extension) = 0;
// Attaches the window to our window hierarchy.
- virtual void AddAppWindow(aura::Window* window) = 0;
+ virtual void AddAppWindow(gfx::NativeWindow window) = 0;
// Removes the window from the desktop.
virtual void RemoveAppWindow(AppWindow* window) = 0;
diff --git a/extensions/shell/browser/shell_app_window_client.cc b/extensions/shell/browser/shell_app_window_client.cc
index 293f58b..8ad1670 100644
--- a/extensions/shell/browser/shell_app_window_client.cc
+++ b/extensions/shell/browser/shell_app_window_client.cc
@@ -8,7 +8,6 @@
#include "extensions/browser/app_window/app_window.h"
#include "extensions/shell/browser/desktop_controller.h"
-#include "extensions/shell/browser/shell_native_app_window.h"
namespace extensions {
@@ -24,16 +23,6 @@ AppWindow* ShellAppWindowClient::CreateAppWindow(
return DesktopController::instance()->CreateAppWindow(context, extension);
}
-NativeAppWindow* ShellAppWindowClient::CreateNativeAppWindow(
- AppWindow* window,
- AppWindow::CreateParams* params) {
- ShellNativeAppWindow* native_app_window =
- new ShellNativeAppWindow(window, *params);
- DesktopController::instance()->AddAppWindow(
- native_app_window->GetNativeWindow());
- return native_app_window;
-}
-
void ShellAppWindowClient::OpenDevToolsWindow(
content::WebContents* web_contents,
const base::Closure& callback) {
diff --git a/extensions/shell/browser/shell_app_window_client.h b/extensions/shell/browser/shell_app_window_client.h
index 0ead4a8..ecb5f0b 100644
--- a/extensions/shell/browser/shell_app_window_client.h
+++ b/extensions/shell/browser/shell_app_window_client.h
@@ -20,6 +20,8 @@ class ShellAppWindowClient : public AppWindowClient {
// AppWindowClient overrides:
AppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension) override;
+ // Note that CreateNativeAppWindow is defined in separate (per-framework)
+ // implementation files.
NativeAppWindow* CreateNativeAppWindow(
AppWindow* window,
AppWindow::CreateParams* params) override;
diff --git a/extensions/shell/browser/shell_app_window_client_aura.cc b/extensions/shell/browser/shell_app_window_client_aura.cc
new file mode 100644
index 0000000..af63f27
--- /dev/null
+++ b/extensions/shell/browser/shell_app_window_client_aura.cc
@@ -0,0 +1,23 @@
+// 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/shell_app_window_client.h"
+
+#include "extensions/browser/app_window/app_window.h"
+#include "extensions/shell/browser/desktop_controller.h"
+#include "extensions/shell/browser/shell_native_app_window_aura.h"
+
+namespace extensions {
+
+NativeAppWindow* ShellAppWindowClient::CreateNativeAppWindow(
+ AppWindow* window,
+ AppWindow::CreateParams* params) {
+ ShellNativeAppWindow* native_app_window =
+ new ShellNativeAppWindowAura(window, *params);
+ DesktopController::instance()->AddAppWindow(
+ native_app_window->GetNativeWindow());
+ return native_app_window;
+}
+
+} // namespace extensions
diff --git a/extensions/shell/browser/shell_browser_main_delegate.h b/extensions/shell/browser/shell_browser_main_delegate.h
index 1b234c5..a3ddf7f 100644
--- a/extensions/shell/browser/shell_browser_main_delegate.h
+++ b/extensions/shell/browser/shell_browser_main_delegate.h
@@ -25,9 +25,9 @@ class ShellBrowserMainDelegate {
// other services such as BrowserContext / extension system are shut down.
virtual void Shutdown() = 0;
- // Creates the ShellDesktopController instance to initialize the root window
- // and window manager. Subclass may return its subclass to customize the
- // windo manager.
+ // Creates the ShellDesktopControllerAura instance to initialize the root
+ // window and window manager. Subclass may return its subclass to customize
+ // the window manager.
virtual DesktopController* CreateDesktopController() = 0;
};
diff --git a/extensions/shell/browser/shell_browser_main_parts.cc b/extensions/shell/browser/shell_browser_main_parts.cc
index a454942..5651795 100644
--- a/extensions/shell/browser/shell_browser_main_parts.cc
+++ b/extensions/shell/browser/shell_browser_main_parts.cc
@@ -24,7 +24,7 @@
#include "extensions/shell/browser/shell_browser_context.h"
#include "extensions/shell/browser/shell_browser_context_keyed_service_factories.h"
#include "extensions/shell/browser/shell_browser_main_delegate.h"
-#include "extensions/shell/browser/shell_desktop_controller.h"
+#include "extensions/shell/browser/shell_desktop_controller_aura.h"
#include "extensions/shell/browser/shell_device_client.h"
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/browser/shell_extension_system_factory.h"
@@ -33,11 +33,13 @@
#include "extensions/shell/browser/shell_omaha_query_params_delegate.h"
#include "extensions/shell/common/shell_extensions_client.h"
#include "extensions/shell/common/switches.h"
-#include "ui/aura/env.h"
-#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/base/resource/resource_bundle.h"
+#if defined(USE_AURA)
+#include "ui/aura/env.h"
+#endif
+
#if defined(OS_CHROMEOS)
#include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -127,7 +129,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
// Initialize our "profile" equivalent.
browser_context_.reset(new ShellBrowserContext(net_log_.get()));
+#if defined(USE_AURA)
aura::Env::GetInstance()->set_context_factory(content::GetContextFactory());
+#endif
storage_monitor::StorageMonitor::Create();
diff --git a/extensions/shell/browser/shell_desktop_controller.cc b/extensions/shell/browser/shell_desktop_controller_aura.cc
index f7da092..3a59a42 100644
--- a/extensions/shell/browser/shell_desktop_controller.cc
+++ b/extensions/shell/browser/shell_desktop_controller_aura.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "extensions/shell/browser/shell_desktop_controller.h"
+#include "extensions/shell/browser/shell_desktop_controller_aura.h"
#include <algorithm>
#include <string>
@@ -24,6 +24,7 @@
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/image_cursors.h"
#include "ui/base/ime/input_method_initializer.h"
+#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/base_focus_rules.h"
@@ -158,13 +159,13 @@ class AppsFocusRules : public wm::BaseFocusRules {
} // namespace
-ShellDesktopController::ShellDesktopController()
+ShellDesktopControllerAura::ShellDesktopControllerAura()
: app_window_client_(new ShellAppWindowClient) {
extensions::AppWindowClient::Set(app_window_client_.get());
#if defined(OS_CHROMEOS)
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
- AddObserver(this);
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
+ this);
display_configurator_.reset(new ui::DisplayConfigurator);
display_configurator_->Init(false);
display_configurator_->ForceInitialConfigure(0);
@@ -173,21 +174,21 @@ ShellDesktopController::ShellDesktopController()
CreateRootWindow();
}
-ShellDesktopController::~ShellDesktopController() {
+ShellDesktopControllerAura::~ShellDesktopControllerAura() {
CloseAppWindows();
DestroyRootWindow();
#if defined(OS_CHROMEOS)
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
- RemoveObserver(this);
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
+ this);
#endif
extensions::AppWindowClient::Set(NULL);
}
-aura::WindowTreeHost* ShellDesktopController::GetHost() {
- return host_.get();
+gfx::Size ShellDesktopControllerAura::GetWindowSize() {
+ return host_->window()->bounds().size();
}
-AppWindow* ShellDesktopController::CreateAppWindow(
+AppWindow* ShellDesktopControllerAura::CreateAppWindow(
content::BrowserContext* context,
const Extension* extension) {
app_windows_.push_back(
@@ -195,18 +196,18 @@ AppWindow* ShellDesktopController::CreateAppWindow(
return app_windows_.back();
}
-void ShellDesktopController::AddAppWindow(aura::Window* window) {
- aura::Window* root_window = GetHost()->window();
+void ShellDesktopControllerAura::AddAppWindow(gfx::NativeWindow window) {
+ aura::Window* root_window = host_->window();
root_window->AddChild(window);
}
-void ShellDesktopController::RemoveAppWindow(AppWindow* window) {
+void ShellDesktopControllerAura::RemoveAppWindow(AppWindow* window) {
auto iter = std::find(app_windows_.begin(), app_windows_.end(), window);
DCHECK(iter != app_windows_.end());
app_windows_.erase(iter);
}
-void ShellDesktopController::CloseAppWindows() {
+void ShellDesktopControllerAura::CloseAppWindows() {
// Create a copy of the window vector, because closing the windows will
// trigger RemoveAppWindow, which will invalidate the iterator.
// This vector should be small enough that this should not be an issue.
@@ -216,7 +217,7 @@ void ShellDesktopController::CloseAppWindows() {
app_windows_.clear();
}
-aura::Window* ShellDesktopController::GetDefaultParent(
+aura::Window* ShellDesktopControllerAura::GetDefaultParent(
aura::Window* context,
aura::Window* window,
const gfx::Rect& bounds) {
@@ -224,16 +225,17 @@ aura::Window* ShellDesktopController::GetDefaultParent(
}
#if defined(OS_CHROMEOS)
-void ShellDesktopController::PowerButtonEventReceived(
+void ShellDesktopControllerAura::PowerButtonEventReceived(
bool down,
const base::TimeTicks& timestamp) {
if (down) {
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
- RequestShutdown();
+ chromeos::DBusThreadManager::Get()
+ ->GetPowerManagerClient()
+ ->RequestShutdown();
}
}
-void ShellDesktopController::OnDisplayModeChanged(
+void ShellDesktopControllerAura::OnDisplayModeChanged(
const std::vector<ui::DisplayConfigurator::DisplayState>& displays) {
gfx::Size size = GetPrimaryDisplaySize();
if (!size.IsEmpty())
@@ -241,7 +243,7 @@ void ShellDesktopController::OnDisplayModeChanged(
}
#endif
-void ShellDesktopController::OnHostCloseRequested(
+void ShellDesktopControllerAura::OnHostCloseRequested(
const aura::WindowTreeHost* host) {
DCHECK_EQ(host_.get(), host);
CloseAppWindows();
@@ -249,7 +251,7 @@ void ShellDesktopController::OnHostCloseRequested(
base::MessageLoop::QuitClosure());
}
-void ShellDesktopController::InitWindowManager() {
+void ShellDesktopControllerAura::InitWindowManager() {
wm::FocusController* focus_controller =
new wm::FocusController(new AppsFocusRules());
aura::client::SetFocusClient(host_->window(), focus_controller);
@@ -285,7 +287,7 @@ void ShellDesktopController::InitWindowManager() {
#endif
}
-void ShellDesktopController::CreateRootWindow() {
+void ShellDesktopControllerAura::CreateRootWindow() {
// Set up basic pieces of ui::wm.
gfx::Size size;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -319,7 +321,7 @@ void ShellDesktopController::CreateRootWindow() {
host_->Show();
}
-void ShellDesktopController::DestroyRootWindow() {
+void ShellDesktopControllerAura::DestroyRootWindow() {
host_->RemoveObserver(this);
if (input_method_filter_)
root_window_event_filter_->RemoveHandler(input_method_filter_.get());
@@ -345,7 +347,7 @@ void ShellDesktopController::DestroyRootWindow() {
host_.reset();
}
-gfx::Size ShellDesktopController::GetPrimaryDisplaySize() {
+gfx::Size ShellDesktopControllerAura::GetPrimaryDisplaySize() {
#if defined(OS_CHROMEOS)
const std::vector<ui::DisplayConfigurator::DisplayState>& displays =
display_configurator_->cached_displays();
diff --git a/extensions/shell/browser/shell_desktop_controller.h b/extensions/shell/browser/shell_desktop_controller_aura.h
index 2087234..5ec11c9 100644
--- a/extensions/shell/browser/shell_desktop_controller.h
+++ b/extensions/shell/browser/shell_desktop_controller_aura.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 EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_
-#define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_
+#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
+#define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
#include <vector>
@@ -55,22 +55,23 @@ class AppWindowClient;
class Extension;
// Handles desktop-related tasks for app_shell.
-class ShellDesktopController : public DesktopController,
- public aura::client::WindowTreeClient,
+class ShellDesktopControllerAura
+ : public DesktopController,
+ public aura::client::WindowTreeClient,
#if defined(OS_CHROMEOS)
- public chromeos::PowerManagerClient::Observer,
- public ui::DisplayConfigurator::Observer,
+ public chromeos::PowerManagerClient::Observer,
+ public ui::DisplayConfigurator::Observer,
#endif
- public aura::WindowTreeHostObserver {
+ public aura::WindowTreeHostObserver {
public:
- ShellDesktopController();
- ~ShellDesktopController() override;
+ ShellDesktopControllerAura();
+ ~ShellDesktopControllerAura() override;
// DesktopController:
- aura::WindowTreeHost* GetHost() override;
+ gfx::Size GetWindowSize() override;
AppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension) override;
- void AddAppWindow(aura::Window* window) override;
+ void AddAppWindow(gfx::NativeWindow window) override;
void RemoveAppWindow(AppWindow* window) override;
void CloseAppWindows() override;
@@ -81,13 +82,13 @@ class ShellDesktopController : public DesktopController,
#if defined(OS_CHROMEOS)
// chromeos::PowerManagerClient::Observer overrides:
- virtual void PowerButtonEventReceived(bool down,
- const base::TimeTicks& timestamp)
- override;
+ void PowerButtonEventReceived(bool down,
+ const base::TimeTicks& timestamp) override;
// ui::DisplayConfigurator::Observer overrides.
- virtual void OnDisplayModeChanged(const std::vector<
- ui::DisplayConfigurator::DisplayState>& displays) override;
+ void OnDisplayModeChanged(
+ const std::vector<ui::DisplayConfigurator::DisplayState>& displays)
+ override;
#endif
// aura::WindowTreeHostObserver overrides:
@@ -137,9 +138,9 @@ class ShellDesktopController : public DesktopController,
// NativeAppWindow::Close() deletes the AppWindow.
std::vector<AppWindow*> app_windows_;
- DISALLOW_COPY_AND_ASSIGN(ShellDesktopController);
+ DISALLOW_COPY_AND_ASSIGN(ShellDesktopControllerAura);
};
} // namespace extensions
-#endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_
+#endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
diff --git a/extensions/shell/browser/shell_desktop_controller_unittest.cc b/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
index 5972d58..fc1c01a 100644
--- a/extensions/shell/browser/shell_desktop_controller_unittest.cc
+++ b/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "extensions/shell/browser/shell_desktop_controller.h"
+#include "extensions/shell/browser/shell_desktop_controller_aura.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -16,15 +16,15 @@
namespace extensions {
-class ShellDesktopControllerTest : public aura::test::AuraTestBase {
+class ShellDesktopControllerAuraTest : public aura::test::AuraTestBase {
public:
- ShellDesktopControllerTest()
+ ShellDesktopControllerAuraTest()
#if defined(OS_CHROMEOS)
: power_manager_client_(NULL)
#endif
{
}
- ~ShellDesktopControllerTest() override {}
+ ~ShellDesktopControllerAuraTest() override {}
void SetUp() override {
#if defined(OS_CHROMEOS)
@@ -34,7 +34,7 @@ class ShellDesktopControllerTest : public aura::test::AuraTestBase {
dbus_setter->SetPowerManagerClient(make_scoped_ptr(power_manager_client_));
#endif
aura::test::AuraTestBase::SetUp();
- controller_.reset(new ShellDesktopController());
+ controller_.reset(new ShellDesktopControllerAura());
}
void TearDown() override {
@@ -46,20 +46,20 @@ class ShellDesktopControllerTest : public aura::test::AuraTestBase {
}
protected:
- scoped_ptr<ShellDesktopController> controller_;
+ scoped_ptr<ShellDesktopControllerAura> controller_;
#if defined(OS_CHROMEOS)
chromeos::FakePowerManagerClient* power_manager_client_; // Not owned.
#endif
private:
- DISALLOW_COPY_AND_ASSIGN(ShellDesktopControllerTest);
+ DISALLOW_COPY_AND_ASSIGN(ShellDesktopControllerAuraTest);
};
#if defined(OS_CHROMEOS)
// Tests that a shutdown request is sent to the power manager when the power
// button is pressed.
-TEST_F(ShellDesktopControllerTest, PowerButton) {
+TEST_F(ShellDesktopControllerAuraTest, PowerButton) {
// Ignore button releases.
power_manager_client_->SendPowerButtonEvent(false /* down */,
base::TimeTicks());
diff --git a/extensions/shell/browser/shell_native_app_window.cc b/extensions/shell/browser/shell_native_app_window.cc
index 0f3d29f..dd8bfa0 100644
--- a/extensions/shell/browser/shell_native_app_window.cc
+++ b/extensions/shell/browser/shell_native_app_window.cc
@@ -4,48 +4,24 @@
#include "extensions/shell/browser/shell_native_app_window.h"
-#include "content/public/browser/web_contents.h"
#include "extensions/shell/browser/desktop_controller.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
+#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
-#include "ui/wm/core/window_util.h"
namespace extensions {
-namespace {
-
-gfx::Size GetDesktopWindowSize() {
- return DesktopController::instance()->GetHost()->window()->bounds().size();
-}
-
-} // namespace
ShellNativeAppWindow::ShellNativeAppWindow(
AppWindow* app_window,
const AppWindow::CreateParams& params)
: app_window_(app_window) {
- gfx::Rect bounds = params.GetInitialWindowBounds(GetFrameInsets());
- bool position_specified =
- bounds.x() != AppWindow::BoundsSpecification::kUnspecifiedPosition &&
- bounds.y() != AppWindow::BoundsSpecification::kUnspecifiedPosition;
- if (!position_specified)
- bounds.set_origin(GetBounds().origin());
- SetBounds(bounds);
}
ShellNativeAppWindow::~ShellNativeAppWindow() {
}
-bool ShellNativeAppWindow::IsActive() const {
- // Even though app_shell only supports a single app window, there might be
- // some sort of system-level dialog open and active.
- aura::Window* window = GetWindow();
- return window && wm::IsActiveWindow(window);
-}
-
bool ShellNativeAppWindow::IsMaximized() const {
return false;
}
@@ -61,10 +37,6 @@ bool ShellNativeAppWindow::IsFullscreen() const {
return false;
}
-gfx::NativeWindow ShellNativeAppWindow::GetNativeWindow() const {
- return GetWindow();
-}
-
gfx::Rect ShellNativeAppWindow::GetRestoredBounds() const {
// app_shell windows cannot be maximized, so the current bounds are the
// restored bounds.
@@ -75,18 +47,6 @@ ui::WindowShowState ShellNativeAppWindow::GetRestoredState() const {
return ui::SHOW_STATE_NORMAL;
}
-gfx::Rect ShellNativeAppWindow::GetBounds() const {
- return GetWindow()->GetBoundsInScreen();
-}
-
-void ShellNativeAppWindow::Show() {
- GetWindow()->Show();
-}
-
-void ShellNativeAppWindow::Hide() {
- GetWindow()->Hide();
-}
-
void ShellNativeAppWindow::ShowInactive() {
NOTIMPLEMENTED();
}
@@ -96,18 +56,6 @@ void ShellNativeAppWindow::Close() {
app_window_->OnNativeClose();
}
-void ShellNativeAppWindow::Activate() {
- aura::Window* window = GetWindow();
- if (window)
- wm::ActivateWindow(window);
-}
-
-void ShellNativeAppWindow::Deactivate() {
- aura::Window* window = GetWindow();
- if (window)
- wm::DeactivateWindow(window);
-}
-
void ShellNativeAppWindow::Maximize() {
NOTIMPLEMENTED();
}
@@ -120,10 +68,6 @@ void ShellNativeAppWindow::Restore() {
NOTIMPLEMENTED();
}
-void ShellNativeAppWindow::SetBounds(const gfx::Rect& bounds) {
- GetWindow()->SetBounds(bounds);
-}
-
void ShellNativeAppWindow::FlashFrame(bool flash) {
NOTIMPLEMENTED();
}
@@ -236,12 +180,12 @@ void ShellNativeAppWindow::UpdateShelfMenu() {
gfx::Size ShellNativeAppWindow::GetContentMinimumSize() const {
// Content fills the desktop and cannot be resized.
- return GetDesktopWindowSize();
+ return DesktopController::instance()->GetWindowSize();
}
gfx::Size ShellNativeAppWindow::GetContentMaximumSize() const {
// Content fills the desktop and cannot be resized.
- return GetDesktopWindowSize();
+ return DesktopController::instance()->GetWindowSize();
}
void ShellNativeAppWindow::SetContentSizeConstraints(
@@ -259,8 +203,4 @@ bool ShellNativeAppWindow::CanHaveAlphaEnabled() const {
return false;
}
-aura::Window* ShellNativeAppWindow::GetWindow() const {
- return app_window_->web_contents()->GetNativeView();
-}
-
} // namespace extensions
diff --git a/extensions/shell/browser/shell_native_app_window.h b/extensions/shell/browser/shell_native_app_window.h
index 8402050..d86470a 100644
--- a/extensions/shell/browser/shell_native_app_window.h
+++ b/extensions/shell/browser/shell_native_app_window.h
@@ -17,25 +17,19 @@ class ShellNativeAppWindow : public NativeAppWindow {
const AppWindow::CreateParams& params);
~ShellNativeAppWindow() override;
+ AppWindow* app_window() const { return app_window_; }
+
// ui::BaseView overrides:
- bool IsActive() const override;
bool IsMaximized() const override;
bool IsMinimized() const override;
bool IsFullscreen() const override;
- gfx::NativeWindow GetNativeWindow() const override;
gfx::Rect GetRestoredBounds() const override;
ui::WindowShowState GetRestoredState() const override;
- gfx::Rect GetBounds() const override;
- void Show() override;
- void Hide() override;
void ShowInactive() override;
void Close() override;
- void Activate() override;
- void Deactivate() override;
void Maximize() override;
void Minimize() override;
void Restore() override;
- void SetBounds(const gfx::Rect& bounds) override;
void FlashFrame(bool flash) override;
bool IsAlwaysOnTop() const override;
void SetAlwaysOnTop(bool always_on_top) override;
@@ -77,8 +71,6 @@ class ShellNativeAppWindow : public NativeAppWindow {
bool CanHaveAlphaEnabled() const override;
private:
- aura::Window* GetWindow() const;
-
AppWindow* app_window_;
DISALLOW_COPY_AND_ASSIGN(ShellNativeAppWindow);
diff --git a/extensions/shell/browser/shell_native_app_window_aura.cc b/extensions/shell/browser/shell_native_app_window_aura.cc
new file mode 100644
index 0000000..c015896
--- /dev/null
+++ b/extensions/shell/browser/shell_native_app_window_aura.cc
@@ -0,0 +1,71 @@
+// 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/shell_native_app_window_aura.h"
+
+#include "content/public/browser/web_contents.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/wm/core/window_util.h"
+
+namespace extensions {
+
+ShellNativeAppWindowAura::ShellNativeAppWindowAura(
+ AppWindow* app_window,
+ const AppWindow::CreateParams& params)
+ : ShellNativeAppWindow(app_window, params) {
+ // TODO(yoz): We might have to duplicate this for mac.
+ gfx::Rect bounds = params.GetInitialWindowBounds(GetFrameInsets());
+ bool position_specified =
+ bounds.x() != AppWindow::BoundsSpecification::kUnspecifiedPosition &&
+ bounds.y() != AppWindow::BoundsSpecification::kUnspecifiedPosition;
+ if (!position_specified)
+ bounds.set_origin(GetBounds().origin());
+ SetBounds(bounds);
+}
+
+ShellNativeAppWindowAura::~ShellNativeAppWindowAura() {
+}
+
+bool ShellNativeAppWindowAura::IsActive() const {
+ // Even though app_shell only supports a single app window, there might be
+ // some sort of system-level dialog open and active.
+ aura::Window* window = GetNativeWindow();
+ return window && wm::IsActiveWindow(window);
+}
+
+gfx::NativeWindow ShellNativeAppWindowAura::GetNativeWindow() const {
+ return app_window()->web_contents()->GetNativeView();
+}
+
+gfx::Rect ShellNativeAppWindowAura::GetBounds() const {
+ return GetNativeWindow()->GetBoundsInScreen();
+}
+
+void ShellNativeAppWindowAura::Show() {
+ GetNativeWindow()->Show();
+}
+
+void ShellNativeAppWindowAura::Hide() {
+ GetNativeWindow()->Hide();
+}
+
+void ShellNativeAppWindowAura::Activate() {
+ aura::Window* window = GetNativeWindow();
+ if (window)
+ wm::ActivateWindow(window);
+}
+
+void ShellNativeAppWindowAura::Deactivate() {
+ aura::Window* window = GetNativeWindow();
+ if (window)
+ wm::DeactivateWindow(window);
+}
+
+void ShellNativeAppWindowAura::SetBounds(const gfx::Rect& bounds) {
+ GetNativeWindow()->SetBounds(bounds);
+}
+
+} // namespace extensions
diff --git a/extensions/shell/browser/shell_native_app_window_aura.h b/extensions/shell/browser/shell_native_app_window_aura.h
new file mode 100644
index 0000000..c566b02
--- /dev/null
+++ b/extensions/shell/browser/shell_native_app_window_aura.h
@@ -0,0 +1,36 @@
+// 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_SHELL_NATIVE_APP_WINDOW_AURA_H_
+#define EXTENSIONS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_AURA_H_
+
+#include "base/macros.h"
+#include "extensions/shell/browser/shell_native_app_window.h"
+
+namespace extensions {
+
+// The Aura-specific parts of the app_shell NativeAppWindow implementation.
+class ShellNativeAppWindowAura : public ShellNativeAppWindow {
+ public:
+ ShellNativeAppWindowAura(extensions::AppWindow* app_window,
+ const AppWindow::CreateParams& params);
+ ~ShellNativeAppWindowAura() override;
+
+ // ui::BaseWindow:
+ bool IsActive() const override;
+ gfx::NativeWindow GetNativeWindow() const override;
+ gfx::Rect GetBounds() const override;
+ void Show() override;
+ void Hide() override;
+ void Activate() override;
+ void Deactivate() override;
+ void SetBounds(const gfx::Rect& bounds) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ShellNativeAppWindowAura);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_AURA_H_
diff --git a/extensions/shell/browser/shell_native_app_window_aura_unittest.cc b/extensions/shell/browser/shell_native_app_window_aura_unittest.cc
new file mode 100644
index 0000000..5592f1d
--- /dev/null
+++ b/extensions/shell/browser/shell_native_app_window_aura_unittest.cc
@@ -0,0 +1,74 @@
+// 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/shell_native_app_window_aura.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/test_browser_context.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/browser/app_window/app_window.h"
+#include "extensions/browser/app_window/test_app_window_contents.h"
+#include "extensions/browser/extensions_test.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
+#include "extensions/shell/browser/desktop_controller.h"
+#include "extensions/shell/browser/shell_app_delegate.h"
+#include "extensions/shell/browser/shell_app_window_client.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace extensions {
+
+class ShellNativeAppWindowAuraTest : public ExtensionsTest {
+ public:
+ ShellNativeAppWindowAuraTest()
+ : notification_service_(content::NotificationService::Create()) {
+ AppWindowClient::Set(&app_window_client_);
+ }
+
+ ~ShellNativeAppWindowAuraTest() override {}
+
+ protected:
+ content::TestBrowserThreadBundle thread_bundle_;
+ scoped_ptr<content::NotificationService> notification_service_;
+ ShellAppWindowClient app_window_client_;
+};
+
+TEST_F(ShellNativeAppWindowAuraTest, Bounds) {
+ // The BrowserContext used here must be destroyed before the thread bundle,
+ // because of destructors of things spawned from creating a WebContents.
+ scoped_ptr<content::BrowserContext> browser_context(
+ new content::TestBrowserContext);
+ scoped_refptr<Extension> extension =
+ ExtensionBuilder()
+ .SetManifest(DictionaryBuilder()
+ .Set("name", "test extension")
+ .Set("version", "1")
+ .Set("manifest_version", 2))
+ .Build();
+
+ AppWindow* app_window = new AppWindow(
+ browser_context.get(), new ShellAppDelegate, extension.get());
+ content::WebContents* web_contents = content::WebContents::Create(
+ content::WebContents::CreateParams(browser_context.get()));
+ app_window->SetAppWindowContentsForTesting(
+ make_scoped_ptr(new TestAppWindowContents(web_contents)));
+
+ AppWindow::BoundsSpecification window_spec;
+ window_spec.bounds = gfx::Rect(100, 200, 300, 400);
+ AppWindow::CreateParams params;
+ params.window_spec = window_spec;
+
+ ShellNativeAppWindowAura window(app_window, params);
+
+ gfx::Rect bounds = window.GetBounds();
+ EXPECT_EQ(window_spec.bounds, bounds);
+
+ // Delete the AppWindow.
+ app_window->OnNativeClose();
+}
+
+} // namespace extensions
diff --git a/extensions/shell/test/shell_test.cc b/extensions/shell/test/shell_test.cc
index 87e5430..37147766a 100644
--- a/extensions/shell/test/shell_test.cc
+++ b/extensions/shell/test/shell_test.cc
@@ -8,8 +8,8 @@
#include "base/logging.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/shell/browser/desktop_controller.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"
namespace extensions {
@@ -44,7 +44,7 @@ void AppShellTest::RunTestOnMainThreadLoop() {
TearDownOnMainThread();
// Clean up the app window.
- ShellDesktopController::instance()->CloseAppWindows();
+ DesktopController::instance()->CloseAppWindows();
}
} // namespace extensions