| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
| 6 #define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 6 #define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "extensions/shell/browser/desktop_controller.h" |
| 11 #include "ui/aura/client/window_tree_client.h" | 12 #include "ui/aura/client/window_tree_client.h" |
| 12 #include "ui/aura/window_tree_host_observer.h" | 13 #include "ui/aura/window_tree_host_observer.h" |
| 13 | 14 |
| 14 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
| 15 #include "ui/display/chromeos/display_configurator.h" | 16 #include "ui/display/chromeos/display_configurator.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace aura { | 19 namespace aura { |
| 19 class TestScreen; | 20 class TestScreen; |
| 20 class Window; | 21 class Window; |
| 21 class WindowTreeHost; | 22 class WindowTreeHost; |
| 22 namespace client { | 23 namespace client { |
| 23 class DefaultCaptureClient; | 24 class DefaultCaptureClient; |
| 24 class FocusClient; | 25 class FocusClient; |
| 25 } | 26 } |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 class BrowserContext; | 30 class BrowserContext; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace gfx { | 33 namespace gfx { |
| 33 class Insets; | |
| 34 class Size; | 34 class Size; |
| 35 } | 35 } |
| 36 | 36 |
| 37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 38 namespace ui { | 38 namespace ui { |
| 39 class UserActivityPowerManagerNotifier; | 39 class UserActivityPowerManagerNotifier; |
| 40 } | 40 } |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 namespace wm { | 43 namespace wm { |
| 44 class CompoundEventFilter; | 44 class CompoundEventFilter; |
| 45 class CursorManager; | 45 class CursorManager; |
| 46 class FocusRules; | |
| 47 class InputMethodEventFilter; | 46 class InputMethodEventFilter; |
| 48 class UserActivityDetector; | 47 class UserActivityDetector; |
| 49 } | 48 } |
| 50 | 49 |
| 51 namespace extensions { | 50 namespace extensions { |
| 52 | 51 |
| 53 class ShellAppWindow; | 52 class ShellAppWindow; |
| 54 class ShellAppWindowController; | 53 class ShellAppWindowController; |
| 55 | 54 |
| 56 // Handles desktop-related tasks for app_shell. | 55 // Handles desktop-related tasks for app_shell. |
| 57 class ShellDesktopController : public aura::client::WindowTreeClient, | 56 class ShellDesktopController : public DesktopController, |
| 57 public aura::client::WindowTreeClient, |
| 58 public aura::WindowTreeHostObserver | 58 public aura::WindowTreeHostObserver |
| 59 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 60 , | 60 , |
| 61 public ui::DisplayConfigurator::Observer | 61 public ui::DisplayConfigurator::Observer |
| 62 #endif | 62 #endif |
| 63 { | 63 { |
| 64 public: | 64 public: |
| 65 ShellDesktopController(); | 65 ShellDesktopController(); |
| 66 virtual ~ShellDesktopController(); | 66 virtual ~ShellDesktopController(); |
| 67 | 67 |
| 68 // Returns the single instance of the desktop. (Stateless functions like | 68 // DeskopController: |
| 69 // ShellAppWindowCreateFunction need to be able to access the desktop, so | 69 virtual aura::WindowTreeHost* GetHost() OVERRIDE; |
| 70 // we need a singleton somewhere). | 70 virtual void CreateRootWindow() OVERRIDE; |
| 71 static ShellDesktopController* instance(); | 71 virtual ShellAppWindow* CreateAppWindow( |
| 72 | 72 content::BrowserContext* context) OVERRIDE; |
| 73 aura::WindowTreeHost* host() { return host_.get(); } | 73 virtual void CloseAppWindows() OVERRIDE; |
| 74 | |
| 75 // Creates the window that hosts the app. | |
| 76 void CreateRootWindow(); | |
| 77 | |
| 78 // Sets the controller to create/close the app windows. Takes the ownership of | |
| 79 // |app_window_controller|. | |
| 80 void SetAppWindowController(ShellAppWindowController* app_window_controller); | |
| 81 | |
| 82 // Creates a new app window and adds it to the desktop. The desktop maintains | |
| 83 // ownership of the window. | |
| 84 ShellAppWindow* CreateAppWindow(content::BrowserContext* context); | |
| 85 | |
| 86 // Closes and destroys the app windows. | |
| 87 void CloseAppWindows(); | |
| 88 | |
| 89 // Sets the screen's work area insets. | |
| 90 void SetDisplayWorkAreaInsets(const gfx::Insets& insets); | |
| 91 | 74 |
| 92 // Overridden from aura::client::WindowTreeClient: | 75 // Overridden from aura::client::WindowTreeClient: |
| 93 virtual aura::Window* GetDefaultParent(aura::Window* context, | 76 virtual aura::Window* GetDefaultParent(aura::Window* context, |
| 94 aura::Window* window, | 77 aura::Window* window, |
| 95 const gfx::Rect& bounds) OVERRIDE; | 78 const gfx::Rect& bounds) OVERRIDE; |
| 96 | 79 |
| 97 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
| 98 // ui::DisplayConfigurator::Observer overrides. | 81 // ui::DisplayConfigurator::Observer overrides. |
| 99 virtual void OnDisplayModeChanged(const std::vector< | 82 virtual void OnDisplayModeChanged(const std::vector< |
| 100 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; | 83 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; |
| 101 #endif | 84 #endif |
| 102 | 85 |
| 103 // aura::WindowTreeHostObserver overrides: | 86 // aura::WindowTreeHostObserver overrides: |
| 104 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; | 87 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; |
| 105 | 88 |
| 106 protected: | 89 protected: |
| 107 // Creates and sets the aura clients and window manager stuff. Subclass may | 90 // Creates and sets the aura clients and window manager stuff. Subclass may |
| 108 // initialize different sets of the clients. | 91 // initialize different sets of the clients. |
| 109 virtual void InitWindowManager(); | 92 virtual void InitWindowManager(); |
| 110 | 93 |
| 111 // Creates a focus rule that is to be used in the InitWindowManager. | |
| 112 virtual wm::FocusRules* CreateFocusRules(); | |
| 113 | |
| 114 private: | 94 private: |
| 115 // Closes and destroys the root window hosting the app. | 95 // Closes and destroys the root window hosting the app. |
| 116 void DestroyRootWindow(); | 96 void DestroyRootWindow(); |
| 117 | 97 |
| 118 // Returns the dimensions (in pixels) of the primary display, or an empty size | 98 // Returns the dimensions (in pixels) of the primary display, or an empty size |
| 119 // if the dimensions can't be determined or no display is connected. | 99 // if the dimensions can't be determined or no display is connected. |
| 120 gfx::Size GetPrimaryDisplaySize(); | 100 gfx::Size GetPrimaryDisplaySize(); |
| 121 | 101 |
| 122 #if defined(OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
| 123 scoped_ptr<ui::DisplayConfigurator> display_configurator_; | 103 scoped_ptr<ui::DisplayConfigurator> display_configurator_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 136 scoped_ptr<aura::client::FocusClient> focus_client_; | 116 scoped_ptr<aura::client::FocusClient> focus_client_; |
| 137 | 117 |
| 138 scoped_ptr<wm::CursorManager> cursor_manager_; | 118 scoped_ptr<wm::CursorManager> cursor_manager_; |
| 139 | 119 |
| 140 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; | 120 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; |
| 141 #if defined(OS_CHROMEOS) | 121 #if defined(OS_CHROMEOS) |
| 142 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; | 122 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; |
| 143 #endif | 123 #endif |
| 144 | 124 |
| 145 // The desktop supports a single app window. | 125 // The desktop supports a single app window. |
| 146 scoped_ptr<ShellAppWindowController> app_window_controller_; | 126 scoped_ptr<ShellAppWindow> app_window_; |
| 147 | 127 |
| 148 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); | 128 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); |
| 149 }; | 129 }; |
| 150 | 130 |
| 151 } // namespace extensions | 131 } // namespace extensions |
| 152 | 132 |
| 153 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 133 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
| OLD | NEW |