| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 const CreateParams& params) { | 256 const CreateParams& params) { |
| 257 // Initialize the render interface and web contents | 257 // Initialize the render interface and web contents |
| 258 app_window_contents_.reset(app_window_contents); | 258 app_window_contents_.reset(app_window_contents); |
| 259 app_window_contents_->Initialize(browser_context(), url); | 259 app_window_contents_->Initialize(browser_context(), url); |
| 260 WebContents* web_contents = app_window_contents_->GetWebContents(); | 260 WebContents* web_contents = app_window_contents_->GetWebContents(); |
| 261 if (CommandLine::ForCurrentProcess()->HasSwitch( | 261 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 262 switches::kEnableAppsShowOnFirstPaint)) { | 262 switches::kEnableAppsShowOnFirstPaint)) { |
| 263 content::WebContentsObserver::Observe(web_contents); | 263 content::WebContentsObserver::Observe(web_contents); |
| 264 } | 264 } |
| 265 app_delegate_->InitWebContents(web_contents); | 265 app_delegate_->InitWebContents(web_contents); |
| 266 | |
| 267 WebContentsModalDialogManager::CreateForWebContents(web_contents); | 266 WebContentsModalDialogManager::CreateForWebContents(web_contents); |
| 268 // TODO(jamescook): Delegate out this creation. | 267 // TODO(jamescook): Delegate out this creation. |
| 269 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 268 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
| 270 web_contents); | 269 web_contents); |
| 271 | 270 |
| 272 web_contents->SetDelegate(this); | 271 web_contents->SetDelegate(this); |
| 273 WebContentsModalDialogManager::FromWebContents(web_contents) | 272 WebContentsModalDialogManager::FromWebContents(web_contents) |
| 274 ->SetDelegate(this); | 273 ->SetDelegate(this); |
| 275 extensions::SetViewType(web_contents, extensions::VIEW_TYPE_APP_WINDOW); | 274 extensions::SetViewType(web_contents, extensions::VIEW_TYPE_APP_WINDOW); |
| 276 | 275 |
| 277 // Initialize the window | 276 // Initialize the window |
| 278 CreateParams new_params = LoadDefaults(params); | 277 CreateParams new_params = LoadDefaults(params); |
| 279 window_type_ = new_params.window_type; | 278 window_type_ = new_params.window_type; |
| 280 window_key_ = new_params.window_key; | 279 window_key_ = new_params.window_key; |
| 281 | 280 |
| 282 // 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. |
| 283 cached_always_on_top_ = new_params.always_on_top; | 282 cached_always_on_top_ = new_params.always_on_top; |
| 284 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) | 283 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) |
| 285 new_params.always_on_top = false; | 284 new_params.always_on_top = false; |
| 286 | 285 |
| 287 requested_alpha_enabled_ = new_params.alpha_enabled; | 286 requested_alpha_enabled_ = new_params.alpha_enabled; |
| 288 | 287 |
| 289 AppsClient* apps_client = AppsClient::Get(); | 288 AppsClient* apps_client = AppsClient::Get(); |
| 290 native_app_window_.reset( | 289 native_app_window_.reset( |
| 291 apps_client->CreateNativeAppWindow(this, new_params)); | 290 apps_client->CreateNativeAppWindow(this, new_params)); |
| 292 | 291 |
| 293 helper_.reset(new AppWebContentsHelper( | 292 helper_.reset(new AppWebContentsHelper( |
| 294 browser_context_, extension_id_, web_contents, app_delegate_.get())); | 293 browser_context_, extension_id_, web_contents, app_delegate_.get())); |
| 295 | 294 |
| 296 popup_manager_.reset( | |
| 297 new web_modal::PopupManager(GetWebContentsModalDialogHost())); | |
| 298 popup_manager_->RegisterWith(web_contents); | |
| 299 | |
| 300 // Prevent the browser process from shutting down while this window exists. | 295 // Prevent the browser process from shutting down while this window exists. |
| 301 apps_client->IncrementKeepAliveCount(); | 296 apps_client->IncrementKeepAliveCount(); |
| 302 UpdateExtensionAppIcon(); | 297 UpdateExtensionAppIcon(); |
| 303 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); | 298 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); |
| 304 | 299 |
| 305 if (new_params.hidden) { | 300 if (new_params.hidden) { |
| 306 // Although the window starts hidden by default, calling Hide() here | 301 // Although the window starts hidden by default, calling Hide() here |
| 307 // notifies observers of the window being hidden. | 302 // notifies observers of the window being hidden. |
| 308 Hide(); | 303 Hide(); |
| 309 } else { | 304 } else { |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 region.bounds.x(), | 1098 region.bounds.x(), |
| 1104 region.bounds.y(), | 1099 region.bounds.y(), |
| 1105 region.bounds.right(), | 1100 region.bounds.right(), |
| 1106 region.bounds.bottom(), | 1101 region.bounds.bottom(), |
| 1107 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1102 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1108 } | 1103 } |
| 1109 return sk_region; | 1104 return sk_region; |
| 1110 } | 1105 } |
| 1111 | 1106 |
| 1112 } // namespace apps | 1107 } // namespace apps |
| OLD | NEW |