| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 // AppWindow::CreateParams | 154 // AppWindow::CreateParams |
| 155 | 155 |
| 156 AppWindow::CreateParams::CreateParams() | 156 AppWindow::CreateParams::CreateParams() |
| 157 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), | 157 : window_type(AppWindow::WINDOW_TYPE_DEFAULT), |
| 158 frame(AppWindow::FRAME_CHROME), | 158 frame(AppWindow::FRAME_CHROME), |
| 159 has_frame_color(false), | 159 has_frame_color(false), |
| 160 active_frame_color(SK_ColorBLACK), | 160 active_frame_color(SK_ColorBLACK), |
| 161 inactive_frame_color(SK_ColorBLACK), | 161 inactive_frame_color(SK_ColorBLACK), |
| 162 transparent_background(false), | 162 alpha_enabled(false), |
| 163 creator_process_id(0), | 163 creator_process_id(0), |
| 164 state(ui::SHOW_STATE_DEFAULT), | 164 state(ui::SHOW_STATE_DEFAULT), |
| 165 hidden(false), | 165 hidden(false), |
| 166 resizable(true), | 166 resizable(true), |
| 167 focused(true), | 167 focused(true), |
| 168 always_on_top(false) {} | 168 always_on_top(false) { |
| 169 } |
| 169 | 170 |
| 170 AppWindow::CreateParams::~CreateParams() {} | 171 AppWindow::CreateParams::~CreateParams() {} |
| 171 | 172 |
| 172 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( | 173 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( |
| 173 const gfx::Insets& frame_insets) const { | 174 const gfx::Insets& frame_insets) const { |
| 174 // Combine into a single window bounds. | 175 // Combine into a single window bounds. |
| 175 gfx::Rect combined_bounds(window_spec.bounds); | 176 gfx::Rect combined_bounds(window_spec.bounds); |
| 176 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) | 177 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) |
| 177 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); | 178 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); |
| 178 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) | 179 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 app_delegate_(app_delegate), | 242 app_delegate_(app_delegate), |
| 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 | 770 |
| 770 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 771 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
| 771 DCHECK(properties); | 772 DCHECK(properties); |
| 772 | 773 |
| 773 properties->SetBoolean("fullscreen", | 774 properties->SetBoolean("fullscreen", |
| 774 native_app_window_->IsFullscreenOrPending()); | 775 native_app_window_->IsFullscreenOrPending()); |
| 775 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); | 776 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); |
| 776 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); | 777 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); |
| 777 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); | 778 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); |
| 778 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); | 779 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); |
| 779 properties->SetBoolean("alphaEnabled", | 780 properties->SetBoolean( |
| 780 requested_transparent_background_ && | 781 "alphaEnabled", |
| 781 native_app_window_->CanHaveAlphaEnabled()); | 782 requested_alpha_enabled_ && native_app_window_->CanHaveAlphaEnabled()); |
| 782 | 783 |
| 783 // These properties are undocumented and are to enable testing. Alpha is | 784 // These properties are undocumented and are to enable testing. Alpha is |
| 784 // removed to | 785 // removed to |
| 785 // make the values easier to check. | 786 // make the values easier to check. |
| 786 SkColor transparent_white = ~SK_ColorBLACK; | 787 SkColor transparent_white = ~SK_ColorBLACK; |
| 787 properties->SetInteger( | 788 properties->SetInteger( |
| 788 "activeFrameColor", | 789 "activeFrameColor", |
| 789 native_app_window_->ActiveFrameColor() & transparent_white); | 790 native_app_window_->ActiveFrameColor() & transparent_white); |
| 790 properties->SetInteger( | 791 properties->SetInteger( |
| 791 "inactiveFrameColor", | 792 "inactiveFrameColor", |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 region.bounds.x(), | 1155 region.bounds.x(), |
| 1155 region.bounds.y(), | 1156 region.bounds.y(), |
| 1156 region.bounds.right(), | 1157 region.bounds.right(), |
| 1157 region.bounds.bottom(), | 1158 region.bounds.bottom(), |
| 1158 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1159 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1159 } | 1160 } |
| 1160 return sk_region; | 1161 return sk_region; |
| 1161 } | 1162 } |
| 1162 | 1163 |
| 1163 } // namespace apps | 1164 } // namespace apps |
| OLD | NEW |