1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file.
4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/native_app_window/native_app_window_views.h"
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/threading/sequenced_worker_pool.h"
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/render_view_host.h"
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/render_widget_host_view.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/web_contents.h"
111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/app_window/app_window.h"
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "extensions/common/draggable_region.h"
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "third_party/skia/include/core/SkRegion.h"
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/gfx/path.h"
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/views/controls/webview/webview.h"
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/views/widget/widget.h"
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/views/window/non_client_view.h"
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(USE_AURA)
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window.h"
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciusing extensions::AppWindow;
241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace native_app_window {
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)NativeAppWindowViews::NativeAppWindowViews()
28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    : app_window_(NULL),
29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      web_view_(NULL),
3023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)      widget_(NULL),
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      frameless_(false),
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      resizable_(false) {
331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::Init(AppWindow* app_window,
36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                const AppWindow::CreateParams& create_params) {
37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  app_window_ = app_window;
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  frameless_ = create_params.frame == AppWindow::FRAME_NONE;
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  resizable_ = create_params.resizable;
4023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  size_constraints_.set_minimum_size(
4123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)      create_params.GetContentMinimumSize(gfx::Insets()));
4223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  size_constraints_.set_maximum_size(
4323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)      create_params.GetContentMaximumSize(gfx::Insets()));
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  Observe(app_window_->web_contents());
45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
4623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_ = new views::Widget;
47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  InitializeWindow(app_window, create_params);
48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  OnViewWasResized();
5023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->AddObserver(this);
51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)NativeAppWindowViews::~NativeAppWindowViews() {
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  web_view_->SetWebContents(NULL);
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
57116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid NativeAppWindowViews::OnCanHaveAlphaEnabledChanged() {
58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  app_window_->OnNativeWindowChanged();
59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::InitializeWindow(
62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    AppWindow* app_window,
63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const AppWindow::CreateParams& create_params) {
64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW);
66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  init_params.delegate = this;
67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  init_params.keep_on_top = create_params.always_on_top;
6823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->Init(init_params);
6923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->CenterWindow(
70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      create_params.GetInitialWindowBounds(gfx::Insets()).size());
71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// ui::BaseWindow implementation.
74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool NativeAppWindowViews::IsActive() const {
761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return widget_->IsActive();
771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::IsMaximized() const {
8023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->IsMaximized();
81a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
82a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
83a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::IsMinimized() const {
8423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->IsMinimized();
85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
86a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
87a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::IsFullscreen() const {
8823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->IsFullscreen();
89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
90a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::NativeWindow NativeAppWindowViews::GetNativeWindow() {
9223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->GetNativeWindow();
93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Rect NativeAppWindowViews::GetRestoredBounds() const {
9623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->GetRestoredBounds();
97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)ui::WindowShowState NativeAppWindowViews::GetRestoredState() const {
100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (IsMaximized())
102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return ui::SHOW_STATE_MAXIMIZED;
103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (IsFullscreen())
104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return ui::SHOW_STATE_FULLSCREEN;
105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return ui::SHOW_STATE_NORMAL;
106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Rect NativeAppWindowViews::GetBounds() const {
10923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->GetWindowBoundsInScreen();
110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::Show() {
11323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  if (widget_->IsVisible()) {
11423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    widget_->Activate();
115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
11723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->Show();
118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::ShowInactive() {
12123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  if (widget_->IsVisible())
122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
12423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->ShowInactive();
125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Hide() {
1281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Hide();
1291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Close() {
1321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Close();
1331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
134a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Activate() {
1361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Activate();
1371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Deactivate() {
1401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Deactivate();
1411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Maximize() {
1441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Maximize();
1451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Minimize() {
1481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Minimize();
1491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::Restore() {
1521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->Restore();
1531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
154a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
155a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) {
15623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->SetBounds(bounds);
157a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
158a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
159a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::FlashFrame(bool flash) {
16023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->FlashFrame(flash);
161a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
162a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
163a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::IsAlwaysOnTop() const {
164a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
16523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->IsAlwaysOnTop();
166a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) {
16923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->SetAlwaysOnTop(always_on_top);
170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::NativeView NativeAppWindowViews::GetHostView() const {
17323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->GetNativeView();
174a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
175a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) {
17723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  gfx::Size app_window_size = widget_->GetWindowBoundsInScreen().size();
178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return gfx::Point(app_window_size.width() / 2 - size.width() / 2,
179a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                    app_window_size.height() / 2 - size.height() / 2);
180a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
181a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
182a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Size NativeAppWindowViews::GetMaximumDialogSize() {
18323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->GetWindowBoundsInScreen().size();
184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::AddObserver(
187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    web_modal::ModalDialogHostObserver* observer) {
188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  observer_list_.AddObserver(observer);
189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::RemoveObserver(
191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    web_modal::ModalDialogHostObserver* observer) {
192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  observer_list_.RemoveObserver(observer);
193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
194a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
195a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::OnViewWasResized() {
196a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver,
197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                    observer_list_,
198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                    OnPositionRequiresUpdate());
199a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
200a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
201a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// WidgetDelegate implementation.
202a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
203a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::OnWidgetMove() {
204a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  app_window_->OnNativeWindowChanged();
205a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
206a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)views::View* NativeAppWindowViews::GetInitiallyFocusedView() {
208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return web_view_;
209a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
210a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
211a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::CanResize() const {
2121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return resizable_ && !size_constraints_.HasFixedSize() &&
2131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci         !WidgetHasHitTestMask();
214a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::CanMaximize() const {
217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return resizable_ && !size_constraints_.HasMaximumSize() &&
2181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci         !app_window_->window_type_is_panel() && !WidgetHasHitTestMask();
2191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
2201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool NativeAppWindowViews::CanMinimize() const {
2221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return true;
223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 NativeAppWindowViews::GetWindowTitle() const {
226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return app_window_->GetTitle();
227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::ShouldShowWindowTitle() const {
230a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL;
231a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
232a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
233a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::ShouldShowWindowIcon() const {
234a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL;
235a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
236a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
237a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds,
238a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               ui::WindowShowState show_state) {
239a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
240a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  app_window_->OnNativeWindowChanged();
241a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
242a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
243a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::DeleteDelegate() {
24423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->RemoveObserver(this);
245a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  app_window_->OnNativeClose();
246a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
247a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
2481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciviews::Widget* NativeAppWindowViews::GetWidget() {
2491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return widget_;
2501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
251a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
2521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst views::Widget* NativeAppWindowViews::GetWidget() const {
2531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return widget_;
2541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
256a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)views::View* NativeAppWindowViews::GetContentsView() {
257a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return this;
258a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
259a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
260a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling(
261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    gfx::NativeView child,
262a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const gfx::Point& location) {
263a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(USE_AURA)
264010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  if (child->Contains(web_view_->web_contents()->GetNativeView())) {
265a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // App window should claim mouse events that fall within the draggable
266a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // region.
267a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return !draggable_region_.get() ||
268a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)           !draggable_region_->contains(location.x(), location.y());
269a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
270a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
271a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
272a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return true;
273a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
275a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// WidgetObserver implementation.
276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget,
278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                     bool visible) {
279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  app_window_->OnNativeWindowChanged();
280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
282a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget,
283a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                     bool active) {
284a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  app_window_->OnNativeWindowChanged();
285a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (active)
286a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    app_window_->OnNativeWindowActivated();
287a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
288a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
289a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// WebContentsObserver implementation.
290a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
291a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::RenderViewCreated(
292a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    content::RenderViewHost* render_view_host) {
2936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  if (app_window_->requested_alpha_enabled() && CanHaveAlphaEnabled()) {
294a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    content::RenderWidgetHostView* view = render_view_host->GetView();
295a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    DCHECK(view);
296cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    view->SetBackgroundOpaque(false);
297a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
298a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
299a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
300a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::RenderViewHostChanged(
301a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    content::RenderViewHost* old_host,
302a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    content::RenderViewHost* new_host) {
303a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  OnViewWasResized();
304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
306a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// views::View implementation.
307a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
308a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::Layout() {
309a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  DCHECK(web_view_);
310a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  web_view_->SetBounds(0, 0, width(), height());
311a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  OnViewWasResized();
312a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
313a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
314a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::ViewHierarchyChanged(
315a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const ViewHierarchyChangedDetails& details) {
316a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (details.is_add && details.child == this) {
317a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    web_view_ = new views::WebView(NULL);
318a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    AddChildView(web_view_);
319a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    web_view_->SetWebContents(app_window_->web_contents());
320a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
321a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
322a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
323cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)gfx::Size NativeAppWindowViews::GetMinimumSize() const {
324a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return size_constraints_.GetMinimumSize();
325a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
326a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
327cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)gfx::Size NativeAppWindowViews::GetMaximumSize() const {
328a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return size_constraints_.GetMaximumSize();
329a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
330a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
331a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::OnFocus() {
332a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  web_view_->RequestFocus();
333a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
334a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
335a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// NativeAppWindow implementation.
336a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
337a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::SetFullscreen(int fullscreen_types) {
338a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
33923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  widget_->SetFullscreen(fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE);
340a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
341a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
342a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool NativeAppWindowViews::IsFullscreenOrPending() const {
343a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
34423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return widget_->IsFullscreen();
345a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
346a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::UpdateWindowIcon() {
3481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->UpdateWindowIcon();
3491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
350a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::UpdateWindowTitle() {
3521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->UpdateWindowTitle();
3531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
354a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
355a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::UpdateBadgeIcon() {
356a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
357a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
359a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::UpdateDraggableRegions(
360a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const std::vector<extensions::DraggableRegion>& regions) {
361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Draggable region is not supported for non-frameless window.
362a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!frameless_)
363a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
365a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  draggable_region_.reset(AppWindow::RawDraggableRegionsToSkRegion(regions));
366a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  OnViewWasResized();
367a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
368a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
369a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)SkRegion* NativeAppWindowViews::GetDraggableRegion() {
370a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return draggable_region_.get();
371a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
372a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
373a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) {
374a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stub implementation. See also ChromeNativeAppWindowViews.
375a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
376a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
377a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::HandleKeyboardEvent(
378a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const content::NativeWebKeyboardEvent& event) {
379a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
380a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                        GetFocusManager());
381a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
382a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool NativeAppWindowViews::IsFrameless() const {
3841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return frameless_;
3851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
386a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool NativeAppWindowViews::HasFrameColor() const {
3881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return false;
3891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3915c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuSkColor NativeAppWindowViews::ActiveFrameColor() const {
3925c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  return SK_ColorBLACK;
3935c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu}
3945c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
3955c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuSkColor NativeAppWindowViews::InactiveFrameColor() const {
3965c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  return SK_ColorBLACK;
3975c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu}
398a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
399a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Insets NativeAppWindowViews::GetFrameInsets() const {
400a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (frameless_)
401a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return gfx::Insets();
402a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
403a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // The pretend client_bounds passed in need to be large enough to ensure that
404a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // GetWindowBoundsForClientBounds() doesn't decide that it needs more than
405a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // the specified amount of space to fit the window controls in, and return a
406a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // number larger than the real frame insets. Most window controls are smaller
407a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // than 1000x1000px, so this should be big enough.
408a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  gfx::Rect client_bounds = gfx::Rect(1000, 1000);
409a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  gfx::Rect window_bounds =
41023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)      widget_->non_client_view()->GetWindowBoundsForClientBounds(client_bounds);
411a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return window_bounds.InsetsFrom(client_bounds);
412a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
413a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
4141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::HideWithApp() {
4151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
416a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
4171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::ShowWithApp() {
4181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
419a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
4201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::UpdateShelfMenu() {
4211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
422a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
423a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Size NativeAppWindowViews::GetContentMinimumSize() const {
424a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return size_constraints_.GetMinimumSize();
425a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
426a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
427a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)gfx::Size NativeAppWindowViews::GetContentMaximumSize() const {
428a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return size_constraints_.GetMaximumSize();
429a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
430a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
431a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void NativeAppWindowViews::SetContentSizeConstraints(
4321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    const gfx::Size& min_size,
4331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    const gfx::Size& max_size) {
434a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  size_constraints_.set_minimum_size(min_size);
435a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  size_constraints_.set_maximum_size(max_size);
4361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->OnSizeConstraintsChanged();
437a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
438a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
439116680a4aac90f2aa7413d9095a592090648e557Ben Murdochbool NativeAppWindowViews::CanHaveAlphaEnabled() const {
440116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  return widget_->IsTranslucentWindowOpacitySupported();
441116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
442116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
4431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid NativeAppWindowViews::SetVisibleOnAllWorkspaces(bool always_visible) {
4441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  widget_->SetVisibleOnAllWorkspaces(always_visible);
4451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
4461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
4471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace native_app_window
448