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

Side by Side Diff: apps/app_window.cc

Issue 375183002: Add app.window.alphaEnabled() and onAlphaEnabledChanged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split out non-essential parts for another CL. Created 6 years, 5 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/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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 extension_id_(extension->id()), 238 extension_id_(extension->id()),
239 window_type_(WINDOW_TYPE_DEFAULT), 239 window_type_(WINDOW_TYPE_DEFAULT),
240 delegate_(delegate), 240 delegate_(delegate),
241 image_loader_ptr_factory_(this), 241 image_loader_ptr_factory_(this),
242 fullscreen_types_(FULLSCREEN_TYPE_NONE), 242 fullscreen_types_(FULLSCREEN_TYPE_NONE),
243 show_on_first_paint_(false), 243 show_on_first_paint_(false),
244 first_paint_complete_(false), 244 first_paint_complete_(false),
245 has_been_shown_(false), 245 has_been_shown_(false),
246 can_send_events_(false), 246 can_send_events_(false),
247 is_hidden_(false), 247 is_hidden_(false),
248 cached_always_on_top_(false) { 248 cached_always_on_top_(false),
249 requested_transparent_background_(false) {
249 extensions::ExtensionsBrowserClient* client = 250 extensions::ExtensionsBrowserClient* client =
250 extensions::ExtensionsBrowserClient::Get(); 251 extensions::ExtensionsBrowserClient::Get();
251 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) 252 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
252 << "Only off the record window may be opened in the guest mode."; 253 << "Only off the record window may be opened in the guest mode.";
253 } 254 }
254 255
255 void AppWindow::Init(const GURL& url, 256 void AppWindow::Init(const GURL& url,
256 AppWindowContents* app_window_contents, 257 AppWindowContents* app_window_contents,
257 const CreateParams& params) { 258 const CreateParams& params) {
258 // Initialize the render interface and web contents 259 // Initialize the render interface and web contents
(...skipping 18 matching lines...) Expand all
277 // Initialize the window 278 // Initialize the window
278 CreateParams new_params = LoadDefaults(params); 279 CreateParams new_params = LoadDefaults(params);
279 window_type_ = new_params.window_type; 280 window_type_ = new_params.window_type;
280 window_key_ = new_params.window_key; 281 window_key_ = new_params.window_key;
281 282
282 // Windows cannot be always-on-top in fullscreen mode for security reasons. 283 // Windows cannot be always-on-top in fullscreen mode for security reasons.
283 cached_always_on_top_ = new_params.always_on_top; 284 cached_always_on_top_ = new_params.always_on_top;
284 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) 285 if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
285 new_params.always_on_top = false; 286 new_params.always_on_top = false;
286 287
288 requested_transparent_background_ = new_params.transparent_background;
289
287 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params)); 290 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params));
288 291
289 // Prevent the browser process from shutting down while this window exists. 292 // Prevent the browser process from shutting down while this window exists.
290 AppsClient::Get()->IncrementKeepAliveCount(); 293 AppsClient::Get()->IncrementKeepAliveCount();
291 UpdateExtensionAppIcon(); 294 UpdateExtensionAppIcon();
292 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); 295 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this);
293 296
294 if (new_params.hidden) { 297 if (new_params.hidden) {
295 // Although the window starts hidden by default, calling Hide() here 298 // Although the window starts hidden by default, calling Hide() here
296 // notifies observers of the window being hidden. 299 // notifies observers of the window being hidden.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 OnNativeWindowChanged(); 738 OnNativeWindowChanged();
736 } 739 }
737 740
738 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } 741 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; }
739 742
740 void AppWindow::WindowEventsReady() { 743 void AppWindow::WindowEventsReady() {
741 can_send_events_ = true; 744 can_send_events_ = true;
742 SendOnWindowShownIfShown(); 745 SendOnWindowShownIfShown();
743 } 746 }
744 747
748 bool AppWindow::requested_transparent_background() const {
749 return requested_transparent_background_;
tapted 2014/07/16 03:01:01 nit: inline this in the header? (ignoring names, t
jackhou1 2014/07/16 05:54:04 Done.
750 }
751
745 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { 752 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const {
746 DCHECK(properties); 753 DCHECK(properties);
747 754
748 properties->SetBoolean("fullscreen", 755 properties->SetBoolean("fullscreen",
749 native_app_window_->IsFullscreenOrPending()); 756 native_app_window_->IsFullscreenOrPending());
750 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); 757 properties->SetBoolean("minimized", native_app_window_->IsMinimized());
751 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); 758 properties->SetBoolean("maximized", native_app_window_->IsMaximized());
752 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); 759 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop());
753 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); 760 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor());
761 properties->SetBoolean("alphaEnabled",
762 requested_transparent_background_ &&
763 native_app_window_->CanHaveAlphaEnabled());
754 764
755 // These properties are undocumented and are to enable testing. Alpha is 765 // These properties are undocumented and are to enable testing. Alpha is
756 // removed to 766 // removed to
757 // make the values easier to check. 767 // make the values easier to check.
758 SkColor transparent_white = ~SK_ColorBLACK; 768 SkColor transparent_white = ~SK_ColorBLACK;
759 properties->SetInteger( 769 properties->SetInteger(
760 "activeFrameColor", 770 "activeFrameColor",
761 native_app_window_->ActiveFrameColor() & transparent_white); 771 native_app_window_->ActiveFrameColor() & transparent_white);
762 properties->SetInteger( 772 properties->SetInteger(
763 "inactiveFrameColor", 773 "inactiveFrameColor",
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 region.bounds.x(), 1152 region.bounds.x(),
1143 region.bounds.y(), 1153 region.bounds.y(),
1144 region.bounds.right(), 1154 region.bounds.right(),
1145 region.bounds.bottom(), 1155 region.bounds.bottom(),
1146 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1156 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1147 } 1157 }
1148 return sk_region; 1158 return sk_region;
1149 } 1159 }
1150 1160
1151 } // namespace apps 1161 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698