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

Side by Side Diff: apps/app_window.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
« no previous file with comments | « apps/app_window.h ('k') | apps/ui/views/native_app_window_views.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/app_window.h" 5 #include "apps/app_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "apps/app_window_geometry_cache.h" 9 #include "apps/app_window_geometry_cache.h"
10 #include "apps/app_window_registry.h" 10 #include "apps/app_window_registry.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void AppWindow::BoundsSpecification::ResetBounds() { 148 void AppWindow::BoundsSpecification::ResetBounds() {
149 bounds.SetRect(kUnspecifiedPosition, kUnspecifiedPosition, 0, 0); 149 bounds.SetRect(kUnspecifiedPosition, kUnspecifiedPosition, 0, 0);
150 } 150 }
151 151
152 // AppWindow::CreateParams 152 // AppWindow::CreateParams
153 153
154 AppWindow::CreateParams::CreateParams() 154 AppWindow::CreateParams::CreateParams()
155 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), 155 : window_type(AppWindow::WINDOW_TYPE_DEFAULT),
156 frame(AppWindow::FRAME_CHROME), 156 frame(AppWindow::FRAME_CHROME),
157 has_frame_color(false), 157 has_frame_color(false),
158 transparent_background(false), 158 alpha_enabled(false),
159 creator_process_id(0), 159 creator_process_id(0),
160 state(ui::SHOW_STATE_DEFAULT), 160 state(ui::SHOW_STATE_DEFAULT),
161 hidden(false), 161 hidden(false),
162 resizable(true), 162 resizable(true),
163 focused(true), 163 focused(true),
164 always_on_top(false) {} 164 always_on_top(false) {
garykac 2014/05/08 03:46:36 required by git cl format
165 }
165 166
166 AppWindow::CreateParams::~CreateParams() {} 167 AppWindow::CreateParams::~CreateParams() {}
167 168
168 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( 169 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds(
169 const gfx::Insets& frame_insets) const { 170 const gfx::Insets& frame_insets) const {
170 // Combine into a single window bounds. 171 // Combine into a single window bounds.
171 gfx::Rect combined_bounds(window_spec.bounds); 172 gfx::Rect combined_bounds(window_spec.bounds);
172 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) 173 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition)
173 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); 174 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left());
174 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) 175 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 Delegate* delegate, 232 Delegate* delegate,
232 const extensions::Extension* extension) 233 const extensions::Extension* extension)
233 : browser_context_(context), 234 : browser_context_(context),
234 extension_id_(extension->id()), 235 extension_id_(extension->id()),
235 window_type_(WINDOW_TYPE_DEFAULT), 236 window_type_(WINDOW_TYPE_DEFAULT),
236 delegate_(delegate), 237 delegate_(delegate),
237 image_loader_ptr_factory_(this), 238 image_loader_ptr_factory_(this),
238 fullscreen_types_(FULLSCREEN_TYPE_NONE), 239 fullscreen_types_(FULLSCREEN_TYPE_NONE),
239 show_on_first_paint_(false), 240 show_on_first_paint_(false),
240 first_paint_complete_(false), 241 first_paint_complete_(false),
241 cached_always_on_top_(false) { 242 cached_always_on_top_(false),
243 cached_alpha_enabled_(false) {
242 extensions::ExtensionsBrowserClient* client = 244 extensions::ExtensionsBrowserClient* client =
243 extensions::ExtensionsBrowserClient::Get(); 245 extensions::ExtensionsBrowserClient::Get();
244 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) 246 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
245 << "Only off the record window may be opened in the guest mode."; 247 << "Only off the record window may be opened in the guest mode.";
246 } 248 }
247 249
248 void AppWindow::Init(const GURL& url, 250 void AppWindow::Init(const GURL& url,
249 AppWindowContents* app_window_contents, 251 AppWindowContents* app_window_contents,
250 const CreateParams& params) { 252 const CreateParams& params) {
251 // Initialize the render interface and web contents 253 // Initialize the render interface and web contents
(...skipping 18 matching lines...) Expand all
270 // Initialize the window 272 // Initialize the window
271 CreateParams new_params = LoadDefaults(params); 273 CreateParams new_params = LoadDefaults(params);
272 window_type_ = new_params.window_type; 274 window_type_ = new_params.window_type;
273 window_key_ = new_params.window_key; 275 window_key_ = new_params.window_key;
274 276
275 // Windows cannot be always-on-top in fullscreen mode for security reasons. 277 // Windows cannot be always-on-top in fullscreen mode for security reasons.
276 cached_always_on_top_ = new_params.always_on_top; 278 cached_always_on_top_ = new_params.always_on_top;
277 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) 279 if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
278 new_params.always_on_top = false; 280 new_params.always_on_top = false;
279 281
282 cached_alpha_enabled_ = new_params.alpha_enabled;
283
280 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params)); 284 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params));
281 285
282 if (!new_params.hidden) { 286 if (!new_params.hidden) {
283 // Panels are not activated by default. 287 // Panels are not activated by default.
284 Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE 288 Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE
285 : SHOW_ACTIVE); 289 : SHOW_ACTIVE);
286 #if defined(OS_CHROMEOS) 290 #if defined(OS_CHROMEOS)
287 } else { 291 } else {
288 // Although the window starts hidden by default, calling Hide() here 292 // Although the window starts hidden by default, calling Hide() here
289 // notifies observers of the window being hidden. 293 // notifies observers of the window being hidden.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 // overlap the taskbar to be on top. The property will be applied when the 729 // overlap the taskbar to be on top. The property will be applied when the
726 // window exits fullscreen and moves away from the taskbar. 730 // window exits fullscreen and moves away from the taskbar.
727 if (!IsFullscreen(fullscreen_types_) && !IntersectsWithTaskbar()) 731 if (!IsFullscreen(fullscreen_types_) && !IntersectsWithTaskbar())
728 native_app_window_->SetAlwaysOnTop(always_on_top); 732 native_app_window_->SetAlwaysOnTop(always_on_top);
729 733
730 OnNativeWindowChanged(); 734 OnNativeWindowChanged();
731 } 735 }
732 736
733 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } 737 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; }
734 738
739 bool AppWindow::AlphaEnabled() const {
740 return cached_alpha_enabled_;
741 }
742
735 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { 743 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const {
736 DCHECK(properties); 744 DCHECK(properties);
737 745
738 properties->SetBoolean("fullscreen", 746 properties->SetBoolean("fullscreen",
739 native_app_window_->IsFullscreenOrPending()); 747 native_app_window_->IsFullscreenOrPending());
740 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); 748 properties->SetBoolean("minimized", native_app_window_->IsMinimized());
741 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); 749 properties->SetBoolean("maximized", native_app_window_->IsMaximized());
742 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); 750 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop());
751 properties->SetBoolean("alphaEnabled", AlphaEnabled());
743 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); 752 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor());
744 753
745 // These properties are undocumented and are to enable testing. Alpha is 754 // These properties are undocumented and are to enable testing. Alpha is
746 // removed to 755 // removed to
747 // make the values easier to check. 756 // make the values easier to check.
748 SkColor transparent_white = ~SK_ColorBLACK; 757 SkColor transparent_white = ~SK_ColorBLACK;
749 properties->SetInteger( 758 properties->SetInteger(
750 "activeFrameColor", 759 "activeFrameColor",
751 native_app_window_->ActiveFrameColor() & transparent_white); 760 native_app_window_->ActiveFrameColor() & transparent_white);
752 properties->SetInteger( 761 properties->SetInteger(
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 region.bounds.x(), 1132 region.bounds.x(),
1124 region.bounds.y(), 1133 region.bounds.y(),
1125 region.bounds.right(), 1134 region.bounds.right(),
1126 region.bounds.bottom(), 1135 region.bounds.bottom(),
1127 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1136 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1128 } 1137 }
1129 return sk_region; 1138 return sk_region;
1130 } 1139 }
1131 1140
1132 } // namespace apps 1141 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_window.h ('k') | apps/ui/views/native_app_window_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698