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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
| 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 Loading... |
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 Loading... |
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 // Although the window starts hidden by default, calling Hide() here | 287 // Although the window starts hidden by default, calling Hide() here |
284 // notifies observers of the window being hidden. | 288 // notifies observers of the window being hidden. |
285 Hide(); | 289 Hide(); |
286 } else { | 290 } else { |
287 // Panels are not activated by default. | 291 // Panels are not activated by default. |
288 Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE | 292 Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE |
289 : SHOW_ACTIVE); | 293 : SHOW_ACTIVE); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 // overlap the taskbar to be on top. The property will be applied when the | 723 // overlap the taskbar to be on top. The property will be applied when the |
720 // window exits fullscreen and moves away from the taskbar. | 724 // window exits fullscreen and moves away from the taskbar. |
721 if (!IsFullscreen(fullscreen_types_) && !IntersectsWithTaskbar()) | 725 if (!IsFullscreen(fullscreen_types_) && !IntersectsWithTaskbar()) |
722 native_app_window_->SetAlwaysOnTop(always_on_top); | 726 native_app_window_->SetAlwaysOnTop(always_on_top); |
723 | 727 |
724 OnNativeWindowChanged(); | 728 OnNativeWindowChanged(); |
725 } | 729 } |
726 | 730 |
727 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } | 731 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } |
728 | 732 |
| 733 bool AppWindow::AlphaEnabled() const { |
| 734 return cached_alpha_enabled_; |
| 735 } |
| 736 |
729 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 737 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
730 DCHECK(properties); | 738 DCHECK(properties); |
731 | 739 |
732 properties->SetBoolean("fullscreen", | 740 properties->SetBoolean("fullscreen", |
733 native_app_window_->IsFullscreenOrPending()); | 741 native_app_window_->IsFullscreenOrPending()); |
734 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); | 742 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); |
735 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); | 743 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); |
736 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); | 744 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); |
| 745 properties->SetBoolean("alphaEnabled", AlphaEnabled()); |
737 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); | 746 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); |
738 | 747 |
739 // These properties are undocumented and are to enable testing. Alpha is | 748 // These properties are undocumented and are to enable testing. Alpha is |
740 // removed to | 749 // removed to |
741 // make the values easier to check. | 750 // make the values easier to check. |
742 SkColor transparent_white = ~SK_ColorBLACK; | 751 SkColor transparent_white = ~SK_ColorBLACK; |
743 properties->SetInteger( | 752 properties->SetInteger( |
744 "activeFrameColor", | 753 "activeFrameColor", |
745 native_app_window_->ActiveFrameColor() & transparent_white); | 754 native_app_window_->ActiveFrameColor() & transparent_white); |
746 properties->SetInteger( | 755 properties->SetInteger( |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 region.bounds.x(), | 1126 region.bounds.x(), |
1118 region.bounds.y(), | 1127 region.bounds.y(), |
1119 region.bounds.right(), | 1128 region.bounds.right(), |
1120 region.bounds.bottom(), | 1129 region.bounds.bottom(), |
1121 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1130 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
1122 } | 1131 } |
1123 return sk_region; | 1132 return sk_region; |
1124 } | 1133 } |
1125 | 1134 |
1126 } // namespace apps | 1135 } // namespace apps |
OLD | NEW |