| 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 "apps/ui/views/base_native_app_window_views.h" | 5 #include "apps/ui/views/native_app_window_views.h" |
| 6 | 6 |
| 7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
| 10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_contents_view.h" | 12 #include "content/public/browser/web_contents_view.h" |
| 13 #include "extensions/common/draggable_region.h" | 13 #include "extensions/common/draggable_region.h" |
| 14 #include "third_party/skia/include/core/SkRegion.h" | 14 #include "third_party/skia/include/core/SkRegion.h" |
| 15 #include "ui/gfx/path.h" | 15 #include "ui/gfx/path.h" |
| 16 #include "ui/views/controls/webview/webview.h" | 16 #include "ui/views/controls/webview/webview.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/window/non_client_view.h" | 18 #include "ui/views/window/non_client_view.h" |
| 19 | 19 |
| 20 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 using apps::AppWindow; | 24 namespace apps { |
| 25 | 25 |
| 26 BaseNativeAppWindowViews::BaseNativeAppWindowViews() | 26 NativeAppWindowViews::NativeAppWindowViews() |
| 27 : app_window_(NULL), | 27 : app_window_(NULL), |
| 28 web_view_(NULL), | 28 web_view_(NULL), |
| 29 window_(NULL), | 29 window_(NULL), |
| 30 frameless_(false), | 30 frameless_(false), |
| 31 transparent_background_(false), | 31 transparent_background_(false), |
| 32 resizable_(false) {} | 32 resizable_(false) {} |
| 33 | 33 |
| 34 void BaseNativeAppWindowViews::Init( | 34 void NativeAppWindowViews::Init(AppWindow* app_window, |
| 35 apps::AppWindow* app_window, | 35 const AppWindow::CreateParams& create_params) { |
| 36 const AppWindow::CreateParams& create_params) { | |
| 37 app_window_ = app_window; | 36 app_window_ = app_window; |
| 38 frameless_ = create_params.frame == AppWindow::FRAME_NONE; | 37 frameless_ = create_params.frame == AppWindow::FRAME_NONE; |
| 39 transparent_background_ = create_params.transparent_background; | 38 transparent_background_ = create_params.transparent_background; |
| 40 resizable_ = create_params.resizable; | 39 resizable_ = create_params.resizable; |
| 41 Observe(app_window_->web_contents()); | 40 Observe(app_window_->web_contents()); |
| 42 | 41 |
| 43 window_ = new views::Widget; | 42 window_ = new views::Widget; |
| 44 InitializeWindow(app_window, create_params); | 43 InitializeWindow(app_window, create_params); |
| 45 | 44 |
| 46 OnViewWasResized(); | 45 OnViewWasResized(); |
| 47 window_->AddObserver(this); | 46 window_->AddObserver(this); |
| 48 } | 47 } |
| 49 | 48 |
| 50 BaseNativeAppWindowViews::~BaseNativeAppWindowViews() { | 49 NativeAppWindowViews::~NativeAppWindowViews() { |
| 51 web_view_->SetWebContents(NULL); | 50 web_view_->SetWebContents(NULL); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void BaseNativeAppWindowViews::InitializeWindow( | 53 void NativeAppWindowViews::InitializeWindow( |
| 55 apps::AppWindow* app_window, | 54 AppWindow* app_window, |
| 56 const apps::AppWindow::CreateParams& create_params) { | 55 const AppWindow::CreateParams& create_params) { |
| 57 // Stub implementation. See also NativeAppWindowViews in Chrome. | 56 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 58 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | 57 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); |
| 59 init_params.delegate = this; | 58 init_params.delegate = this; |
| 60 init_params.top_level = true; | 59 init_params.top_level = true; |
| 61 init_params.keep_on_top = create_params.always_on_top; | 60 init_params.keep_on_top = create_params.always_on_top; |
| 62 window_->Init(init_params); | 61 window_->Init(init_params); |
| 63 window_->CenterWindow(create_params.bounds.size()); | 62 window_->CenterWindow(create_params.bounds.size()); |
| 64 } | 63 } |
| 65 | 64 |
| 66 // ui::BaseWindow implementation. | 65 // ui::BaseWindow implementation. |
| 67 | 66 |
| 68 bool BaseNativeAppWindowViews::IsActive() const { | 67 bool NativeAppWindowViews::IsActive() const { |
| 69 return window_->IsActive(); | 68 return window_->IsActive(); |
| 70 } | 69 } |
| 71 | 70 |
| 72 bool BaseNativeAppWindowViews::IsMaximized() const { | 71 bool NativeAppWindowViews::IsMaximized() const { |
| 73 return window_->IsMaximized(); | 72 return window_->IsMaximized(); |
| 74 } | 73 } |
| 75 | 74 |
| 76 bool BaseNativeAppWindowViews::IsMinimized() const { | 75 bool NativeAppWindowViews::IsMinimized() const { |
| 77 return window_->IsMinimized(); | 76 return window_->IsMinimized(); |
| 78 } | 77 } |
| 79 | 78 |
| 80 bool BaseNativeAppWindowViews::IsFullscreen() const { | 79 bool NativeAppWindowViews::IsFullscreen() const { |
| 81 return window_->IsFullscreen(); | 80 return window_->IsFullscreen(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 gfx::NativeWindow BaseNativeAppWindowViews::GetNativeWindow() { | 83 gfx::NativeWindow NativeAppWindowViews::GetNativeWindow() { |
| 85 return window_->GetNativeWindow(); | 84 return window_->GetNativeWindow(); |
| 86 } | 85 } |
| 87 | 86 |
| 88 gfx::Rect BaseNativeAppWindowViews::GetRestoredBounds() const { | 87 gfx::Rect NativeAppWindowViews::GetRestoredBounds() const { |
| 89 return window_->GetRestoredBounds(); | 88 return window_->GetRestoredBounds(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 ui::WindowShowState BaseNativeAppWindowViews::GetRestoredState() const { | 91 ui::WindowShowState NativeAppWindowViews::GetRestoredState() const { |
| 93 // Stub implementation. See also NativeAppWindowViews in Chrome. | 92 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 94 if (IsMaximized()) | 93 if (IsMaximized()) |
| 95 return ui::SHOW_STATE_MAXIMIZED; | 94 return ui::SHOW_STATE_MAXIMIZED; |
| 96 if (IsFullscreen()) | 95 if (IsFullscreen()) |
| 97 return ui::SHOW_STATE_FULLSCREEN; | 96 return ui::SHOW_STATE_FULLSCREEN; |
| 98 return ui::SHOW_STATE_NORMAL; | 97 return ui::SHOW_STATE_NORMAL; |
| 99 } | 98 } |
| 100 | 99 |
| 101 gfx::Rect BaseNativeAppWindowViews::GetBounds() const { | 100 gfx::Rect NativeAppWindowViews::GetBounds() const { |
| 102 return window_->GetWindowBoundsInScreen(); | 101 return window_->GetWindowBoundsInScreen(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 void BaseNativeAppWindowViews::Show() { | 104 void NativeAppWindowViews::Show() { |
| 106 if (window_->IsVisible()) { | 105 if (window_->IsVisible()) { |
| 107 window_->Activate(); | 106 window_->Activate(); |
| 108 return; | 107 return; |
| 109 } | 108 } |
| 110 window_->Show(); | 109 window_->Show(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void BaseNativeAppWindowViews::ShowInactive() { | 112 void NativeAppWindowViews::ShowInactive() { |
| 114 if (window_->IsVisible()) | 113 if (window_->IsVisible()) |
| 115 return; | 114 return; |
| 116 | 115 |
| 117 window_->ShowInactive(); | 116 window_->ShowInactive(); |
| 118 } | 117 } |
| 119 | 118 |
| 120 void BaseNativeAppWindowViews::Hide() { | 119 void NativeAppWindowViews::Hide() { |
| 121 window_->Hide(); | 120 window_->Hide(); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void BaseNativeAppWindowViews::Close() { | 123 void NativeAppWindowViews::Close() { |
| 125 window_->Close(); | 124 window_->Close(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 void BaseNativeAppWindowViews::Activate() { | 127 void NativeAppWindowViews::Activate() { |
| 129 window_->Activate(); | 128 window_->Activate(); |
| 130 } | 129 } |
| 131 | 130 |
| 132 void BaseNativeAppWindowViews::Deactivate() { | 131 void NativeAppWindowViews::Deactivate() { |
| 133 window_->Deactivate(); | 132 window_->Deactivate(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 void BaseNativeAppWindowViews::Maximize() { | 135 void NativeAppWindowViews::Maximize() { |
| 137 window_->Maximize(); | 136 window_->Maximize(); |
| 138 } | 137 } |
| 139 | 138 |
| 140 void BaseNativeAppWindowViews::Minimize() { | 139 void NativeAppWindowViews::Minimize() { |
| 141 window_->Minimize(); | 140 window_->Minimize(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void BaseNativeAppWindowViews::Restore() { | 143 void NativeAppWindowViews::Restore() { |
| 145 window_->Restore(); | 144 window_->Restore(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void BaseNativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { | 147 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { |
| 149 window_->SetBounds(bounds); | 148 window_->SetBounds(bounds); |
| 150 } | 149 } |
| 151 | 150 |
| 152 void BaseNativeAppWindowViews::FlashFrame(bool flash) { | 151 void NativeAppWindowViews::FlashFrame(bool flash) { |
| 153 window_->FlashFrame(flash); | 152 window_->FlashFrame(flash); |
| 154 } | 153 } |
| 155 | 154 |
| 156 bool BaseNativeAppWindowViews::IsAlwaysOnTop() const { | 155 bool NativeAppWindowViews::IsAlwaysOnTop() const { |
| 157 // Stub implementation. See also NativeAppWindowViews in Chrome. | 156 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 158 return window_->IsAlwaysOnTop(); | 157 return window_->IsAlwaysOnTop(); |
| 159 } | 158 } |
| 160 | 159 |
| 161 void BaseNativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { | 160 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { |
| 162 window_->SetAlwaysOnTop(always_on_top); | 161 window_->SetAlwaysOnTop(always_on_top); |
| 163 } | 162 } |
| 164 | 163 |
| 165 gfx::NativeView BaseNativeAppWindowViews::GetHostView() const { | 164 gfx::NativeView NativeAppWindowViews::GetHostView() const { |
| 166 return window_->GetNativeView(); | 165 return window_->GetNativeView(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 gfx::Point BaseNativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 168 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
| 170 gfx::Size app_window_size = window_->GetWindowBoundsInScreen().size(); | 169 gfx::Size app_window_size = window_->GetWindowBoundsInScreen().size(); |
| 171 return gfx::Point(app_window_size.width() / 2 - size.width() / 2, | 170 return gfx::Point(app_window_size.width() / 2 - size.width() / 2, |
| 172 app_window_size.height() / 2 - size.height() / 2); | 171 app_window_size.height() / 2 - size.height() / 2); |
| 173 } | 172 } |
| 174 | 173 |
| 175 gfx::Size BaseNativeAppWindowViews::GetMaximumDialogSize() { | 174 gfx::Size NativeAppWindowViews::GetMaximumDialogSize() { |
| 176 return window_->GetWindowBoundsInScreen().size(); | 175 return window_->GetWindowBoundsInScreen().size(); |
| 177 } | 176 } |
| 178 | 177 |
| 179 void BaseNativeAppWindowViews::AddObserver( | 178 void NativeAppWindowViews::AddObserver( |
| 180 web_modal::ModalDialogHostObserver* observer) { | 179 web_modal::ModalDialogHostObserver* observer) { |
| 181 observer_list_.AddObserver(observer); | 180 observer_list_.AddObserver(observer); |
| 182 } | 181 } |
| 183 void BaseNativeAppWindowViews::RemoveObserver( | 182 void NativeAppWindowViews::RemoveObserver( |
| 184 web_modal::ModalDialogHostObserver* observer) { | 183 web_modal::ModalDialogHostObserver* observer) { |
| 185 observer_list_.RemoveObserver(observer); | 184 observer_list_.RemoveObserver(observer); |
| 186 } | 185 } |
| 187 | 186 |
| 188 void BaseNativeAppWindowViews::OnViewWasResized() { | 187 void NativeAppWindowViews::OnViewWasResized() { |
| 189 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, | 188 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, |
| 190 observer_list_, | 189 observer_list_, |
| 191 OnPositionRequiresUpdate()); | 190 OnPositionRequiresUpdate()); |
| 192 } | 191 } |
| 193 | 192 |
| 194 // WidgetDelegate implementation. | 193 // WidgetDelegate implementation. |
| 195 | 194 |
| 196 void BaseNativeAppWindowViews::OnWidgetMove() { | 195 void NativeAppWindowViews::OnWidgetMove() { |
| 197 app_window_->OnNativeWindowChanged(); | 196 app_window_->OnNativeWindowChanged(); |
| 198 } | 197 } |
| 199 | 198 |
| 200 views::View* BaseNativeAppWindowViews::GetInitiallyFocusedView() { | 199 views::View* NativeAppWindowViews::GetInitiallyFocusedView() { |
| 201 return web_view_; | 200 return web_view_; |
| 202 } | 201 } |
| 203 | 202 |
| 204 bool BaseNativeAppWindowViews::CanResize() const { | 203 bool NativeAppWindowViews::CanResize() const { |
| 205 return resizable_ && !app_window_->size_constraints().HasFixedSize(); | 204 return resizable_ && !app_window_->size_constraints().HasFixedSize(); |
| 206 } | 205 } |
| 207 | 206 |
| 208 bool BaseNativeAppWindowViews::CanMaximize() const { | 207 bool NativeAppWindowViews::CanMaximize() const { |
| 209 return resizable_ && !app_window_->size_constraints().HasMaximumSize() && | 208 return resizable_ && !app_window_->size_constraints().HasMaximumSize() && |
| 210 !app_window_->window_type_is_panel(); | 209 !app_window_->window_type_is_panel(); |
| 211 } | 210 } |
| 212 | 211 |
| 213 base::string16 BaseNativeAppWindowViews::GetWindowTitle() const { | 212 base::string16 NativeAppWindowViews::GetWindowTitle() const { |
| 214 return app_window_->GetTitle(); | 213 return app_window_->GetTitle(); |
| 215 } | 214 } |
| 216 | 215 |
| 217 bool BaseNativeAppWindowViews::ShouldShowWindowTitle() const { | 216 bool NativeAppWindowViews::ShouldShowWindowTitle() const { |
| 218 return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; | 217 return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; |
| 219 } | 218 } |
| 220 | 219 |
| 221 bool BaseNativeAppWindowViews::ShouldShowWindowIcon() const { | 220 bool NativeAppWindowViews::ShouldShowWindowIcon() const { |
| 222 return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; | 221 return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; |
| 223 } | 222 } |
| 224 | 223 |
| 225 void BaseNativeAppWindowViews::SaveWindowPlacement( | 224 void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, |
| 226 const gfx::Rect& bounds, | 225 ui::WindowShowState show_state) { |
| 227 ui::WindowShowState show_state) { | |
| 228 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 226 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); |
| 229 app_window_->OnNativeWindowChanged(); | 227 app_window_->OnNativeWindowChanged(); |
| 230 } | 228 } |
| 231 | 229 |
| 232 void BaseNativeAppWindowViews::DeleteDelegate() { | 230 void NativeAppWindowViews::DeleteDelegate() { |
| 233 window_->RemoveObserver(this); | 231 window_->RemoveObserver(this); |
| 234 app_window_->OnNativeClose(); | 232 app_window_->OnNativeClose(); |
| 235 } | 233 } |
| 236 | 234 |
| 237 views::Widget* BaseNativeAppWindowViews::GetWidget() { | 235 views::Widget* NativeAppWindowViews::GetWidget() { |
| 238 return window_; | 236 return window_; |
| 239 } | 237 } |
| 240 | 238 |
| 241 const views::Widget* BaseNativeAppWindowViews::GetWidget() const { | 239 const views::Widget* NativeAppWindowViews::GetWidget() const { |
| 242 return window_; | 240 return window_; |
| 243 } | 241 } |
| 244 | 242 |
| 245 views::View* BaseNativeAppWindowViews::GetContentsView() { | 243 views::View* NativeAppWindowViews::GetContentsView() { |
| 246 return this; | 244 return this; |
| 247 } | 245 } |
| 248 | 246 |
| 249 bool BaseNativeAppWindowViews::ShouldDescendIntoChildForEventHandling( | 247 bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling( |
| 250 gfx::NativeView child, | 248 gfx::NativeView child, |
| 251 const gfx::Point& location) { | 249 const gfx::Point& location) { |
| 252 #if defined(USE_AURA) | 250 #if defined(USE_AURA) |
| 253 if (child->Contains(web_view_->web_contents()->GetView()->GetNativeView())) { | 251 if (child->Contains(web_view_->web_contents()->GetView()->GetNativeView())) { |
| 254 // App window should claim mouse events that fall within the draggable | 252 // App window should claim mouse events that fall within the draggable |
| 255 // region. | 253 // region. |
| 256 return !draggable_region_.get() || | 254 return !draggable_region_.get() || |
| 257 !draggable_region_->contains(location.x(), location.y()); | 255 !draggable_region_->contains(location.x(), location.y()); |
| 258 } | 256 } |
| 259 #endif | 257 #endif |
| 260 | 258 |
| 261 return true; | 259 return true; |
| 262 } | 260 } |
| 263 | 261 |
| 264 // WidgetObserver implementation. | 262 // WidgetObserver implementation. |
| 265 | 263 |
| 266 void BaseNativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget, | 264 void NativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget, |
| 267 bool visible) { | 265 bool visible) { |
| 268 app_window_->OnNativeWindowChanged(); | 266 app_window_->OnNativeWindowChanged(); |
| 269 } | 267 } |
| 270 | 268 |
| 271 void BaseNativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget, | 269 void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget, |
| 272 bool active) { | 270 bool active) { |
| 273 app_window_->OnNativeWindowChanged(); | 271 app_window_->OnNativeWindowChanged(); |
| 274 if (active) | 272 if (active) |
| 275 app_window_->OnNativeWindowActivated(); | 273 app_window_->OnNativeWindowActivated(); |
| 276 } | 274 } |
| 277 | 275 |
| 278 // WebContentsObserver implementation. | 276 // WebContentsObserver implementation. |
| 279 | 277 |
| 280 void BaseNativeAppWindowViews::RenderViewCreated( | 278 void NativeAppWindowViews::RenderViewCreated( |
| 281 content::RenderViewHost* render_view_host) { | 279 content::RenderViewHost* render_view_host) { |
| 282 if (transparent_background_) { | 280 if (transparent_background_) { |
| 283 // Use a background with transparency to trigger transparency in Webkit. | 281 // Use a background with transparency to trigger transparency in Webkit. |
| 284 SkBitmap background; | 282 SkBitmap background; |
| 285 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 283 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); |
| 286 background.allocPixels(); | 284 background.allocPixels(); |
| 287 background.eraseARGB(0x00, 0x00, 0x00, 0x00); | 285 background.eraseARGB(0x00, 0x00, 0x00, 0x00); |
| 288 | 286 |
| 289 content::RenderWidgetHostView* view = render_view_host->GetView(); | 287 content::RenderWidgetHostView* view = render_view_host->GetView(); |
| 290 DCHECK(view); | 288 DCHECK(view); |
| 291 view->SetBackground(background); | 289 view->SetBackground(background); |
| 292 } | 290 } |
| 293 } | 291 } |
| 294 | 292 |
| 295 void BaseNativeAppWindowViews::RenderViewHostChanged( | 293 void NativeAppWindowViews::RenderViewHostChanged( |
| 296 content::RenderViewHost* old_host, | 294 content::RenderViewHost* old_host, |
| 297 content::RenderViewHost* new_host) { | 295 content::RenderViewHost* new_host) { |
| 298 OnViewWasResized(); | 296 OnViewWasResized(); |
| 299 } | 297 } |
| 300 | 298 |
| 301 // views::View implementation. | 299 // views::View implementation. |
| 302 | 300 |
| 303 void BaseNativeAppWindowViews::Layout() { | 301 void NativeAppWindowViews::Layout() { |
| 304 DCHECK(web_view_); | 302 DCHECK(web_view_); |
| 305 web_view_->SetBounds(0, 0, width(), height()); | 303 web_view_->SetBounds(0, 0, width(), height()); |
| 306 OnViewWasResized(); | 304 OnViewWasResized(); |
| 307 } | 305 } |
| 308 | 306 |
| 309 void BaseNativeAppWindowViews::ViewHierarchyChanged( | 307 void NativeAppWindowViews::ViewHierarchyChanged( |
| 310 const ViewHierarchyChangedDetails& details) { | 308 const ViewHierarchyChangedDetails& details) { |
| 311 if (details.is_add && details.child == this) { | 309 if (details.is_add && details.child == this) { |
| 312 web_view_ = new views::WebView(NULL); | 310 web_view_ = new views::WebView(NULL); |
| 313 AddChildView(web_view_); | 311 AddChildView(web_view_); |
| 314 web_view_->SetWebContents(app_window_->web_contents()); | 312 web_view_->SetWebContents(app_window_->web_contents()); |
| 315 } | 313 } |
| 316 } | 314 } |
| 317 | 315 |
| 318 gfx::Size BaseNativeAppWindowViews::GetMinimumSize() { | 316 gfx::Size NativeAppWindowViews::GetMinimumSize() { |
| 319 return app_window_->size_constraints().GetMinimumSize(); | 317 return app_window_->size_constraints().GetMinimumSize(); |
| 320 } | 318 } |
| 321 | 319 |
| 322 gfx::Size BaseNativeAppWindowViews::GetMaximumSize() { | 320 gfx::Size NativeAppWindowViews::GetMaximumSize() { |
| 323 return app_window_->size_constraints().GetMaximumSize(); | 321 return app_window_->size_constraints().GetMaximumSize(); |
| 324 } | 322 } |
| 325 | 323 |
| 326 void BaseNativeAppWindowViews::OnFocus() { | 324 void NativeAppWindowViews::OnFocus() { |
| 327 web_view_->RequestFocus(); | 325 web_view_->RequestFocus(); |
| 328 } | 326 } |
| 329 | 327 |
| 330 // NativeAppWindow implementation. | 328 // NativeAppWindow implementation. |
| 331 | 329 |
| 332 void BaseNativeAppWindowViews::SetFullscreen(int fullscreen_types) { | 330 void NativeAppWindowViews::SetFullscreen(int fullscreen_types) { |
| 333 // Stub implementation. See also NativeAppWindowViews in Chrome. | 331 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 334 window_->SetFullscreen(fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE); | 332 window_->SetFullscreen(fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE); |
| 335 } | 333 } |
| 336 | 334 |
| 337 bool BaseNativeAppWindowViews::IsFullscreenOrPending() const { | 335 bool NativeAppWindowViews::IsFullscreenOrPending() const { |
| 338 // Stub implementation. See also NativeAppWindowViews in Chrome. | 336 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 339 return window_->IsFullscreen(); | 337 return window_->IsFullscreen(); |
| 340 } | 338 } |
| 341 | 339 |
| 342 bool BaseNativeAppWindowViews::IsDetached() const { | 340 bool NativeAppWindowViews::IsDetached() const { |
| 343 // Stub implementation. See also NativeAppWindowViews in Chrome. | 341 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 344 return false; | 342 return false; |
| 345 } | 343 } |
| 346 | 344 |
| 347 void BaseNativeAppWindowViews::UpdateWindowIcon() { | 345 void NativeAppWindowViews::UpdateWindowIcon() { |
| 348 window_->UpdateWindowIcon(); | 346 window_->UpdateWindowIcon(); |
| 349 } | 347 } |
| 350 | 348 |
| 351 void BaseNativeAppWindowViews::UpdateWindowTitle() { | 349 void NativeAppWindowViews::UpdateWindowTitle() { |
| 352 window_->UpdateWindowTitle(); | 350 window_->UpdateWindowTitle(); |
| 353 } | 351 } |
| 354 | 352 |
| 355 void BaseNativeAppWindowViews::UpdateBadgeIcon() { | 353 void NativeAppWindowViews::UpdateBadgeIcon() { |
| 356 // Stub implementation. See also NativeAppWindowViews in Chrome. | 354 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 357 } | 355 } |
| 358 | 356 |
| 359 void BaseNativeAppWindowViews::UpdateDraggableRegions( | 357 void NativeAppWindowViews::UpdateDraggableRegions( |
| 360 const std::vector<extensions::DraggableRegion>& regions) { | 358 const std::vector<extensions::DraggableRegion>& regions) { |
| 361 // Draggable region is not supported for non-frameless window. | 359 // Draggable region is not supported for non-frameless window. |
| 362 if (!frameless_) | 360 if (!frameless_) |
| 363 return; | 361 return; |
| 364 | 362 |
| 365 draggable_region_.reset(AppWindow::RawDraggableRegionsToSkRegion(regions)); | 363 draggable_region_.reset(AppWindow::RawDraggableRegionsToSkRegion(regions)); |
| 366 OnViewWasResized(); | 364 OnViewWasResized(); |
| 367 } | 365 } |
| 368 | 366 |
| 369 SkRegion* BaseNativeAppWindowViews::GetDraggableRegion() { | 367 SkRegion* NativeAppWindowViews::GetDraggableRegion() { |
| 370 return draggable_region_.get(); | 368 return draggable_region_.get(); |
| 371 } | 369 } |
| 372 | 370 |
| 373 void BaseNativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) { | 371 void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) { |
| 374 // Stub implementation. See also NativeAppWindowViews in Chrome. | 372 // Stub implementation. See also ChromeNativeAppWindowViews. |
| 375 } | 373 } |
| 376 | 374 |
| 377 void BaseNativeAppWindowViews::HandleKeyboardEvent( | 375 void NativeAppWindowViews::HandleKeyboardEvent( |
| 378 const content::NativeWebKeyboardEvent& event) { | 376 const content::NativeWebKeyboardEvent& event) { |
| 379 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 377 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
| 380 GetFocusManager()); | 378 GetFocusManager()); |
| 381 } | 379 } |
| 382 | 380 |
| 383 bool BaseNativeAppWindowViews::IsFrameless() const { | 381 bool NativeAppWindowViews::IsFrameless() const { return frameless_; } |
| 384 return frameless_; | |
| 385 } | |
| 386 | 382 |
| 387 bool BaseNativeAppWindowViews::HasFrameColor() const { return false; } | 383 bool NativeAppWindowViews::HasFrameColor() const { return false; } |
| 388 | 384 |
| 389 SkColor BaseNativeAppWindowViews::FrameColor() const { return SK_ColorBLACK; } | 385 SkColor NativeAppWindowViews::FrameColor() const { return SK_ColorBLACK; } |
| 390 | 386 |
| 391 gfx::Insets BaseNativeAppWindowViews::GetFrameInsets() const { | 387 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { |
| 392 if (frameless_) | 388 if (frameless_) |
| 393 return gfx::Insets(); | 389 return gfx::Insets(); |
| 394 | 390 |
| 395 // The pretend client_bounds passed in need to be large enough to ensure that | 391 // The pretend client_bounds passed in need to be large enough to ensure that |
| 396 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than | 392 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than |
| 397 // the specified amount of space to fit the window controls in, and return a | 393 // the specified amount of space to fit the window controls in, and return a |
| 398 // number larger than the real frame insets. Most window controls are smaller | 394 // number larger than the real frame insets. Most window controls are smaller |
| 399 // than 1000x1000px, so this should be big enough. | 395 // than 1000x1000px, so this should be big enough. |
| 400 gfx::Rect client_bounds = gfx::Rect(1000, 1000); | 396 gfx::Rect client_bounds = gfx::Rect(1000, 1000); |
| 401 gfx::Rect window_bounds = | 397 gfx::Rect window_bounds = |
| 402 window_->non_client_view()->GetWindowBoundsForClientBounds( | 398 window_->non_client_view()->GetWindowBoundsForClientBounds( |
| 403 client_bounds); | 399 client_bounds); |
| 404 return window_bounds.InsetsFrom(client_bounds); | 400 return window_bounds.InsetsFrom(client_bounds); |
| 405 } | 401 } |
| 406 | 402 |
| 407 void BaseNativeAppWindowViews::HideWithApp() {} | 403 void NativeAppWindowViews::HideWithApp() {} |
| 408 | 404 |
| 409 void BaseNativeAppWindowViews::ShowWithApp() {} | 405 void NativeAppWindowViews::ShowWithApp() {} |
| 410 | 406 |
| 411 void BaseNativeAppWindowViews::UpdateWindowMinMaxSize() {} | 407 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} |
| 412 | 408 |
| 413 void BaseNativeAppWindowViews::UpdateShelfMenu() {} | 409 void NativeAppWindowViews::UpdateShelfMenu() {} |
| 410 |
| 411 } // namespace apps |
| OLD | NEW |