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 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 153 } |
154 | 154 |
155 // AppWindow::CreateParams | 155 // AppWindow::CreateParams |
156 | 156 |
157 AppWindow::CreateParams::CreateParams() | 157 AppWindow::CreateParams::CreateParams() |
158 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), | 158 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), |
159 frame(AppWindow::FRAME_CHROME), | 159 frame(AppWindow::FRAME_CHROME), |
160 has_frame_color(false), | 160 has_frame_color(false), |
161 active_frame_color(SK_ColorBLACK), | 161 active_frame_color(SK_ColorBLACK), |
162 inactive_frame_color(SK_ColorBLACK), | 162 inactive_frame_color(SK_ColorBLACK), |
163 transparent_background(false), | 163 alpha_enabled(false), |
164 creator_process_id(0), | 164 creator_process_id(0), |
165 state(ui::SHOW_STATE_DEFAULT), | 165 state(ui::SHOW_STATE_DEFAULT), |
166 hidden(false), | 166 hidden(false), |
167 resizable(true), | 167 resizable(true), |
168 focused(true), | 168 focused(true), |
169 always_on_top(false) {} | 169 always_on_top(false) { |
| 170 } |
170 | 171 |
171 AppWindow::CreateParams::~CreateParams() {} | 172 AppWindow::CreateParams::~CreateParams() {} |
172 | 173 |
173 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( | 174 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( |
174 const gfx::Insets& frame_insets) const { | 175 const gfx::Insets& frame_insets) const { |
175 // Combine into a single window bounds. | 176 // Combine into a single window bounds. |
176 gfx::Rect combined_bounds(window_spec.bounds); | 177 gfx::Rect combined_bounds(window_spec.bounds); |
177 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) | 178 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) |
178 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); | 179 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); |
179 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) | 180 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 window_type_(WINDOW_TYPE_DEFAULT), | 237 window_type_(WINDOW_TYPE_DEFAULT), |
237 app_delegate_(app_delegate), | 238 app_delegate_(app_delegate), |
238 image_loader_ptr_factory_(this), | 239 image_loader_ptr_factory_(this), |
239 fullscreen_types_(FULLSCREEN_TYPE_NONE), | 240 fullscreen_types_(FULLSCREEN_TYPE_NONE), |
240 show_on_first_paint_(false), | 241 show_on_first_paint_(false), |
241 first_paint_complete_(false), | 242 first_paint_complete_(false), |
242 has_been_shown_(false), | 243 has_been_shown_(false), |
243 can_send_events_(false), | 244 can_send_events_(false), |
244 is_hidden_(false), | 245 is_hidden_(false), |
245 cached_always_on_top_(false), | 246 cached_always_on_top_(false), |
246 requested_transparent_background_(false) { | 247 requested_alpha_enabled_(false) { |
247 extensions::ExtensionsBrowserClient* client = | 248 extensions::ExtensionsBrowserClient* client = |
248 extensions::ExtensionsBrowserClient::Get(); | 249 extensions::ExtensionsBrowserClient::Get(); |
249 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) | 250 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) |
250 << "Only off the record window may be opened in the guest mode."; | 251 << "Only off the record window may be opened in the guest mode."; |
251 } | 252 } |
252 | 253 |
253 void AppWindow::Init(const GURL& url, | 254 void AppWindow::Init(const GURL& url, |
254 AppWindowContents* app_window_contents, | 255 AppWindowContents* app_window_contents, |
255 const CreateParams& params) { | 256 const CreateParams& params) { |
256 // Initialize the render interface and web contents | 257 // Initialize the render interface and web contents |
(...skipping 19 matching lines...) Expand all Loading... |
276 // Initialize the window | 277 // Initialize the window |
277 CreateParams new_params = LoadDefaults(params); | 278 CreateParams new_params = LoadDefaults(params); |
278 window_type_ = new_params.window_type; | 279 window_type_ = new_params.window_type; |
279 window_key_ = new_params.window_key; | 280 window_key_ = new_params.window_key; |
280 | 281 |
281 // Windows cannot be always-on-top in fullscreen mode for security reasons. | 282 // Windows cannot be always-on-top in fullscreen mode for security reasons. |
282 cached_always_on_top_ = new_params.always_on_top; | 283 cached_always_on_top_ = new_params.always_on_top; |
283 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) | 284 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) |
284 new_params.always_on_top = false; | 285 new_params.always_on_top = false; |
285 | 286 |
286 requested_transparent_background_ = new_params.transparent_background; | 287 requested_alpha_enabled_ = new_params.alpha_enabled; |
287 | 288 |
288 AppsClient* apps_client = AppsClient::Get(); | 289 AppsClient* apps_client = AppsClient::Get(); |
289 native_app_window_.reset( | 290 native_app_window_.reset( |
290 apps_client->CreateNativeAppWindow(this, new_params)); | 291 apps_client->CreateNativeAppWindow(this, new_params)); |
291 | 292 |
292 helper_.reset(new AppWebContentsHelper( | 293 helper_.reset(new AppWebContentsHelper( |
293 browser_context_, extension_id_, web_contents, app_delegate_.get())); | 294 browser_context_, extension_id_, web_contents, app_delegate_.get())); |
294 | 295 |
295 popup_manager_.reset( | 296 popup_manager_.reset( |
296 new web_modal::PopupManager(GetWebContentsModalDialogHost())); | 297 new web_modal::PopupManager(GetWebContentsModalDialogHost())); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 725 |
725 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 726 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
726 DCHECK(properties); | 727 DCHECK(properties); |
727 | 728 |
728 properties->SetBoolean("fullscreen", | 729 properties->SetBoolean("fullscreen", |
729 native_app_window_->IsFullscreenOrPending()); | 730 native_app_window_->IsFullscreenOrPending()); |
730 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); | 731 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); |
731 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); | 732 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); |
732 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); | 733 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); |
733 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); | 734 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); |
734 properties->SetBoolean("alphaEnabled", | 735 properties->SetBoolean( |
735 requested_transparent_background_ && | 736 "alphaEnabled", |
736 native_app_window_->CanHaveAlphaEnabled()); | 737 requested_alpha_enabled_ && native_app_window_->CanHaveAlphaEnabled()); |
737 | 738 |
738 // These properties are undocumented and are to enable testing. Alpha is | 739 // These properties are undocumented and are to enable testing. Alpha is |
739 // removed to | 740 // removed to |
740 // make the values easier to check. | 741 // make the values easier to check. |
741 SkColor transparent_white = ~SK_ColorBLACK; | 742 SkColor transparent_white = ~SK_ColorBLACK; |
742 properties->SetInteger( | 743 properties->SetInteger( |
743 "activeFrameColor", | 744 "activeFrameColor", |
744 native_app_window_->ActiveFrameColor() & transparent_white); | 745 native_app_window_->ActiveFrameColor() & transparent_white); |
745 properties->SetInteger( | 746 properties->SetInteger( |
746 "inactiveFrameColor", | 747 "inactiveFrameColor", |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 region.bounds.x(), | 1103 region.bounds.x(), |
1103 region.bounds.y(), | 1104 region.bounds.y(), |
1104 region.bounds.right(), | 1105 region.bounds.right(), |
1105 region.bounds.bottom(), | 1106 region.bounds.bottom(), |
1106 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1107 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
1107 } | 1108 } |
1108 return sk_region; | 1109 return sk_region; |
1109 } | 1110 } |
1110 | 1111 |
1111 } // namespace apps | 1112 } // namespace apps |
OLD | NEW |