diff options
Diffstat (limited to 'ui/aura_shell')
-rw-r--r-- | ui/aura_shell/aura_shell.gyp | 22 | ||||
-rw-r--r-- | ui/aura_shell/aura_shell_export.h | 30 | ||||
-rw-r--r-- | ui/aura_shell/aura_shell_switches.cc | 44 | ||||
-rw-r--r-- | ui/aura_shell/aura_shell_switches.h | 29 | ||||
-rw-r--r-- | ui/aura_shell/run_all_unittests.cc | 9 | ||||
-rw-r--r-- | ui/aura_shell/screenshot_delegate.h | 22 | ||||
-rw-r--r-- | ui/aura_shell/shell.cc | 369 | ||||
-rw-r--r-- | ui/aura_shell/shell.h | 149 | ||||
-rw-r--r-- | ui/aura_shell/shell_delegate.h | 67 | ||||
-rw-r--r-- | ui/aura_shell/shell_factory.h | 27 | ||||
-rw-r--r-- | ui/aura_shell/shell_unittest.cc | 292 | ||||
-rw-r--r-- | ui/aura_shell/shell_window_ids.h | 47 |
12 files changed, 11 insertions, 1096 deletions
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp index 2b821e6..163928f 100644 --- a/ui/aura_shell/aura_shell.gyp +++ b/ui/aura_shell/aura_shell.gyp @@ -33,13 +33,13 @@ ], 'sources': [ # All .cc, .h under views, except unittests - 'aura_shell_switches.cc', - 'aura_shell_switches.h', - 'shell.cc', - 'shell.h', - 'shell_delegate.h', - 'shell_factory.h', - 'shell_window_ids.h', + '../../ash/ash_switches.cc', + '../../ash/ash_switches.h', + '../../ash/shell.cc', + '../../ash/shell.h', + '../../ash/shell_delegate.h', + '../../ash/shell_factory.h', + '../../ash/shell_window_ids.h', '../../ash/accelerators/accelerator_controller.cc', '../../ash/accelerators/accelerator_controller.h', '../../ash/accelerators/accelerator_filter.cc', @@ -174,22 +174,22 @@ 'aura_shell', ], 'sources': [ - 'run_all_unittests.cc', - 'shell_unittest.cc', '../../ash/accelerators/accelerator_controller_unittest.cc', '../../ash/drag_drop/drag_drop_controller_unittest.cc', '../../ash/launcher/launcher_model_unittest.cc', '../../ash/launcher/launcher_unittest.cc', '../../ash/launcher/view_model_unittest.cc', '../../ash/launcher/view_model_utils_unittest.cc', - '../../ash/test/test_suite.cc', - '../../ash/test/test_suite.h', + '../../ash/shell_unittest.cc', + '../../ash/test/ash_unittests.cc', '../../ash/test/aura_shell_test_base.cc', '../../ash/test/aura_shell_test_base.h', '../../ash/test/test_activation_delegate.cc', '../../ash/test/test_activation_delegate.h', '../../ash/test/test_shell_delegate.cc', '../../ash/test/test_shell_delegate.h', + '../../ash/test/test_suite.cc', + '../../ash/test/test_suite.h', '../../ash/tooltips/tooltip_controller_unittest.cc', '../../ash/wm/activation_controller_unittest.cc', '../../ash/wm/default_container_layout_manager_unittest.cc', diff --git a/ui/aura_shell/aura_shell_export.h b/ui/aura_shell/aura_shell_export.h deleted file mode 100644 index 94ed04c..0000000 --- a/ui/aura_shell/aura_shell_export.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_AURA_SHELL_EXPORT_H -#define UI_AURA_SHELL_AURA_SHELL_EXPORT_H -#pragma once - -// Defines AURA_SHELL_EXPORT so that functionality implemented by the aura_shell -// module can be exported to consumers. - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(AURA_SHELL_IMPLEMENTATION) -#define AURA_SHELL_EXPORT __declspec(dllexport) -#else -#define AURA_SHELL_EXPORT __declspec(dllimport) -#endif // defined(AURA_SHELL_IMPLEMENTATION) - -#else // defined(WIN32) -#define AURA_SHELL_EXPORT __attribute__((visibility("default"))) -#endif - -#else // defined(COMPONENT_BUILD) -#define AURA_SHELL_EXPORT -#endif - -#endif // UI_AURA_SHELL_AURA_SHELL_EXPORT_H - diff --git a/ui/aura_shell/aura_shell_switches.cc b/ui/aura_shell/aura_shell_switches.cc deleted file mode 100644 index 6c6e728..0000000 --- a/ui/aura_shell/aura_shell_switches.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2011 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 "ui/aura_shell/aura_shell_switches.h" - -#include <string> - -#include "base/command_line.h" - -namespace aura_shell { -namespace switches { - -// Avoid drawing drop shadows under windows. -const char kAuraNoShadows[] = "aura-no-shadows"; - -// Use Aura-style translucent window frame. -const char kAuraTranslucentFrames[] = "aura-translucent-frames"; - -// Use views-based app list. -const char kAuraViewsAppList[] = "aura-views-applist"; - -// Use a custom window style, e.g. --aura-window-mode=compact. -// When this flag is not passed we default to "normal" mode. -const char kAuraWindowMode[] = "aura-window-mode"; - -// Show only a single maximized window, like traditional non-Aura builds. -// Useful for low-resolution screens, such as on laptops. -const char kAuraWindowModeCompact[] = "compact"; - -// Default window management with multiple draggable windows. -const char kAuraWindowModeNormal[] = "normal"; - -// Use Aura-style workspace window dragging and sizing. -const char kAuraWorkspaceManager[] = "aura-workspace-manager"; - -bool IsAuraWindowModeCompact() { - std::string mode = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kAuraWindowMode); - return mode == switches::kAuraWindowModeCompact; -} - -} // namespace switches -} // namespace aura_shell diff --git a/ui/aura_shell/aura_shell_switches.h b/ui/aura_shell/aura_shell_switches.h deleted file mode 100644 index fd6ffcb3..0000000 --- a/ui/aura_shell/aura_shell_switches.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_AURA_SHELL_SWITCHES_H_ -#define UI_AURA_SHELL_AURA_SHELL_SWITCHES_H_ -#pragma once - -#include "ui/aura_shell/aura_shell_export.h" - -namespace aura_shell { -namespace switches { - -// Please keep alphabetized. -AURA_SHELL_EXPORT extern const char kAuraNoShadows[]; -AURA_SHELL_EXPORT extern const char kAuraTranslucentFrames[]; -AURA_SHELL_EXPORT extern const char kAuraViewsAppList[]; -AURA_SHELL_EXPORT extern const char kAuraWindowMode[]; -AURA_SHELL_EXPORT extern const char kAuraWindowModeCompact[]; -AURA_SHELL_EXPORT extern const char kAuraWindowModeNormal[]; -AURA_SHELL_EXPORT extern const char kAuraWorkspaceManager[]; - -// Utilities for testing multi-valued switches. -AURA_SHELL_EXPORT bool IsAuraWindowModeCompact(); - -} // namespace switches -} // namespace aura_shell - -#endif // UI_AURA_SHELL_AURA_SHELL_SWITCHES_H_ diff --git a/ui/aura_shell/run_all_unittests.cc b/ui/aura_shell/run_all_unittests.cc deleted file mode 100644 index ad39e19..0000000 --- a/ui/aura_shell/run_all_unittests.cc +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2011 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 "ash/test/test_suite.h" - -int main(int argc, char** argv) { - return aura_shell::test::AuraShellTestSuite(argc, argv).Run(); -} diff --git a/ui/aura_shell/screenshot_delegate.h b/ui/aura_shell/screenshot_delegate.h deleted file mode 100644 index 9f6fe34..0000000 --- a/ui/aura_shell/screenshot_delegate.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_SCREENSHOT_DELEGATE_H_ -#define UI_AURA_SHELL_SCREENSHOT_DELEGATE_H_ -#pragma once - -namespace aura_shell { - -// Delegate for taking screenshots. -class ScreenshotDelegate { - public: - virtual ~ScreenshotDelegate() {} - - // The actual task of taking a screenshot. This method is called - // when the user wants to take a screenshot manually. - virtual void HandleTakeScreenshot() = 0; -}; -} // namespace aura_shell - -#endif // UI_AURA_SHELL_SCREENSHOT_DELEGATE_H_ diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc deleted file mode 100644 index 1d2edc3..0000000 --- a/ui/aura_shell/shell.cc +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright (c) 2011 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 "ui/aura_shell/shell.h" - -#include <algorithm> - -#include "ash/accelerators/accelerator_controller.h" -#include "ash/accelerators/accelerator_filter.h" -#include "ash/app_list/app_list.h" -#include "ash/drag_drop/drag_drop_controller.h" -#include "ash/launcher/launcher.h" -#include "ash/tooltips/tooltip_controller.h" -#include "ash/wm/activation_controller.h" -#include "ash/wm/compact_layout_manager.h" -#include "ash/wm/compact_status_area_layout_manager.h" -#include "ash/wm/default_container_event_filter.h" -#include "ash/wm/default_container_layout_manager.h" -#include "ash/wm/modal_container_layout_manager.h" -#include "ash/wm/root_window_event_filter.h" -#include "ash/wm/root_window_layout_manager.h" -#include "ash/wm/shadow_controller.h" -#include "ash/wm/shelf_layout_manager.h" -#include "ash/wm/stacking_controller.h" -#include "ash/wm/status_area_layout_manager.h" -#include "ash/wm/toplevel_layout_manager.h" -#include "ash/wm/toplevel_window_event_filter.h" -#include "ash/wm/workspace_controller.h" -#include "base/bind.h" -#include "base/command_line.h" -#include "ui/aura/root_window.h" -#include "ui/aura/layout_manager.h" -#include "ui/aura/window.h" -#include "ui/aura_shell/aura_shell_switches.h" -#include "ui/aura_shell/shell_delegate.h" -#include "ui/aura_shell/shell_factory.h" -#include "ui/aura_shell/shell_window_ids.h" -#include "ui/gfx/compositor/layer.h" -#include "ui/gfx/compositor/layer_animator.h" -#include "ui/gfx/screen.h" -#include "ui/gfx/size.h" -#include "ui/views/widget/native_widget_aura.h" -#include "ui/views/widget/widget.h" - -namespace aura_shell { - -namespace { - -using views::Widget; - -// Screen width at or below which we automatically start in compact window mode, -// in pixels. Should be at least 1366 pixels, the resolution of ChromeOS ZGB -// device displays, as we traditionally used a single window on those devices. -const int kCompactWindowModeWidthThreshold = 1366; - -// Creates each of the special window containers that holds windows of various -// types in the shell UI. They are added to |containers| from back to front in -// the z-index. -void CreateSpecialContainers(aura::Window::Windows* containers) { - aura::Window* background_container = new aura::Window(NULL); - background_container->set_id( - internal::kShellWindowId_DesktopBackgroundContainer); - containers->push_back(background_container); - - aura::Window* default_container = new aura::Window(NULL); - // Primary windows in compact mode don't allow drag, so don't use the filter. - if (!switches::IsAuraWindowModeCompact()) { - default_container->SetEventFilter( - new ToplevelWindowEventFilter(default_container)); - } - default_container->set_id(internal::kShellWindowId_DefaultContainer); - containers->push_back(default_container); - - aura::Window* always_on_top_container = new aura::Window(NULL); - always_on_top_container->SetEventFilter( - new ToplevelWindowEventFilter(always_on_top_container)); - always_on_top_container->set_id( - internal::kShellWindowId_AlwaysOnTopContainer); - containers->push_back(always_on_top_container); - - aura::Window* launcher_container = new aura::Window(NULL); - launcher_container->set_id(internal::kShellWindowId_LauncherContainer); - containers->push_back(launcher_container); - - aura::Window* modal_container = new aura::Window(NULL); - modal_container->SetEventFilter( - new ToplevelWindowEventFilter(modal_container)); - modal_container->SetLayoutManager( - new internal::ModalContainerLayoutManager(modal_container)); - modal_container->set_id(internal::kShellWindowId_ModalContainer); - containers->push_back(modal_container); - - // TODO(beng): Figure out if we can make this use ModalityEventFilter instead - // of stops_event_propagation. - aura::Window* lock_container = new aura::Window(NULL); - lock_container->set_stops_event_propagation(true); - lock_container->set_id(internal::kShellWindowId_LockScreenContainer); - containers->push_back(lock_container); - - aura::Window* lock_modal_container = new aura::Window(NULL); - lock_modal_container->SetEventFilter( - new ToplevelWindowEventFilter(lock_modal_container)); - lock_modal_container->SetLayoutManager( - new internal::ModalContainerLayoutManager(lock_modal_container)); - lock_modal_container->set_id(internal::kShellWindowId_LockModalContainer); - containers->push_back(lock_modal_container); - - aura::Window* status_container = new aura::Window(NULL); - status_container->set_id(internal::kShellWindowId_StatusContainer); - containers->push_back(status_container); - - aura::Window* menu_container = new aura::Window(NULL); - menu_container->set_id(internal::kShellWindowId_MenusAndTooltipsContainer); - containers->push_back(menu_container); -} - -} // namespace - -// static -Shell* Shell::instance_ = NULL; - -//////////////////////////////////////////////////////////////////////////////// -// Shell, public: - -Shell::Shell(ShellDelegate* delegate) - : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), - accelerator_controller_(new AcceleratorController), - delegate_(delegate) { - aura::RootWindow::GetInstance()->SetEventFilter( - new internal::RootWindowEventFilter); -} - -Shell::~Shell() { - RemoveRootWindowEventFilter(accelerator_filter_.get()); - - // TooltipController needs a valid shell instance. We delete it before - // deleting the shell |instance_|. - RemoveRootWindowEventFilter(tooltip_controller_.get()); - aura::client::SetTooltipClient(NULL); - - // Make sure we delete WorkspaceController before launcher is - // deleted as it has a reference to launcher model. - workspace_controller_.reset(); - launcher_.reset(); - - // Delete containers now so that child windows does not access - // observers when they are destructed. This has to be after launcher - // is destructed because launcher closes the widget in its destructor. - aura::RootWindow* root_window = aura::RootWindow::GetInstance(); - while (!root_window->children().empty()) { - aura::Window* child = root_window->children()[0]; - delete child; - } - - tooltip_controller_.reset(); - - // Drag drop controller needs a valid shell instance. We destroy it first. - drag_drop_controller_.reset(); - - DCHECK(instance_ == this); - instance_ = NULL; -} - -// static -Shell* Shell::CreateInstance(ShellDelegate* delegate) { - CHECK(!instance_); - instance_ = new Shell(delegate); - instance_->Init(); - return instance_; -} - -// static -Shell* Shell::GetInstance() { - DCHECK(instance_); - return instance_; -} - -// static -void Shell::DeleteInstance() { - delete instance_; - instance_ = NULL; -} - -void Shell::Init() { - // On small screens we automatically enable --aura-window-mode=compact if the - // user has not explicitly set a window mode flag. This must happen before - // we create containers or layout managers. - gfx::Size monitor_size = gfx::Screen::GetPrimaryMonitorSize(); - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (DefaultToCompactWindowMode(monitor_size, command_line)) { - command_line->AppendSwitchASCII(switches::kAuraWindowMode, - switches::kAuraWindowModeCompact); - } - - aura::RootWindow* root_window = aura::RootWindow::GetInstance(); - root_window->SetCursor(aura::kCursorPointer); - - activation_controller_.reset(new internal::ActivationController); - - aura::Window::Windows containers; - CreateSpecialContainers(&containers); - aura::Window::Windows::const_iterator i; - for (i = containers.begin(); i != containers.end(); ++i) { - (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); - root_window->AddChild(*i); - (*i)->Show(); - } - - stacking_controller_.reset(new internal::StackingController); - - InitLayoutManagers(root_window); - - if (!command_line->HasSwitch(switches::kAuraNoShadows)) - shadow_controller_.reset(new internal::ShadowController()); - - // Force a layout. - root_window->layout_manager()->OnWindowResized(); - - // Initialize AcceleratorFilter. - accelerator_filter_.reset(new internal::AcceleratorFilter); - AddRootWindowEventFilter(accelerator_filter_.get()); - - // Initialize TooltipController. - tooltip_controller_.reset(new internal::TooltipController); - AddRootWindowEventFilter(tooltip_controller_.get()); - aura::client::SetTooltipClient(tooltip_controller_.get()); - - // Initialize drag drop controller. - drag_drop_controller_.reset(new internal::DragDropController); -} - -bool Shell::DefaultToCompactWindowMode(const gfx::Size& monitor_size, - CommandLine* command_line) const { - // Developers often run the Aura shell in a window on their desktop. - // Don't mess with their window mode. - if (!aura::RootWindow::use_fullscreen_host_window()) - return false; - - // If user set the flag, don't override their desired behavior. - if (command_line->HasSwitch(switches::kAuraWindowMode)) - return false; - - // If the screen is wide enough, we prefer multiple draggable windows. - // We explicitly don't care about height, since users don't generally stack - // browser windows vertically. - if (monitor_size.width() > kCompactWindowModeWidthThreshold) - return false; - - return true; -} - -void Shell::InitLayoutManagers(aura::RootWindow* root_window) { - internal::RootWindowLayoutManager* root_window_layout = - new internal::RootWindowLayoutManager(root_window); - root_window->SetLayoutManager(root_window_layout); - - views::Widget* status_widget = NULL; - if (delegate_.get()) - status_widget = delegate_->CreateStatusArea(); - if (!status_widget) - status_widget = internal::CreateStatusArea(); - - aura::Window* default_container = - GetContainer(internal::kShellWindowId_DefaultContainer); - - // Compact mode has a simplified layout manager and doesn't use the launcher, - // desktop background, shelf, etc. - if (switches::IsAuraWindowModeCompact()) { - default_container->SetLayoutManager( - new internal::CompactLayoutManager(status_widget)); - internal::CompactStatusAreaLayoutManager* status_area_layout_manager = - new internal::CompactStatusAreaLayoutManager(status_widget); - GetContainer(internal::kShellWindowId_StatusContainer)-> - SetLayoutManager(status_area_layout_manager); - return; - } - - root_window_layout->set_background_widget( - internal::CreateDesktopBackground()); - launcher_.reset(new Launcher(default_container)); - - internal::ShelfLayoutManager* shelf_layout_manager = - new internal::ShelfLayoutManager(launcher_->widget(), status_widget); - GetContainer(internal::kShellWindowId_LauncherContainer)-> - SetLayoutManager(shelf_layout_manager); - - internal::StatusAreaLayoutManager* status_area_layout_manager = - new internal::StatusAreaLayoutManager(shelf_layout_manager); - GetContainer(internal::kShellWindowId_StatusContainer)-> - SetLayoutManager(status_area_layout_manager); - - // Workspace manager has its own layout managers. - if (CommandLine::ForCurrentProcess()-> - HasSwitch(switches::kAuraWorkspaceManager)) { - EnableWorkspaceManager(); - return; - } - - // Default layout manager. - internal::ToplevelLayoutManager* toplevel_layout_manager = - new internal::ToplevelLayoutManager(); - default_container->SetLayoutManager(toplevel_layout_manager); - toplevel_layout_manager->set_shelf(shelf_layout_manager); -} - -aura::Window* Shell::GetContainer(int container_id) { - return const_cast<aura::Window*>( - const_cast<const Shell*>(this)->GetContainer(container_id)); -} - -const aura::Window* Shell::GetContainer(int container_id) const { - return aura::RootWindow::GetInstance()->GetChildById(container_id); -} - -void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { - static_cast<internal::RootWindowEventFilter*>( - aura::RootWindow::GetInstance()->event_filter())->AddFilter(filter); -} - -void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { - static_cast<internal::RootWindowEventFilter*>( - aura::RootWindow::GetInstance()->event_filter())->RemoveFilter(filter); -} - -void Shell::ToggleOverview() { - if (workspace_controller_.get()) - workspace_controller_->ToggleOverview(); -} - -void Shell::ToggleAppList() { - if (!app_list_.get()) - app_list_.reset(new internal::AppList); - app_list_->SetVisible(!app_list_->IsVisible()); -} - -// Returns true if the screen is locked. -bool Shell::IsScreenLocked() const { - const aura::Window* lock_screen_container = GetContainer( - internal::kShellWindowId_LockScreenContainer); - const aura::Window::Windows& lock_screen_windows = - lock_screen_container->children(); - aura::Window::Windows::const_iterator lock_screen_it = - std::find_if(lock_screen_windows.begin(), lock_screen_windows.end(), - std::mem_fun(&aura::Window::IsVisible)); - if (lock_screen_it != lock_screen_windows.end()) - return true; - - return false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Shell, private: - -void Shell::EnableWorkspaceManager() { - aura::Window* default_container = - GetContainer(internal::kShellWindowId_DefaultContainer); - - workspace_controller_.reset( - new internal::WorkspaceController(default_container)); - workspace_controller_->SetLauncherModel(launcher_->model()); - default_container->SetEventFilter( - new internal::DefaultContainerEventFilter(default_container)); - default_container->SetLayoutManager( - new internal::DefaultContainerLayoutManager( - workspace_controller_->workspace_manager())); -} - -} // namespace aura_shell diff --git a/ui/aura_shell/shell.h b/ui/aura_shell/shell.h deleted file mode 100644 index 439392b..0000000 --- a/ui/aura_shell/shell.h +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_SHELL_H_ -#define UI_AURA_SHELL_SHELL_H_ -#pragma once - -#include <utility> -#include <vector> - -#include "base/basictypes.h" -#include "base/gtest_prod_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/task.h" -#include "base/compiler_specific.h" -#include "base/memory/weak_ptr.h" -#include "ui/aura_shell/aura_shell_export.h" - -class CommandLine; - -namespace aura { -class EventFilter; -class RootWindow; -class Window; -} -namespace gfx { -class Rect; -class Size; -} - -namespace aura_shell { - -class AcceleratorController; -class Launcher; -class ShellDelegate; - -namespace internal { -class ActivationController; -class AcceleratorFilter; -class AppList; -class DragDropController; -class ShadowController; -class StackingController; -class TooltipController; -class WorkspaceController; -} - -// Shell is a singleton object that presents the Shell API and implements the -// RootWindow's delegate interface. -class AURA_SHELL_EXPORT Shell { - public: - // Upon creation, the Shell sets itself as the RootWindow's delegate, which - // takes ownership of the Shell. - - // A shell must be explicitly created so that it can call |Init()| with the - // delegate set. |delegate| can be NULL (if not required for initialization). - static Shell* CreateInstance(ShellDelegate* delegate); - - // Should never be called before |CreateInstance()|. - static Shell* GetInstance(); - - static void DeleteInstance(); - - aura::Window* GetContainer(int container_id); - const aura::Window* GetContainer(int container_id) const; - - // Adds or removes |filter| from the RootWindowEventFilter. - void AddRootWindowEventFilter(aura::EventFilter* filter); - void RemoveRootWindowEventFilter(aura::EventFilter* filter); - - // Toggles between overview mode and normal mode. - void ToggleOverview(); - - // Toggles app list. - void ToggleAppList(); - - // Returns true if the screen is locked. - bool IsScreenLocked() const; - - AcceleratorController* accelerator_controller() { - return accelerator_controller_.get(); - } - - internal::TooltipController* tooltip_controller() { - return tooltip_controller_.get(); - } - - ShellDelegate* delegate() { return delegate_.get(); } - - // May return NULL if we're not using a launcher (e.g. laptop-mode). - Launcher* launcher() { return launcher_.get(); } - - // Made available for tests. - internal::ShadowController* shadow_controller() { - return shadow_controller_.get(); - } - - private: - FRIEND_TEST_ALL_PREFIXES(ShellTest, DefaultToCompactWindowMode); - - typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; - - explicit Shell(ShellDelegate* delegate); - virtual ~Shell(); - - void Init(); - - // Returns true if the |monitor_size| is narrow and the user has not set - // an explicit window mode flag on the |command_line|. - bool DefaultToCompactWindowMode(const gfx::Size& monitor_size, - CommandLine* command_line) const; - - void InitLayoutManagers(aura::RootWindow* root_window); - - // Enables WorkspaceManager. - void EnableWorkspaceManager(); - - static Shell* instance_; - - std::vector<WindowAndBoundsPair> to_restore_; - - base::WeakPtrFactory<Shell> method_factory_; - - scoped_ptr<AcceleratorController> accelerator_controller_; - - scoped_ptr<ShellDelegate> delegate_; - - scoped_ptr<Launcher> launcher_; - - scoped_ptr<internal::AppList> app_list_; - - scoped_ptr<internal::StackingController> stacking_controller_; - scoped_ptr<internal::ActivationController> activation_controller_; - scoped_ptr<internal::DragDropController> drag_drop_controller_; - scoped_ptr<internal::WorkspaceController> workspace_controller_; - scoped_ptr<internal::ShadowController> shadow_controller_; - scoped_ptr<internal::TooltipController> tooltip_controller_; - - // An event filter that pre-handles global accelerators. - scoped_ptr<internal::AcceleratorFilter> accelerator_filter_; - - - DISALLOW_COPY_AND_ASSIGN(Shell); -}; - -} // namespace aura_shell - -#endif // UI_AURA_SHELL_SHELL_H_ diff --git a/ui/aura_shell/shell_delegate.h b/ui/aura_shell/shell_delegate.h deleted file mode 100644 index 7912919..0000000 --- a/ui/aura_shell/shell_delegate.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_SHELL_DELEGATE_H_ -#define UI_AURA_SHELL_SHELL_DELEGATE_H_ -#pragma once - -#include "base/callback.h" -#include "ui/aura_shell/aura_shell_export.h" - -namespace gfx { -class Rect; -} - -namespace views { -class Widget; -} - -namespace aura_shell { - -class AppListModel; -class AppListViewDelegate; -struct LauncherItem; - -// Delegate of the Shell. -class AURA_SHELL_EXPORT ShellDelegate { - public: - // Callback to pass back a widget used by RequestAppListWidget. - typedef base::Callback<void(views::Widget*)> SetWidgetCallback; - - // The Shell owns the delegate. - virtual ~ShellDelegate() {} - - // Invoked when the user clicks on button in the launcher to create a new - // window. - virtual void CreateNewWindow() = 0; - - // Invoked to create a new status area. Can return NULL. - virtual views::Widget* CreateStatusArea() = 0; - - // Invoked to create app list widget. The Delegate calls the callback - // when the widget is ready to show. - // Deprecated. - // TODO(xiyuan): Clean this up when switching to views app list. - virtual void RequestAppListWidget( - const gfx::Rect& bounds, - const SetWidgetCallback& callback) = 0; - - // Invoked to ask the delegate to populate the |model|. - virtual void BuildAppListModel(AppListModel* model) = 0; - - // Invoked to create an AppListViewDelegate. Shell takes the ownership of - // the created delegate. - virtual AppListViewDelegate* CreateAppListViewDelegate() = 0; - - // Invoked when the user clicks on a window entry in the launcher. - virtual void LauncherItemClicked(const LauncherItem& item) = 0; - - // Invoked when a window is added. If the delegate wants the launcher to show - // an entry for |item->window| it should configure |item| appropriately and - // return true. - virtual bool ConfigureLauncherItem(LauncherItem* item) = 0; -}; -} // namespace aura_shell - -#endif // UI_AURA_SHELL_SHELL_DELEGATE_H_ diff --git a/ui/aura_shell/shell_factory.h b/ui/aura_shell/shell_factory.h deleted file mode 100644 index 58da655..0000000 --- a/ui/aura_shell/shell_factory.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_SHELL_FACTORY_H_ -#define UI_AURA_SHELL_SHELL_FACTORY_H_ -#pragma once - -#include "ui/aura_shell/aura_shell_export.h" - -namespace views { -class Widget; -} - -// Declarations of shell component factory functions. - -namespace aura_shell { - -namespace internal { -views::Widget* CreateDesktopBackground(); -AURA_SHELL_EXPORT views::Widget* CreateStatusArea(); -} // namespace internal - -} // namespace aura_shell - - -#endif // UI_AURA_SHELL_SHELL_FACTORY_H_ diff --git a/ui/aura_shell/shell_unittest.cc b/ui/aura_shell/shell_unittest.cc deleted file mode 100644 index 6a8c0e2..0000000 --- a/ui/aura_shell/shell_unittest.cc +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) 2011 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 "ash/test/aura_shell_test_base.h" -#include "base/command_line.h" -#include "base/utf_string_conversions.h" -#include "ui/aura/test/aura_test_base.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/aura_shell/aura_shell_switches.h" -#include "ui/aura_shell/shell.h" -#include "ui/aura_shell/shell_window_ids.h" -#include "ui/gfx/size.h" -#include "ui/views/widget/widget.h" -#include "ui/views/widget/widget_delegate.h" - -namespace aura_shell { - -namespace { - -views::Widget* CreateTestWindow(const views::Widget::InitParams& params) { - views::Widget* widget = new views::Widget; - widget->Init(params); - return widget; -} - -aura::Window* GetDefaultContainer() { - return Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_DefaultContainer); -} - -aura::Window* GetAlwaysOnTopContainer() { - return Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_AlwaysOnTopContainer); -} - -void TestCreateWindow(views::Widget::InitParams::Type type, - bool always_on_top, - aura::Window* expected_container) { - views::Widget::InitParams widget_params(type); - widget_params.keep_on_top = always_on_top; - - views::Widget* widget = CreateTestWindow(widget_params); - widget->Show(); - - EXPECT_EQ(expected_container, widget->GetNativeWindow()->parent()) << - "TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top; - - widget->Close(); -} - -class ModalWindow : public views::WidgetDelegateView { - public: - ModalWindow() {} - virtual ~ModalWindow() {} - - // Overridden from views::WidgetDelegate: - virtual views::View* GetContentsView() OVERRIDE { - return this; - } - virtual bool CanResize() const OVERRIDE { - return true; - } - virtual string16 GetWindowTitle() const OVERRIDE { - return ASCIIToUTF16("Modal Window"); - } - virtual bool IsModal() const OVERRIDE { - return true; - } - - private: - DISALLOW_COPY_AND_ASSIGN(ModalWindow); -}; - -// After base::AutoReset<> but via setter and getter. -class AutoResetUseFullscreenHostWindow { - public: - AutoResetUseFullscreenHostWindow(bool new_value) { - old_value_ = aura::RootWindow::use_fullscreen_host_window(); - aura::RootWindow::set_use_fullscreen_host_window(new_value); - } - ~AutoResetUseFullscreenHostWindow() { - aura::RootWindow::set_use_fullscreen_host_window(old_value_); - } - private: - bool old_value_; -}; - -} // namespace - -class ShellTest : public test::AuraShellTestBase { - public: - ShellTest() {} - virtual ~ShellTest() {} - - private: - DISALLOW_COPY_AND_ASSIGN(ShellTest); -}; - -TEST_F(ShellTest, CreateWindow) { - // Normal window should be created in default container. - TestCreateWindow(views::Widget::InitParams::TYPE_WINDOW, - false, // always_on_top - GetDefaultContainer()); - TestCreateWindow(views::Widget::InitParams::TYPE_POPUP, - false, // always_on_top - GetDefaultContainer()); - - // Always-on-top window and popup are created in always-on-top container. - TestCreateWindow(views::Widget::InitParams::TYPE_WINDOW, - true, // always_on_top - GetAlwaysOnTopContainer()); - TestCreateWindow(views::Widget::InitParams::TYPE_POPUP, - true, // always_on_top - GetAlwaysOnTopContainer()); -} - -TEST_F(ShellTest, ChangeAlwaysOnTop) { - views::Widget::InitParams widget_params( - views::Widget::InitParams::TYPE_WINDOW); - - // Creates a normal window - views::Widget* widget = CreateTestWindow(widget_params); - widget->Show(); - - // It should be in default container. - EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); - - // Flip always-on-top flag. - widget->SetAlwaysOnTop(true); - // And it should in always on top container now. - EXPECT_EQ(GetAlwaysOnTopContainer(), widget->GetNativeWindow()->parent()); - - // Flip always-on-top flag. - widget->SetAlwaysOnTop(false); - // It should go back to default container. - EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); - - // Set the same always-on-top flag again. - widget->SetAlwaysOnTop(false); - // Should have no effect and we are still in the default container. - EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); - - widget->Close(); -} - -TEST_F(ShellTest, CreateModalWindow) { - views::Widget::InitParams widget_params( - views::Widget::InitParams::TYPE_WINDOW); - - // Create a normal window. - views::Widget* widget = CreateTestWindow(widget_params); - widget->Show(); - - // It should be in default container. - EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); - - // Create a modal window. - views::Widget* modal_widget = views::Widget::CreateWindowWithParent( - new ModalWindow(), widget->GetNativeView()); - modal_widget->Show(); - - // It should be in modal container. - aura::Window* modal_container = Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_ModalContainer); - EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); - - modal_widget->Close(); - widget->Close(); -} - -TEST_F(ShellTest, CreateLockScreenModalWindow) { - views::Widget::InitParams widget_params( - views::Widget::InitParams::TYPE_WINDOW); - - // Create a normal window. - views::Widget* widget = CreateTestWindow(widget_params); - widget->Show(); - - // It should be in default container. - EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); - - // Create a LockScreen window. - views::Widget* lock_widget = CreateTestWindow(widget_params); - aura_shell::Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_LockScreenContainer)-> - AddChild(lock_widget->GetNativeView()); - lock_widget->Show(); - - // It should be in LockScreen container. - aura::Window* lock_screen = Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_LockScreenContainer); - EXPECT_EQ(lock_screen, lock_widget->GetNativeWindow()->parent()); - - // Create a modal window with a lock window as parent. - views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent( - new ModalWindow(), lock_widget->GetNativeView()); - lock_modal_widget->Show(); - - // It should be in LockScreen modal container. - aura::Window* lock_modal_container = Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_LockModalContainer); - EXPECT_EQ(lock_modal_container, - lock_modal_widget->GetNativeWindow()->parent()); - - // Create a modal window with a normal window as parent. - views::Widget* modal_widget = views::Widget::CreateWindowWithParent( - new ModalWindow(), widget->GetNativeView()); - modal_widget->Show(); - - // It should be in non-LockScreen modal container. - aura::Window* modal_container = Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_ModalContainer); - EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); - - modal_widget->Close(); - lock_modal_widget->Close(); - lock_widget->Close(); - widget->Close(); -} - -TEST_F(ShellTest, IsScreenLocked) { - views::Widget::InitParams widget_params( - views::Widget::InitParams::TYPE_WINDOW); - - // A normal window does not lock the screen. - views::Widget* widget = CreateTestWindow(widget_params); - widget->Show(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); - widget->Hide(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); - - // A modal window with a normal window as parent does not locks the screen. - views::Widget* modal_widget = views::Widget::CreateWindowWithParent( - new ModalWindow(), widget->GetNativeView()); - modal_widget->Show(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); - modal_widget->Close(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); - widget->Close(); - - // A lock screen window locks the screen. - views::Widget* lock_widget = CreateTestWindow(widget_params); - aura_shell::Shell::GetInstance()->GetContainer( - aura_shell::internal::kShellWindowId_LockScreenContainer)-> - AddChild(lock_widget->GetNativeView()); - lock_widget->Show(); - EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); - lock_widget->Hide(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); - - // A modal window with a lock window as parent does not lock the screen. The - // screen is locked only when a lock windown is visible. - views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent( - new ModalWindow(), lock_widget->GetNativeView()); - lock_modal_widget->Show(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); - lock_widget->Show(); - EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); - lock_modal_widget->Close(); - EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); - lock_widget->Close(); - EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); -} - -TEST_F(ShellTest, DefaultToCompactWindowMode) { - // We only change default window mode with full-screen host windows. - AutoResetUseFullscreenHostWindow use_fullscreen_host_window(true); - - // Wide screens use normal window mode. - Shell* shell = Shell::GetInstance(); - gfx::Size monitor_size(1440, 900); - CommandLine command_line(CommandLine::NO_PROGRAM); - EXPECT_FALSE(shell->DefaultToCompactWindowMode(monitor_size, &command_line)); - - // Alex-sized screens need compact mode. - monitor_size.SetSize(1280, 800); - EXPECT_TRUE(shell->DefaultToCompactWindowMode(monitor_size, &command_line)); - - // ZGB-sized screens need compact mode. - monitor_size.SetSize(1366, 768); - EXPECT_TRUE(shell->DefaultToCompactWindowMode(monitor_size, &command_line)); - - // Even for a small screen, the user can force normal mode. - monitor_size.SetSize(800, 600); - command_line.AppendSwitchASCII(aura_shell::switches::kAuraWindowMode, - aura_shell::switches::kAuraWindowModeNormal); - EXPECT_FALSE(shell->DefaultToCompactWindowMode(monitor_size, &command_line)); -} - -} // namespace aura_shell diff --git a/ui/aura_shell/shell_window_ids.h b/ui/aura_shell/shell_window_ids.h deleted file mode 100644 index a17b6fc..0000000 --- a/ui/aura_shell/shell_window_ids.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2011 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 UI_AURA_SHELL_SHELL_WINDOW_IDS_H_ -#define UI_AURA_SHELL_SHELL_WINDOW_IDS_H_ -#pragma once - -// Declarations of ids of special shell windows. - -namespace aura_shell { - -namespace internal { - -// The desktop background window. -const int kShellWindowId_DesktopBackgroundContainer = 0; - -// The container for standard top-level windows. -const int kShellWindowId_DefaultContainer = 1; - -// The container for top-level windows with the 'always-on-top' flag set. -const int kShellWindowId_AlwaysOnTopContainer = 2; - -// The container for the launcher. -const int kShellWindowId_LauncherContainer = 3; - -// The container for user-specific modal windows. -const int kShellWindowId_ModalContainer = 4; - -// The container for the lock screen. -const int kShellWindowId_LockScreenContainer = 5; - -// The container for the lock screen modal windows. -const int kShellWindowId_LockModalContainer = 6; - -// The container for the status area. -const int kShellWindowId_StatusContainer = 7; - -// The container for menus and tooltips. -const int kShellWindowId_MenusAndTooltipsContainer = 8; - -} // namespace internal - -} // namespace aura_shell - - -#endif // UI_AURA_SHELL_SHELL_WINDOW_IDS_H_ |