| 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 #include "extensions/shell/browser/shell_native_app_window.h" | 5 #include "extensions/shell/browser/shell_native_app_window.h" |
| 6 | 6 |
| 7 #include "content/public/browser/web_contents.h" | |
| 8 #include "extensions/shell/browser/desktop_controller.h" | 7 #include "extensions/shell/browser/desktop_controller.h" |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/aura/window_tree_host.h" | |
| 11 #include "ui/gfx/geometry/insets.h" | 8 #include "ui/gfx/geometry/insets.h" |
| 12 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/size.h" | 11 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/wm/core/window_util.h" | |
| 16 | 12 |
| 17 namespace extensions { | 13 namespace extensions { |
| 18 namespace { | |
| 19 | |
| 20 gfx::Size GetDesktopWindowSize() { | |
| 21 return DesktopController::instance()->GetHost()->window()->bounds().size(); | |
| 22 } | |
| 23 | |
| 24 } // namespace | |
| 25 | 14 |
| 26 ShellNativeAppWindow::ShellNativeAppWindow( | 15 ShellNativeAppWindow::ShellNativeAppWindow( |
| 27 AppWindow* app_window, | 16 AppWindow* app_window, |
| 28 const AppWindow::CreateParams& params) | 17 const AppWindow::CreateParams& params) |
| 29 : app_window_(app_window) { | 18 : app_window_(app_window) { |
| 30 gfx::Rect bounds = params.GetInitialWindowBounds(GetFrameInsets()); | |
| 31 bool position_specified = | |
| 32 bounds.x() != AppWindow::BoundsSpecification::kUnspecifiedPosition && | |
| 33 bounds.y() != AppWindow::BoundsSpecification::kUnspecifiedPosition; | |
| 34 if (!position_specified) | |
| 35 bounds.set_origin(GetBounds().origin()); | |
| 36 SetBounds(bounds); | |
| 37 } | 19 } |
| 38 | 20 |
| 39 ShellNativeAppWindow::~ShellNativeAppWindow() { | 21 ShellNativeAppWindow::~ShellNativeAppWindow() { |
| 40 } | 22 } |
| 41 | 23 |
| 42 bool ShellNativeAppWindow::IsActive() const { | |
| 43 // Even though app_shell only supports a single app window, there might be | |
| 44 // some sort of system-level dialog open and active. | |
| 45 aura::Window* window = GetWindow(); | |
| 46 return window && wm::IsActiveWindow(window); | |
| 47 } | |
| 48 | |
| 49 bool ShellNativeAppWindow::IsMaximized() const { | 24 bool ShellNativeAppWindow::IsMaximized() const { |
| 50 return false; | 25 return false; |
| 51 } | 26 } |
| 52 | 27 |
| 53 bool ShellNativeAppWindow::IsMinimized() const { | 28 bool ShellNativeAppWindow::IsMinimized() const { |
| 54 return false; | 29 return false; |
| 55 } | 30 } |
| 56 | 31 |
| 57 bool ShellNativeAppWindow::IsFullscreen() const { | 32 bool ShellNativeAppWindow::IsFullscreen() const { |
| 58 // The window in app_shell is considered a "restored" window that happens to | 33 // The window in app_shell is considered a "restored" window that happens to |
| 59 // fill the display. This avoids special handling of fullscreen or maximized | 34 // fill the display. This avoids special handling of fullscreen or maximized |
| 60 // windows that app_shell doesn't need. | 35 // windows that app_shell doesn't need. |
| 61 return false; | 36 return false; |
| 62 } | 37 } |
| 63 | 38 |
| 64 gfx::NativeWindow ShellNativeAppWindow::GetNativeWindow() const { | |
| 65 return GetWindow(); | |
| 66 } | |
| 67 | |
| 68 gfx::Rect ShellNativeAppWindow::GetRestoredBounds() const { | 39 gfx::Rect ShellNativeAppWindow::GetRestoredBounds() const { |
| 69 // app_shell windows cannot be maximized, so the current bounds are the | 40 // app_shell windows cannot be maximized, so the current bounds are the |
| 70 // restored bounds. | 41 // restored bounds. |
| 71 return GetBounds(); | 42 return GetBounds(); |
| 72 } | 43 } |
| 73 | 44 |
| 74 ui::WindowShowState ShellNativeAppWindow::GetRestoredState() const { | 45 ui::WindowShowState ShellNativeAppWindow::GetRestoredState() const { |
| 75 return ui::SHOW_STATE_NORMAL; | 46 return ui::SHOW_STATE_NORMAL; |
| 76 } | 47 } |
| 77 | 48 |
| 78 gfx::Rect ShellNativeAppWindow::GetBounds() const { | |
| 79 return GetWindow()->GetBoundsInScreen(); | |
| 80 } | |
| 81 | |
| 82 void ShellNativeAppWindow::Show() { | |
| 83 GetWindow()->Show(); | |
| 84 } | |
| 85 | |
| 86 void ShellNativeAppWindow::Hide() { | |
| 87 GetWindow()->Hide(); | |
| 88 } | |
| 89 | |
| 90 void ShellNativeAppWindow::ShowInactive() { | 49 void ShellNativeAppWindow::ShowInactive() { |
| 91 NOTIMPLEMENTED(); | 50 NOTIMPLEMENTED(); |
| 92 } | 51 } |
| 93 | 52 |
| 94 void ShellNativeAppWindow::Close() { | 53 void ShellNativeAppWindow::Close() { |
| 95 DesktopController::instance()->RemoveAppWindow(app_window_); | 54 DesktopController::instance()->RemoveAppWindow(app_window_); |
| 96 app_window_->OnNativeClose(); | 55 app_window_->OnNativeClose(); |
| 97 } | 56 } |
| 98 | 57 |
| 99 void ShellNativeAppWindow::Activate() { | |
| 100 aura::Window* window = GetWindow(); | |
| 101 if (window) | |
| 102 wm::ActivateWindow(window); | |
| 103 } | |
| 104 | |
| 105 void ShellNativeAppWindow::Deactivate() { | |
| 106 aura::Window* window = GetWindow(); | |
| 107 if (window) | |
| 108 wm::DeactivateWindow(window); | |
| 109 } | |
| 110 | |
| 111 void ShellNativeAppWindow::Maximize() { | 58 void ShellNativeAppWindow::Maximize() { |
| 112 NOTIMPLEMENTED(); | 59 NOTIMPLEMENTED(); |
| 113 } | 60 } |
| 114 | 61 |
| 115 void ShellNativeAppWindow::Minimize() { | 62 void ShellNativeAppWindow::Minimize() { |
| 116 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
| 117 } | 64 } |
| 118 | 65 |
| 119 void ShellNativeAppWindow::Restore() { | 66 void ShellNativeAppWindow::Restore() { |
| 120 NOTIMPLEMENTED(); | 67 NOTIMPLEMENTED(); |
| 121 } | 68 } |
| 122 | 69 |
| 123 void ShellNativeAppWindow::SetBounds(const gfx::Rect& bounds) { | |
| 124 GetWindow()->SetBounds(bounds); | |
| 125 } | |
| 126 | |
| 127 void ShellNativeAppWindow::FlashFrame(bool flash) { | 70 void ShellNativeAppWindow::FlashFrame(bool flash) { |
| 128 NOTIMPLEMENTED(); | 71 NOTIMPLEMENTED(); |
| 129 } | 72 } |
| 130 | 73 |
| 131 bool ShellNativeAppWindow::IsAlwaysOnTop() const { | 74 bool ShellNativeAppWindow::IsAlwaysOnTop() const { |
| 132 return false; | 75 return false; |
| 133 } | 76 } |
| 134 | 77 |
| 135 void ShellNativeAppWindow::SetAlwaysOnTop(bool always_on_top) { | 78 void ShellNativeAppWindow::SetAlwaysOnTop(bool always_on_top) { |
| 136 NOTIMPLEMENTED(); | 79 NOTIMPLEMENTED(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void ShellNativeAppWindow::HideWithApp() { | 172 void ShellNativeAppWindow::HideWithApp() { |
| 230 NOTIMPLEMENTED(); | 173 NOTIMPLEMENTED(); |
| 231 } | 174 } |
| 232 | 175 |
| 233 void ShellNativeAppWindow::UpdateShelfMenu() { | 176 void ShellNativeAppWindow::UpdateShelfMenu() { |
| 234 // app_shell has no shelf, dock, or system-tray to update. | 177 // app_shell has no shelf, dock, or system-tray to update. |
| 235 } | 178 } |
| 236 | 179 |
| 237 gfx::Size ShellNativeAppWindow::GetContentMinimumSize() const { | 180 gfx::Size ShellNativeAppWindow::GetContentMinimumSize() const { |
| 238 // Content fills the desktop and cannot be resized. | 181 // Content fills the desktop and cannot be resized. |
| 239 return GetDesktopWindowSize(); | 182 return DesktopController::instance()->GetWindowSize(); |
| 240 } | 183 } |
| 241 | 184 |
| 242 gfx::Size ShellNativeAppWindow::GetContentMaximumSize() const { | 185 gfx::Size ShellNativeAppWindow::GetContentMaximumSize() const { |
| 243 // Content fills the desktop and cannot be resized. | 186 // Content fills the desktop and cannot be resized. |
| 244 return GetDesktopWindowSize(); | 187 return DesktopController::instance()->GetWindowSize(); |
| 245 } | 188 } |
| 246 | 189 |
| 247 void ShellNativeAppWindow::SetContentSizeConstraints( | 190 void ShellNativeAppWindow::SetContentSizeConstraints( |
| 248 const gfx::Size& min_size, | 191 const gfx::Size& min_size, |
| 249 const gfx::Size& max_size) { | 192 const gfx::Size& max_size) { |
| 250 NOTIMPLEMENTED(); | 193 NOTIMPLEMENTED(); |
| 251 } | 194 } |
| 252 | 195 |
| 253 void ShellNativeAppWindow::SetVisibleOnAllWorkspaces(bool always_visible) { | 196 void ShellNativeAppWindow::SetVisibleOnAllWorkspaces(bool always_visible) { |
| 254 NOTIMPLEMENTED(); | 197 NOTIMPLEMENTED(); |
| 255 } | 198 } |
| 256 | 199 |
| 257 bool ShellNativeAppWindow::CanHaveAlphaEnabled() const { | 200 bool ShellNativeAppWindow::CanHaveAlphaEnabled() const { |
| 258 // No background to display if the window was transparent. | 201 // No background to display if the window was transparent. |
| 259 return false; | 202 return false; |
| 260 } | 203 } |
| 261 | 204 |
| 262 aura::Window* ShellNativeAppWindow::GetWindow() const { | |
| 263 return app_window_->web_contents()->GetNativeView(); | |
| 264 } | |
| 265 | |
| 266 } // namespace extensions | 205 } // namespace extensions |
| OLD | NEW |