Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "extensions/shell/browser/shell_native_app_window_aura.h" | |
| 6 | |
| 7 #include "content/public/browser/web_contents.h" | |
| 8 #include "ui/aura/window.h" | |
| 9 #include "ui/aura/window_tree_host.h" | |
| 10 #include "ui/gfx/geometry/rect.h" | |
| 11 #include "ui/wm/core/window_util.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 ShellNativeAppWindowAura::ShellNativeAppWindowAura( | |
| 16 extensions::AppWindow* app_window, | |
|
James Cook
2014/11/11 18:23:52
no need for extensions:: here or below
Yoyo Zhou
2014/11/15 01:05:44
Done.
| |
| 17 const extensions::AppWindow::CreateParams& params) | |
| 18 : ShellNativeAppWindow(app_window, params) { | |
| 19 // TODO(yoz): We might have to duplicate this for mac. | |
| 20 gfx::Rect bounds = params.GetInitialWindowBounds(GetFrameInsets()); | |
| 21 bool position_specified = | |
| 22 bounds.x() != AppWindow::BoundsSpecification::kUnspecifiedPosition && | |
| 23 bounds.y() != AppWindow::BoundsSpecification::kUnspecifiedPosition; | |
| 24 if (!position_specified) | |
| 25 bounds.set_origin(GetBounds().origin()); | |
| 26 SetBounds(bounds); | |
| 27 } | |
| 28 | |
| 29 ShellNativeAppWindowAura::~ShellNativeAppWindowAura() { | |
| 30 } | |
| 31 | |
| 32 bool ShellNativeAppWindowAura::IsActive() const { | |
| 33 // Even though app_shell only supports a single app window, there might be | |
| 34 // some sort of system-level dialog open and active. | |
| 35 aura::Window* window = GetNativeWindow(); | |
| 36 return window && wm::IsActiveWindow(window); | |
| 37 } | |
| 38 | |
| 39 gfx::NativeWindow ShellNativeAppWindowAura::GetNativeWindow() const { | |
| 40 return app_window()->web_contents()->GetNativeView(); | |
| 41 } | |
| 42 | |
| 43 gfx::Rect ShellNativeAppWindowAura::GetBounds() const { | |
| 44 return GetNativeWindow()->GetBoundsInScreen(); | |
| 45 } | |
| 46 | |
| 47 void ShellNativeAppWindowAura::Show() { | |
| 48 GetNativeWindow()->Show(); | |
| 49 } | |
| 50 | |
| 51 void ShellNativeAppWindowAura::Hide() { | |
| 52 GetNativeWindow()->Hide(); | |
| 53 } | |
| 54 | |
| 55 void ShellNativeAppWindowAura::Activate() { | |
| 56 aura::Window* window = GetNativeWindow(); | |
| 57 if (window) | |
| 58 wm::ActivateWindow(window); | |
| 59 } | |
| 60 | |
| 61 void ShellNativeAppWindowAura::Deactivate() { | |
| 62 aura::Window* window = GetNativeWindow(); | |
| 63 if (window) | |
| 64 wm::DeactivateWindow(window); | |
| 65 } | |
| 66 | |
| 67 void ShellNativeAppWindowAura::SetBounds(const gfx::Rect& bounds) { | |
| 68 GetNativeWindow()->SetBounds(bounds); | |
| 69 } | |
| 70 | |
| 71 } // namespace extensions | |
|
James Cook
2014/11/11 18:23:52
I know you're just refactoring here, but can you w
| |
| OLD | NEW |