| 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 "ui/aura/client/window_tree_client.h" | 11 #include "ui/aura/client/window_tree_client.h" |
| 12 #include "ui/aura/window_tree_host_observer.h" | 12 #include "ui/aura/window_tree_host_observer.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "chromeos/dbus/power_manager_client.h" |
| 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; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 48 class UserActivityDetector; | 49 class UserActivityDetector; |
| 49 } | 50 } |
| 50 | 51 |
| 51 namespace extensions { | 52 namespace extensions { |
| 52 | 53 |
| 53 class ShellAppWindow; | 54 class ShellAppWindow; |
| 54 class ShellAppWindowController; | 55 class ShellAppWindowController; |
| 55 | 56 |
| 56 // Handles desktop-related tasks for app_shell. | 57 // Handles desktop-related tasks for app_shell. |
| 57 class ShellDesktopController : public aura::client::WindowTreeClient, | 58 class ShellDesktopController : public aura::client::WindowTreeClient, |
| 58 public aura::WindowTreeHostObserver | |
| 59 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 60 , | 60 public chromeos::PowerManagerClient::Observer, |
| 61 public ui::DisplayConfigurator::Observer | 61 public ui::DisplayConfigurator::Observer, |
| 62 #endif | 62 #endif |
| 63 { | 63 public aura::WindowTreeHostObserver { |
| 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 // Returns the single instance of the desktop. (Stateless functions like |
| 69 // ShellAppWindowCreateFunction need to be able to access the desktop, so | 69 // ShellAppWindowCreateFunction need to be able to access the desktop, so |
| 70 // we need a singleton somewhere). | 70 // we need a singleton somewhere). |
| 71 static ShellDesktopController* instance(); | 71 static ShellDesktopController* instance(); |
| 72 | 72 |
| 73 aura::WindowTreeHost* host() { return host_.get(); } | 73 aura::WindowTreeHost* host() { return host_.get(); } |
| 74 | 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 | 75 // Sets the controller to create/close the app windows. Takes the ownership of |
| 79 // |app_window_controller|. | 76 // |app_window_controller|. |
| 80 void SetAppWindowController(ShellAppWindowController* app_window_controller); | 77 void SetAppWindowController(ShellAppWindowController* app_window_controller); |
| 81 | 78 |
| 82 // Creates a new app window and adds it to the desktop. The desktop maintains | 79 // Creates a new app window and adds it to the desktop. The desktop maintains |
| 83 // ownership of the window. | 80 // ownership of the window. |
| 84 ShellAppWindow* CreateAppWindow(content::BrowserContext* context); | 81 ShellAppWindow* CreateAppWindow(content::BrowserContext* context); |
| 85 | 82 |
| 86 // Closes and destroys the app windows. | 83 // Closes and destroys the app windows. |
| 87 void CloseAppWindows(); | 84 void CloseAppWindows(); |
| 88 | 85 |
| 89 // Sets the screen's work area insets. | 86 // Sets the screen's work area insets. |
| 90 void SetDisplayWorkAreaInsets(const gfx::Insets& insets); | 87 void SetDisplayWorkAreaInsets(const gfx::Insets& insets); |
| 91 | 88 |
| 92 // Overridden from aura::client::WindowTreeClient: | 89 // aura::client::WindowTreeClient overrides: |
| 93 virtual aura::Window* GetDefaultParent(aura::Window* context, | 90 virtual aura::Window* GetDefaultParent(aura::Window* context, |
| 94 aura::Window* window, | 91 aura::Window* window, |
| 95 const gfx::Rect& bounds) OVERRIDE; | 92 const gfx::Rect& bounds) OVERRIDE; |
| 96 | 93 |
| 97 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
| 95 // chromeos::PowerManagerClient::Observer overrides: |
| 96 virtual void PowerButtonEventReceived(bool down, |
| 97 const base::TimeTicks& timestamp) |
| 98 OVERRIDE; |
| 99 |
| 98 // ui::DisplayConfigurator::Observer overrides. | 100 // ui::DisplayConfigurator::Observer overrides. |
| 99 virtual void OnDisplayModeChanged(const std::vector< | 101 virtual void OnDisplayModeChanged(const std::vector< |
| 100 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; | 102 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; |
| 101 #endif | 103 #endif |
| 102 | 104 |
| 103 // aura::WindowTreeHostObserver overrides: | 105 // aura::WindowTreeHostObserver overrides: |
| 104 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; | 106 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; |
| 105 | 107 |
| 106 protected: | 108 protected: |
| 107 // Creates and sets the aura clients and window manager stuff. Subclass may | 109 // Creates and sets the aura clients and window manager stuff. Subclass may |
| 108 // initialize different sets of the clients. | 110 // initialize different sets of the clients. |
| 109 virtual void InitWindowManager(); | 111 virtual void InitWindowManager(); |
| 110 | 112 |
| 111 // Creates a focus rule that is to be used in the InitWindowManager. | 113 // Creates a focus rule that is to be used in the InitWindowManager. |
| 112 virtual wm::FocusRules* CreateFocusRules(); | 114 virtual wm::FocusRules* CreateFocusRules(); |
| 113 | 115 |
| 114 private: | 116 private: |
| 117 // Creates the window that hosts the app. |
| 118 void CreateRootWindow(); |
| 119 |
| 115 // Closes and destroys the root window hosting the app. | 120 // Closes and destroys the root window hosting the app. |
| 116 void DestroyRootWindow(); | 121 void DestroyRootWindow(); |
| 117 | 122 |
| 118 // Returns the dimensions (in pixels) of the primary display, or an empty size | 123 // 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. | 124 // if the dimensions can't be determined or no display is connected. |
| 120 gfx::Size GetPrimaryDisplaySize(); | 125 gfx::Size GetPrimaryDisplaySize(); |
| 121 | 126 |
| 122 #if defined(OS_CHROMEOS) | 127 #if defined(OS_CHROMEOS) |
| 123 scoped_ptr<ui::DisplayConfigurator> display_configurator_; | 128 scoped_ptr<ui::DisplayConfigurator> display_configurator_; |
| 124 #endif | 129 #endif |
| (...skipping 19 matching lines...) Expand all Loading... |
| 144 | 149 |
| 145 // The desktop supports a single app window. | 150 // The desktop supports a single app window. |
| 146 scoped_ptr<ShellAppWindowController> app_window_controller_; | 151 scoped_ptr<ShellAppWindowController> app_window_controller_; |
| 147 | 152 |
| 148 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); | 153 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); |
| 149 }; | 154 }; |
| 150 | 155 |
| 151 } // namespace extensions | 156 } // namespace extensions |
| 152 | 157 |
| 153 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 158 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
| OLD | NEW |