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