| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 // AppWindow::CreateParams | 156 // AppWindow::CreateParams |
| 157 | 157 |
| 158 AppWindow::CreateParams::CreateParams() | 158 AppWindow::CreateParams::CreateParams() |
| 159 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), | 159 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), |
| 160 frame(AppWindow::FRAME_CHROME), | 160 frame(AppWindow::FRAME_CHROME), |
| 161 has_frame_color(false), | 161 has_frame_color(false), |
| 162 active_frame_color(SK_ColorBLACK), | 162 active_frame_color(SK_ColorBLACK), |
| 163 inactive_frame_color(SK_ColorBLACK), | 163 inactive_frame_color(SK_ColorBLACK), |
| 164 transparent_background(false), | 164 alpha_enabled(false), |
| 165 creator_process_id(0), | 165 creator_process_id(0), |
| 166 state(ui::SHOW_STATE_DEFAULT), | 166 state(ui::SHOW_STATE_DEFAULT), |
| 167 hidden(false), | 167 hidden(false), |
| 168 resizable(true), | 168 resizable(true), |
| 169 focused(true), | 169 focused(true), |
| 170 always_on_top(false) {} | 170 always_on_top(false) { |
| 171 } |
| 171 | 172 |
| 172 AppWindow::CreateParams::~CreateParams() {} | 173 AppWindow::CreateParams::~CreateParams() {} |
| 173 | 174 |
| 174 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( | 175 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( |
| 175 const gfx::Insets& frame_insets) const { | 176 const gfx::Insets& frame_insets) const { |
| 176 // Combine into a single window bounds. | 177 // Combine into a single window bounds. |
| 177 gfx::Rect combined_bounds(window_spec.bounds); | 178 gfx::Rect combined_bounds(window_spec.bounds); |
| 178 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) | 179 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) |
| 179 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); | 180 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); |
| 180 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) | 181 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 window_type_(WINDOW_TYPE_DEFAULT), | 242 window_type_(WINDOW_TYPE_DEFAULT), |
| 242 delegate_(delegate), | 243 delegate_(delegate), |
| 243 image_loader_ptr_factory_(this), | 244 image_loader_ptr_factory_(this), |
| 244 fullscreen_types_(FULLSCREEN_TYPE_NONE), | 245 fullscreen_types_(FULLSCREEN_TYPE_NONE), |
| 245 show_on_first_paint_(false), | 246 show_on_first_paint_(false), |
| 246 first_paint_complete_(false), | 247 first_paint_complete_(false), |
| 247 has_been_shown_(false), | 248 has_been_shown_(false), |
| 248 can_send_events_(false), | 249 can_send_events_(false), |
| 249 is_hidden_(false), | 250 is_hidden_(false), |
| 250 cached_always_on_top_(false), | 251 cached_always_on_top_(false), |
| 251 requested_transparent_background_(false) { | 252 requested_alpha_enabled_(false) { |
| 252 extensions::ExtensionsBrowserClient* client = | 253 extensions::ExtensionsBrowserClient* client = |
| 253 extensions::ExtensionsBrowserClient::Get(); | 254 extensions::ExtensionsBrowserClient::Get(); |
| 254 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) | 255 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) |
| 255 << "Only off the record window may be opened in the guest mode."; | 256 << "Only off the record window may be opened in the guest mode."; |
| 256 } | 257 } |
| 257 | 258 |
| 258 void AppWindow::Init(const GURL& url, | 259 void AppWindow::Init(const GURL& url, |
| 259 AppWindowContents* app_window_contents, | 260 AppWindowContents* app_window_contents, |
| 260 const CreateParams& params) { | 261 const CreateParams& params) { |
| 261 // Initialize the render interface and web contents | 262 // Initialize the render interface and web contents |
| (...skipping 19 matching lines...) Expand all Loading... |
| 281 // Initialize the window | 282 // Initialize the window |
| 282 CreateParams new_params = LoadDefaults(params); | 283 CreateParams new_params = LoadDefaults(params); |
| 283 window_type_ = new_params.window_type; | 284 window_type_ = new_params.window_type; |
| 284 window_key_ = new_params.window_key; | 285 window_key_ = new_params.window_key; |
| 285 | 286 |
| 286 // Windows cannot be always-on-top in fullscreen mode for security reasons. | 287 // Windows cannot be always-on-top in fullscreen mode for security reasons. |
| 287 cached_always_on_top_ = new_params.always_on_top; | 288 cached_always_on_top_ = new_params.always_on_top; |
| 288 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) | 289 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) |
| 289 new_params.always_on_top = false; | 290 new_params.always_on_top = false; |
| 290 | 291 |
| 291 requested_transparent_background_ = new_params.transparent_background; | 292 requested_alpha_enabled_ = new_params.alpha_enabled; |
| 292 | 293 |
| 293 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params)); | 294 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params)); |
| 294 | 295 |
| 295 popup_manager_.reset( | 296 popup_manager_.reset( |
| 296 new web_modal::PopupManager(GetWebContentsModalDialogHost())); | 297 new web_modal::PopupManager(GetWebContentsModalDialogHost())); |
| 297 popup_manager_->RegisterWith(web_contents); | 298 popup_manager_->RegisterWith(web_contents); |
| 298 | 299 |
| 299 // Prevent the browser process from shutting down while this window exists. | 300 // Prevent the browser process from shutting down while this window exists. |
| 300 AppsClient::Get()->IncrementKeepAliveCount(); | 301 AppsClient::Get()->IncrementKeepAliveCount(); |
| 301 UpdateExtensionAppIcon(); | 302 UpdateExtensionAppIcon(); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 | 755 |
| 755 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 756 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
| 756 DCHECK(properties); | 757 DCHECK(properties); |
| 757 | 758 |
| 758 properties->SetBoolean("fullscreen", | 759 properties->SetBoolean("fullscreen", |
| 759 native_app_window_->IsFullscreenOrPending()); | 760 native_app_window_->IsFullscreenOrPending()); |
| 760 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); | 761 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); |
| 761 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); | 762 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); |
| 762 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); | 763 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); |
| 763 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); | 764 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); |
| 764 properties->SetBoolean("alphaEnabled", | 765 properties->SetBoolean( |
| 765 requested_transparent_background_ && | 766 "alphaEnabled", |
| 766 native_app_window_->CanHaveAlphaEnabled()); | 767 requested_alpha_enabled_ && native_app_window_->CanHaveAlphaEnabled()); |
| 767 | 768 |
| 768 // These properties are undocumented and are to enable testing. Alpha is | 769 // These properties are undocumented and are to enable testing. Alpha is |
| 769 // removed to | 770 // removed to |
| 770 // make the values easier to check. | 771 // make the values easier to check. |
| 771 SkColor transparent_white = ~SK_ColorBLACK; | 772 SkColor transparent_white = ~SK_ColorBLACK; |
| 772 properties->SetInteger( | 773 properties->SetInteger( |
| 773 "activeFrameColor", | 774 "activeFrameColor", |
| 774 native_app_window_->ActiveFrameColor() & transparent_white); | 775 native_app_window_->ActiveFrameColor() & transparent_white); |
| 775 properties->SetInteger( | 776 properties->SetInteger( |
| 776 "inactiveFrameColor", | 777 "inactiveFrameColor", |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 region.bounds.x(), | 1156 region.bounds.x(), |
| 1156 region.bounds.y(), | 1157 region.bounds.y(), |
| 1157 region.bounds.right(), | 1158 region.bounds.right(), |
| 1158 region.bounds.bottom(), | 1159 region.bounds.bottom(), |
| 1159 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1160 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1160 } | 1161 } |
| 1161 return sk_region; | 1162 return sk_region; |
| 1162 } | 1163 } |
| 1163 | 1164 |
| 1164 } // namespace apps | 1165 } // namespace apps |
| OLD | NEW |