| 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 |
| 11 #include "apps/app_delegate.h" | 11 #include "apps/app_delegate.h" |
| 12 #include "apps/app_web_contents_helper.h" | 12 #include "apps/app_web_contents_helper.h" |
| 13 #include "apps/app_window_geometry_cache.h" | 13 #include "apps/app_window_geometry_cache.h" |
| 14 #include "apps/app_window_registry.h" | 14 #include "apps/app_window_registry.h" |
| 15 #include "apps/apps_client.h" | |
| 16 #include "apps/size_constraints.h" | 15 #include "apps/size_constraints.h" |
| 16 #include "apps/ui/apps_client.h" |
| 17 #include "apps/ui/native_app_window.h" | 17 #include "apps/ui/native_app_window.h" |
| 18 #include "apps/ui/web_contents_sizer.h" | 18 #include "apps/ui/web_contents_sizer.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 24 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 24 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 25 #include "chrome/browser/extensions/suggest_permission_util.h" | 25 #include "chrome/browser/extensions/suggest_permission_util.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 frame_insets); | 219 frame_insets); |
| 220 } | 220 } |
| 221 | 221 |
| 222 gfx::Size AppWindow::CreateParams::GetWindowMaximumSize( | 222 gfx::Size AppWindow::CreateParams::GetWindowMaximumSize( |
| 223 const gfx::Insets& frame_insets) const { | 223 const gfx::Insets& frame_insets) const { |
| 224 return GetCombinedWindowConstraints(window_spec.maximum_size, | 224 return GetCombinedWindowConstraints(window_spec.maximum_size, |
| 225 content_spec.maximum_size, | 225 content_spec.maximum_size, |
| 226 frame_insets); | 226 frame_insets); |
| 227 } | 227 } |
| 228 | 228 |
| 229 // AppWindow::Delegate | |
| 230 | |
| 231 AppWindow::Delegate::~Delegate() {} | |
| 232 | |
| 233 // AppWindow | 229 // AppWindow |
| 234 | 230 |
| 235 AppWindow::AppWindow(BrowserContext* context, | 231 AppWindow::AppWindow(BrowserContext* context, |
| 236 AppDelegate* app_delegate, | 232 AppDelegate* app_delegate, |
| 237 Delegate* delegate, | |
| 238 const extensions::Extension* extension) | 233 const extensions::Extension* extension) |
| 239 : browser_context_(context), | 234 : browser_context_(context), |
| 240 extension_id_(extension->id()), | 235 extension_id_(extension->id()), |
| 241 window_type_(WINDOW_TYPE_DEFAULT), | 236 window_type_(WINDOW_TYPE_DEFAULT), |
| 242 app_delegate_(app_delegate), | 237 app_delegate_(app_delegate), |
| 243 delegate_(delegate), | |
| 244 image_loader_ptr_factory_(this), | 238 image_loader_ptr_factory_(this), |
| 245 fullscreen_types_(FULLSCREEN_TYPE_NONE), | 239 fullscreen_types_(FULLSCREEN_TYPE_NONE), |
| 246 show_on_first_paint_(false), | 240 show_on_first_paint_(false), |
| 247 first_paint_complete_(false), | 241 first_paint_complete_(false), |
| 248 has_been_shown_(false), | 242 has_been_shown_(false), |
| 249 can_send_events_(false), | 243 can_send_events_(false), |
| 250 is_hidden_(false), | 244 is_hidden_(false), |
| 251 cached_always_on_top_(false), | 245 cached_always_on_top_(false), |
| 252 requested_transparent_background_(false) { | 246 requested_transparent_background_(false) { |
| 253 extensions::ExtensionsBrowserClient* client = | 247 extensions::ExtensionsBrowserClient* client = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 284 window_type_ = new_params.window_type; | 278 window_type_ = new_params.window_type; |
| 285 window_key_ = new_params.window_key; | 279 window_key_ = new_params.window_key; |
| 286 | 280 |
| 287 // Windows cannot be always-on-top in fullscreen mode for security reasons. | 281 // Windows cannot be always-on-top in fullscreen mode for security reasons. |
| 288 cached_always_on_top_ = new_params.always_on_top; | 282 cached_always_on_top_ = new_params.always_on_top; |
| 289 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) | 283 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) |
| 290 new_params.always_on_top = false; | 284 new_params.always_on_top = false; |
| 291 | 285 |
| 292 requested_transparent_background_ = new_params.transparent_background; | 286 requested_transparent_background_ = new_params.transparent_background; |
| 293 | 287 |
| 294 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params)); | 288 AppsClient* apps_client = AppsClient::Get(); |
| 289 native_app_window_.reset( |
| 290 apps_client->CreateNativeAppWindow(this, new_params)); |
| 295 | 291 |
| 296 helper_.reset(new AppWebContentsHelper( | 292 helper_.reset(new AppWebContentsHelper( |
| 297 browser_context_, extension_id_, web_contents, app_delegate_.get())); | 293 browser_context_, extension_id_, web_contents, app_delegate_.get())); |
| 298 | 294 |
| 299 popup_manager_.reset( | 295 popup_manager_.reset( |
| 300 new web_modal::PopupManager(GetWebContentsModalDialogHost())); | 296 new web_modal::PopupManager(GetWebContentsModalDialogHost())); |
| 301 popup_manager_->RegisterWith(web_contents); | 297 popup_manager_->RegisterWith(web_contents); |
| 302 | 298 |
| 303 // Prevent the browser process from shutting down while this window exists. | 299 // Prevent the browser process from shutting down while this window exists. |
| 304 AppsClient::Get()->IncrementKeepAliveCount(); | 300 apps_client->IncrementKeepAliveCount(); |
| 305 UpdateExtensionAppIcon(); | 301 UpdateExtensionAppIcon(); |
| 306 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); | 302 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); |
| 307 | 303 |
| 308 if (new_params.hidden) { | 304 if (new_params.hidden) { |
| 309 // Although the window starts hidden by default, calling Hide() here | 305 // Although the window starts hidden by default, calling Hide() here |
| 310 // notifies observers of the window being hidden. | 306 // notifies observers of the window being hidden. |
| 311 Hide(); | 307 Hide(); |
| 312 } else { | 308 } else { |
| 313 // Panels are not activated by default. | 309 // Panels are not activated by default. |
| 314 Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE | 310 Show(window_type_is_panel() || !new_params.focused ? SHOW_INACTIVE |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 region.bounds.x(), | 1102 region.bounds.x(), |
| 1107 region.bounds.y(), | 1103 region.bounds.y(), |
| 1108 region.bounds.right(), | 1104 region.bounds.right(), |
| 1109 region.bounds.bottom(), | 1105 region.bounds.bottom(), |
| 1110 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1106 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1111 } | 1107 } |
| 1112 return sk_region; | 1108 return sk_region; |
| 1113 } | 1109 } |
| 1114 | 1110 |
| 1115 } // namespace apps | 1111 } // namespace apps |
| OLD | NEW |