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/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 Loading... |
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 Loading... |
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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 747 |
745 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 748 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
746 DCHECK(properties); | 749 DCHECK(properties); |
747 | 750 |
748 properties->SetBoolean("fullscreen", | 751 properties->SetBoolean("fullscreen", |
749 native_app_window_->IsFullscreenOrPending()); | 752 native_app_window_->IsFullscreenOrPending()); |
750 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); | 753 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); |
751 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); | 754 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); |
752 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); | 755 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); |
753 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); | 756 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); |
| 757 properties->SetBoolean("alphaEnabled", |
| 758 requested_transparent_background_ && |
| 759 native_app_window_->CanHaveAlphaEnabled()); |
754 | 760 |
755 // These properties are undocumented and are to enable testing. Alpha is | 761 // These properties are undocumented and are to enable testing. Alpha is |
756 // removed to | 762 // removed to |
757 // make the values easier to check. | 763 // make the values easier to check. |
758 SkColor transparent_white = ~SK_ColorBLACK; | 764 SkColor transparent_white = ~SK_ColorBLACK; |
759 properties->SetInteger( | 765 properties->SetInteger( |
760 "activeFrameColor", | 766 "activeFrameColor", |
761 native_app_window_->ActiveFrameColor() & transparent_white); | 767 native_app_window_->ActiveFrameColor() & transparent_white); |
762 properties->SetInteger( | 768 properties->SetInteger( |
763 "inactiveFrameColor", | 769 "inactiveFrameColor", |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 region.bounds.x(), | 1148 region.bounds.x(), |
1143 region.bounds.y(), | 1149 region.bounds.y(), |
1144 region.bounds.right(), | 1150 region.bounds.right(), |
1145 region.bounds.bottom(), | 1151 region.bounds.bottom(), |
1146 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1152 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
1147 } | 1153 } |
1148 return sk_region; | 1154 return sk_region; |
1149 } | 1155 } |
1150 | 1156 |
1151 } // namespace apps | 1157 } // namespace apps |
OLD | NEW |