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() && CanHaveAlphaEnabled()) { |
| 264 content::RenderWidgetHostView* view = render_view_host->GetView(); | 262 content::RenderWidgetHostView* view = render_view_host->GetView(); |
| 265 DCHECK(view); | 263 DCHECK(view); |
| 266 view->SetBackgroundOpaque(false); | 264 view->SetBackgroundOpaque(false); |
| 267 } | 265 } |
| 268 } | 266 } |
| 269 | 267 |
| 270 void NativeAppWindowViews::RenderViewHostChanged( | 268 void NativeAppWindowViews::RenderViewHostChanged( |
| 271 content::RenderViewHost* old_host, | 269 content::RenderViewHost* old_host, |
| 272 content::RenderViewHost* new_host) { | 270 content::RenderViewHost* new_host) { |
| 273 OnViewWasResized(); | 271 OnViewWasResized(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 gfx::Size NativeAppWindowViews::GetContentMaximumSize() const { | 389 gfx::Size NativeAppWindowViews::GetContentMaximumSize() const { |
| 392 return size_constraints_.GetMaximumSize(); | 390 return size_constraints_.GetMaximumSize(); |
| 393 } | 391 } |
| 394 | 392 |
| 395 void NativeAppWindowViews::SetContentSizeConstraints( | 393 void NativeAppWindowViews::SetContentSizeConstraints( |
| 396 const gfx::Size& min_size, const gfx::Size& max_size) { | 394 const gfx::Size& min_size, const gfx::Size& max_size) { |
| 397 size_constraints_.set_minimum_size(min_size); | 395 size_constraints_.set_minimum_size(min_size); |
| 398 size_constraints_.set_maximum_size(max_size); | 396 size_constraints_.set_maximum_size(max_size); |
| 399 } | 397 } |
| 400 | 398 |
| 399 bool NativeAppWindowViews::CanHaveAlphaEnabled() const { | |
| 400 return true; | |
|
tapted
2014/07/14 03:30:24
does this work fine on desktop-linux as well as Ch
jackhou1
2014/07/14 04:51:02
This doesn't work on Linux.
I think this logic s
| |
| 401 } | |
| 402 | |
| 403 void NativeAppWindowViews::CanHaveAlphaEnabledChanged() { | |
| 404 app_window_->OnNativeWindowChanged(); | |
| 405 } | |
| 406 | |
| 401 } // namespace apps | 407 } // namespace apps |
| OLD | NEW |