Chromium Code Reviews| 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/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 "extensions/common/draggable_region.h" | 12 #include "extensions/common/draggable_region.h" |
| 13 #include "third_party/skia/include/core/SkRegion.h" | 13 #include "third_party/skia/include/core/SkRegion.h" |
| 14 #include "ui/gfx/path.h" | 14 #include "ui/gfx/path.h" |
| 15 #include "ui/views/controls/webview/webview.h" | 15 #include "ui/views/controls/webview/webview.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 #include "ui/views/window/non_client_view.h" | 17 #include "ui/views/window/non_client_view.h" |
| 18 | 18 |
| 19 #if defined(USE_AURA) | 19 #if defined(USE_AURA) |
| 20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace apps { | 23 namespace apps { |
| 24 | 24 |
| 25 NativeAppWindowViews::NativeAppWindowViews() | 25 NativeAppWindowViews::NativeAppWindowViews() |
| 26 : app_window_(NULL), | 26 : app_window_(NULL), |
| 27 web_view_(NULL), | 27 web_view_(NULL), |
| 28 widget_(NULL), | 28 widget_(NULL), |
| 29 frameless_(false), | 29 frameless_(false), |
| 30 transparent_background_(false), | |
| 31 resizable_(false) {} | 30 resizable_(false) {} |
| 32 | 31 |
| 33 void NativeAppWindowViews::Init(AppWindow* app_window, | 32 void NativeAppWindowViews::Init(AppWindow* app_window, |
| 34 const AppWindow::CreateParams& create_params) { | 33 const AppWindow::CreateParams& create_params) { |
| 35 app_window_ = app_window; | 34 app_window_ = app_window; |
| 36 frameless_ = create_params.frame == AppWindow::FRAME_NONE; | 35 frameless_ = create_params.frame == AppWindow::FRAME_NONE; |
| 37 transparent_background_ = create_params.transparent_background; | |
| 38 resizable_ = create_params.resizable; | 36 resizable_ = create_params.resizable; |
| 39 size_constraints_.set_minimum_size( | 37 size_constraints_.set_minimum_size( |
| 40 create_params.GetContentMinimumSize(gfx::Insets())); | 38 create_params.GetContentMinimumSize(gfx::Insets())); |
| 41 size_constraints_.set_maximum_size( | 39 size_constraints_.set_maximum_size( |
| 42 create_params.GetContentMaximumSize(gfx::Insets())); | 40 create_params.GetContentMaximumSize(gfx::Insets())); |
| 43 Observe(app_window_->web_contents()); | 41 Observe(app_window_->web_contents()); |
| 44 | 42 |
| 45 widget_ = new views::Widget; | 43 widget_ = new views::Widget; |
| 46 InitializeWindow(app_window, create_params); | 44 InitializeWindow(app_window, create_params); |
| 47 | 45 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 bool active) { | 251 bool active) { |
| 254 app_window_->OnNativeWindowChanged(); | 252 app_window_->OnNativeWindowChanged(); |
| 255 if (active) | 253 if (active) |
| 256 app_window_->OnNativeWindowActivated(); | 254 app_window_->OnNativeWindowActivated(); |
| 257 } | 255 } |
| 258 | 256 |
| 259 // WebContentsObserver implementation. | 257 // WebContentsObserver implementation. |
| 260 | 258 |
| 261 void NativeAppWindowViews::RenderViewCreated( | 259 void NativeAppWindowViews::RenderViewCreated( |
| 262 content::RenderViewHost* render_view_host) { | 260 content::RenderViewHost* render_view_host) { |
| 263 if (transparent_background_) { | 261 if (app_window_->RequestedTransparentBackground() && |
| 262 CanHaveTransparentBackground()) { | |
| 264 content::RenderWidgetHostView* view = render_view_host->GetView(); | 263 content::RenderWidgetHostView* view = render_view_host->GetView(); |
| 265 DCHECK(view); | 264 DCHECK(view); |
| 266 view->SetBackgroundOpaque(false); | 265 view->SetBackgroundOpaque(false); |
| 267 } | 266 } |
| 268 } | 267 } |
| 269 | 268 |
| 270 void NativeAppWindowViews::RenderViewHostChanged( | 269 void NativeAppWindowViews::RenderViewHostChanged( |
| 271 content::RenderViewHost* old_host, | 270 content::RenderViewHost* old_host, |
| 272 content::RenderViewHost* new_host) { | 271 content::RenderViewHost* new_host) { |
| 273 OnViewWasResized(); | 272 OnViewWasResized(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 gfx::Size NativeAppWindowViews::GetContentMaximumSize() const { | 390 gfx::Size NativeAppWindowViews::GetContentMaximumSize() const { |
| 392 return size_constraints_.GetMaximumSize(); | 391 return size_constraints_.GetMaximumSize(); |
| 393 } | 392 } |
| 394 | 393 |
| 395 void NativeAppWindowViews::SetContentSizeConstraints( | 394 void NativeAppWindowViews::SetContentSizeConstraints( |
| 396 const gfx::Size& min_size, const gfx::Size& max_size) { | 395 const gfx::Size& min_size, const gfx::Size& max_size) { |
| 397 size_constraints_.set_minimum_size(min_size); | 396 size_constraints_.set_minimum_size(min_size); |
| 398 size_constraints_.set_maximum_size(max_size); | 397 size_constraints_.set_maximum_size(max_size); |
| 399 } | 398 } |
| 400 | 399 |
| 400 bool NativeAppWindowViews::CanHaveTransparentBackground() const { | |
| 401 return true; | |
|
Wez
2014/07/09 22:03:30
So by default we're assuming that Views can always
jackhou1
2014/07/10 03:04:18
It looks like we use ChromeNativeAppWindowViews on
Wez
2014/07/11 17:14:10
Looks plausible, but I'm no expect on views/Aura.
jackhou1
2014/07/14 03:08:12
benwells, any advice on this?
| |
| 402 } | |
| 403 | |
| 404 void NativeAppWindowViews::CanHaveTransparentBackgroundChanged() { | |
| 405 app_window_->OnNativeWindowChanged(); | |
|
Wez
2014/07/09 22:03:30
Does this fix the Classic->Aero transitions?
jackhou1
2014/07/10 03:04:18
This just updates alphaEnabled in the javascript c
Wez
2014/07/11 17:14:10
Acknowledged.
| |
| 406 } | |
| 407 | |
| 401 } // namespace apps | 408 } // namespace apps |
| OLD | NEW |