| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| 11 #include "chrome/browser/extensions/image_loader.h" | 11 #include "chrome/browser/extensions/image_loader.h" |
| 12 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | 12 #include "chrome/browser/extensions/shell_window_geometry_cache.h" |
| 13 #include "chrome/browser/extensions/shell_window_registry.h" | 13 #include "chrome/browser/extensions/shell_window_registry.h" |
| 14 #include "chrome/browser/extensions/suggest_permission_util.h" | 14 #include "chrome/browser/extensions/suggest_permission_util.h" |
| 15 #include "chrome/browser/extensions/tab_helper.h" | 15 #include "chrome/browser/extensions/tab_helper.h" |
| 16 #include "chrome/browser/favicon/favicon_tab_helper.h" | 16 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 17 #include "chrome/browser/file_select_helper.h" | 17 #include "chrome/browser/file_select_helper.h" |
| 18 #include "chrome/browser/intents/web_intents_util.h" | |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 19 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/sessions/session_id.h" | 21 #include "chrome/browser/sessions/session_id.h" |
| 23 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" | 24 #include "chrome/browser/ui/browser_tabstrip.h" |
| 26 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 27 #include "chrome/browser/ui/extensions/native_app_window.h" | 26 #include "chrome/browser/ui/extensions/native_app_window.h" |
| 28 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | |
| 29 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 27 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
| 30 #include "chrome/browser/view_type_utils.h" | 28 #include "chrome/browser/view_type_utils.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/extensions/api/app_window.h" | 30 #include "chrome/common/extensions/api/app_window.h" |
| 33 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
| 34 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
| 35 #include "chrome/common/extensions/extension_messages.h" | 33 #include "chrome/common/extensions/extension_messages.h" |
| 36 #include "chrome/common/extensions/request_media_access_permission_helper.h" | 34 #include "chrome/common/extensions/request_media_access_permission_helper.h" |
| 37 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/invalidate_type.h" | 36 #include "content/public/browser/invalidate_type.h" |
| 39 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
| 40 #include "content/public/browser/notification_details.h" | 38 #include "content/public/browser/notification_details.h" |
| 41 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
| 43 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
| 44 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
| 45 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
| 46 #include "content/public/browser/resource_dispatcher_host.h" | 44 #include "content/public/browser/resource_dispatcher_host.h" |
| 47 #include "content/public/browser/site_instance.h" | 45 #include "content/public/browser/site_instance.h" |
| 48 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 49 #include "content/public/browser/web_intents_dispatcher.h" | |
| 50 #include "content/public/common/media_stream_request.h" | 47 #include "content/public/common/media_stream_request.h" |
| 51 #include "content/public/common/renderer_preferences.h" | 48 #include "content/public/common/renderer_preferences.h" |
| 52 #include "skia/ext/image_operations.h" | 49 #include "skia/ext/image_operations.h" |
| 53 #include "third_party/skia/include/core/SkRegion.h" | 50 #include "third_party/skia/include/core/SkRegion.h" |
| 54 | 51 |
| 55 #if defined(USE_ASH) | 52 #if defined(USE_ASH) |
| 56 #include "ash/launcher/launcher_types.h" | 53 #include "ash/launcher/launcher_types.h" |
| 57 #endif | 54 #endif |
| 58 | 55 |
| 59 namespace app_window = extensions::api::app_window; | 56 namespace app_window = extensions::api::app_window; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 120 } |
| 124 | 121 |
| 125 void ShellWindow::Init(const GURL& url, | 122 void ShellWindow::Init(const GURL& url, |
| 126 const ShellWindow::CreateParams& params) { | 123 const ShellWindow::CreateParams& params) { |
| 127 window_type_ = params.window_type; | 124 window_type_ = params.window_type; |
| 128 | 125 |
| 129 web_contents_.reset(WebContents::Create(WebContents::CreateParams( | 126 web_contents_.reset(WebContents::Create(WebContents::CreateParams( |
| 130 profile(), SiteInstance::CreateForURL(profile(), url)))); | 127 profile(), SiteInstance::CreateForURL(profile(), url)))); |
| 131 WebContentsModalDialogManager::CreateForWebContents(web_contents_.get()); | 128 WebContentsModalDialogManager::CreateForWebContents(web_contents_.get()); |
| 132 FaviconTabHelper::CreateForWebContents(web_contents_.get()); | 129 FaviconTabHelper::CreateForWebContents(web_contents_.get()); |
| 133 #if defined(ENABLE_WEB_INTENTS) | |
| 134 WebIntentPickerController::CreateForWebContents(web_contents_.get()); | |
| 135 #endif | |
| 136 | 130 |
| 137 content::WebContentsObserver::Observe(web_contents_.get()); | 131 content::WebContentsObserver::Observe(web_contents_.get()); |
| 138 web_contents_->SetDelegate(this); | 132 web_contents_->SetDelegate(this); |
| 139 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_APP_SHELL); | 133 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_APP_SHELL); |
| 140 web_contents_->GetMutableRendererPrefs()-> | 134 web_contents_->GetMutableRendererPrefs()-> |
| 141 browser_handles_all_top_level_requests = true; | 135 browser_handles_all_top_level_requests = true; |
| 142 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 136 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 143 | 137 |
| 144 gfx::Rect bounds = params.bounds; | 138 gfx::Rect bounds = params.bounds; |
| 145 | 139 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 486 |
| 493 void ShellWindow::CloseContents(WebContents* contents) { | 487 void ShellWindow::CloseContents(WebContents* contents) { |
| 494 DCHECK(contents == web_contents_); | 488 DCHECK(contents == web_contents_); |
| 495 native_app_window_->Close(); | 489 native_app_window_->Close(); |
| 496 } | 490 } |
| 497 | 491 |
| 498 bool ShellWindow::ShouldSuppressDialogs() { | 492 bool ShellWindow::ShouldSuppressDialogs() { |
| 499 return true; | 493 return true; |
| 500 } | 494 } |
| 501 | 495 |
| 502 void ShellWindow::WebIntentDispatch( | |
| 503 content::WebContents* web_contents, | |
| 504 content::WebIntentsDispatcher* intents_dispatcher) { | |
| 505 #if defined(ENABLE_WEB_INTENTS) | |
| 506 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) | |
| 507 return; | |
| 508 | |
| 509 WebIntentPickerController* web_intent_picker_controller = | |
| 510 WebIntentPickerController::FromWebContents(web_contents_.get()); | |
| 511 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher); | |
| 512 web_intent_picker_controller->ShowDialog( | |
| 513 intents_dispatcher->GetIntent().action, | |
| 514 intents_dispatcher->GetIntent().type); | |
| 515 #endif | |
| 516 } | |
| 517 | |
| 518 void ShellWindow::RunFileChooser(WebContents* tab, | 496 void ShellWindow::RunFileChooser(WebContents* tab, |
| 519 const content::FileChooserParams& params) { | 497 const content::FileChooserParams& params) { |
| 520 FileSelectHelper::RunFileChooser(tab, params); | 498 FileSelectHelper::RunFileChooser(tab, params); |
| 521 } | 499 } |
| 522 | 500 |
| 523 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const { | 501 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const { |
| 524 DCHECK(source == web_contents_.get()); | 502 DCHECK(source == web_contents_.get()); |
| 525 return true; | 503 return true; |
| 526 } | 504 } |
| 527 | 505 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 const extensions::DraggableRegion& region = *iter; | 623 const extensions::DraggableRegion& region = *iter; |
| 646 sk_region->op( | 624 sk_region->op( |
| 647 region.bounds.x(), | 625 region.bounds.x(), |
| 648 region.bounds.y(), | 626 region.bounds.y(), |
| 649 region.bounds.right(), | 627 region.bounds.right(), |
| 650 region.bounds.bottom(), | 628 region.bounds.bottom(), |
| 651 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 629 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 652 } | 630 } |
| 653 return sk_region; | 631 return sk_region; |
| 654 } | 632 } |
| OLD | NEW |