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.
5 #include "extensions/shell/browser/shell_native_app_window.h"
7 #include "extensions/shell/browser/desktop_controller.h"
8 #include "third_party/skia/include/core/SkRegion.h"
9 #include "ui/gfx/geometry/insets.h"
10 #include "ui/gfx/geometry/point.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h"
14 namespace extensions
{
16 ShellNativeAppWindow::ShellNativeAppWindow(
17 AppWindow
* app_window
,
18 const AppWindow::CreateParams
& params
)
19 : app_window_(app_window
) {
22 ShellNativeAppWindow::~ShellNativeAppWindow() {
25 bool ShellNativeAppWindow::IsMaximized() const {
29 bool ShellNativeAppWindow::IsMinimized() const {
33 bool ShellNativeAppWindow::IsFullscreen() const {
34 // The window in app_shell is considered a "restored" window that happens to
35 // fill the display. This avoids special handling of fullscreen or maximized
36 // windows that app_shell doesn't need.
40 gfx::Rect
ShellNativeAppWindow::GetRestoredBounds() const {
41 // app_shell windows cannot be maximized, so the current bounds are the
46 ui::WindowShowState
ShellNativeAppWindow::GetRestoredState() const {
47 return ui::SHOW_STATE_NORMAL
;
50 void ShellNativeAppWindow::ShowInactive() {
54 void ShellNativeAppWindow::Close() {
55 DesktopController::instance()->RemoveAppWindow(app_window_
);
56 app_window_
->OnNativeClose();
59 void ShellNativeAppWindow::Maximize() {
63 void ShellNativeAppWindow::Minimize() {
67 void ShellNativeAppWindow::Restore() {
71 void ShellNativeAppWindow::FlashFrame(bool flash
) {
75 bool ShellNativeAppWindow::IsAlwaysOnTop() const {
79 void ShellNativeAppWindow::SetAlwaysOnTop(bool always_on_top
) {
83 gfx::NativeView
ShellNativeAppWindow::GetHostView() const {
88 gfx::Point
ShellNativeAppWindow::GetDialogPosition(const gfx::Size
& size
) {
93 void ShellNativeAppWindow::AddObserver(
94 web_modal::ModalDialogHostObserver
* observer
) {
98 void ShellNativeAppWindow::RemoveObserver(
99 web_modal::ModalDialogHostObserver
* observer
) {
103 gfx::Size
ShellNativeAppWindow::GetMaximumDialogSize() {
108 void ShellNativeAppWindow::SetFullscreen(int fullscreen_types
) {
112 bool ShellNativeAppWindow::IsFullscreenOrPending() const {
113 // See comment in IsFullscreen().
117 void ShellNativeAppWindow::UpdateWindowIcon() {
118 // No icon to update.
121 void ShellNativeAppWindow::UpdateWindowTitle() {
122 // No window title to update.
125 void ShellNativeAppWindow::UpdateBadgeIcon() {
126 // No badge to update.
129 void ShellNativeAppWindow::UpdateDraggableRegions(
130 const std::vector
<DraggableRegion
>& regions
) {
134 SkRegion
* ShellNativeAppWindow::GetDraggableRegion() {
139 void ShellNativeAppWindow::UpdateShape(scoped_ptr
<SkRegion
> region
) {
143 void ShellNativeAppWindow::SetInterceptAllKeys(bool want_all_keys
) {
147 void ShellNativeAppWindow::HandleKeyboardEvent(
148 const content::NativeWebKeyboardEvent
& event
) {
149 // No special handling. The WebContents will handle it.
152 bool ShellNativeAppWindow::IsFrameless() const {
157 bool ShellNativeAppWindow::HasFrameColor() const {
161 SkColor
ShellNativeAppWindow::ActiveFrameColor() const {
165 SkColor
ShellNativeAppWindow::InactiveFrameColor() const {
169 gfx::Insets
ShellNativeAppWindow::GetFrameInsets() const {
170 return gfx::Insets();
173 void ShellNativeAppWindow::ShowWithApp() {
177 void ShellNativeAppWindow::HideWithApp() {
181 void ShellNativeAppWindow::UpdateShelfMenu() {
182 // app_shell has no shelf, dock, or system-tray to update.
185 gfx::Size
ShellNativeAppWindow::GetContentMinimumSize() const {
186 // Content fills the desktop and cannot be resized.
187 return DesktopController::instance()->GetWindowSize();
190 gfx::Size
ShellNativeAppWindow::GetContentMaximumSize() const {
191 // Content fills the desktop and cannot be resized.
192 return DesktopController::instance()->GetWindowSize();
195 void ShellNativeAppWindow::SetContentSizeConstraints(
196 const gfx::Size
& min_size
,
197 const gfx::Size
& max_size
) {
201 void ShellNativeAppWindow::SetVisibleOnAllWorkspaces(bool always_visible
) {
205 bool ShellNativeAppWindow::CanHaveAlphaEnabled() const {
206 // No background to display if the window was transparent.
210 } // namespace extensions