Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: apps/ui/views/native_app_window_views.cc

Issue 190533006: Add support for transparent background API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename transparentBackground to alphaEnabled Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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), 30 alpha_enabled_(false),
31 resizable_(false) {} 31 resizable_(false) {
32 }
32 33
33 void NativeAppWindowViews::Init(AppWindow* app_window, 34 void NativeAppWindowViews::Init(AppWindow* app_window,
34 const AppWindow::CreateParams& create_params) { 35 const AppWindow::CreateParams& create_params) {
35 app_window_ = app_window; 36 app_window_ = app_window;
36 frameless_ = create_params.frame == AppWindow::FRAME_NONE; 37 frameless_ = create_params.frame == AppWindow::FRAME_NONE;
37 transparent_background_ = create_params.transparent_background; 38 alpha_enabled_ = create_params.alpha_enabled;
38 resizable_ = create_params.resizable; 39 resizable_ = create_params.resizable;
39 size_constraints_.set_minimum_size( 40 size_constraints_.set_minimum_size(
40 create_params.GetContentMinimumSize(gfx::Insets())); 41 create_params.GetContentMinimumSize(gfx::Insets()));
41 size_constraints_.set_maximum_size( 42 size_constraints_.set_maximum_size(
42 create_params.GetContentMaximumSize(gfx::Insets())); 43 create_params.GetContentMaximumSize(gfx::Insets()));
43 Observe(app_window_->web_contents()); 44 Observe(app_window_->web_contents());
44 45
45 widget_ = new views::Widget; 46 widget_ = new views::Widget;
46 InitializeWindow(app_window, create_params); 47 InitializeWindow(app_window, create_params);
47 48
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 bool active) { 255 bool active) {
255 app_window_->OnNativeWindowChanged(); 256 app_window_->OnNativeWindowChanged();
256 if (active) 257 if (active)
257 app_window_->OnNativeWindowActivated(); 258 app_window_->OnNativeWindowActivated();
258 } 259 }
259 260
260 // WebContentsObserver implementation. 261 // WebContentsObserver implementation.
261 262
262 void NativeAppWindowViews::RenderViewCreated( 263 void NativeAppWindowViews::RenderViewCreated(
263 content::RenderViewHost* render_view_host) { 264 content::RenderViewHost* render_view_host) {
264 if (transparent_background_) { 265 if (alpha_enabled_) {
265 // Use a background with transparency to trigger transparency in Webkit. 266 // Use a background with transparency to trigger transparency in Webkit.
266 SkBitmap background; 267 SkBitmap background;
267 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); 268 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
268 background.allocPixels(); 269 background.allocPixels();
269 background.eraseARGB(0x00, 0x00, 0x00, 0x00); 270 background.eraseARGB(0x00, 0x00, 0x00, 0x00);
270 271
271 content::RenderWidgetHostView* view = render_view_host->GetView(); 272 content::RenderWidgetHostView* view = render_view_host->GetView();
272 DCHECK(view); 273 DCHECK(view);
273 view->SetBackground(background); 274 view->SetBackground(background);
274 } 275 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return size_constraints_.GetMaximumSize(); 400 return size_constraints_.GetMaximumSize();
400 } 401 }
401 402
402 void NativeAppWindowViews::SetContentSizeConstraints( 403 void NativeAppWindowViews::SetContentSizeConstraints(
403 const gfx::Size& min_size, const gfx::Size& max_size) { 404 const gfx::Size& min_size, const gfx::Size& max_size) {
404 size_constraints_.set_minimum_size(min_size); 405 size_constraints_.set_minimum_size(min_size);
405 size_constraints_.set_maximum_size(max_size); 406 size_constraints_.set_maximum_size(max_size);
406 } 407 }
407 408
408 } // namespace apps 409 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698