| 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 "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" | 5 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
| 11 #include "extensions/browser/api/extensions_api_client.h" | 11 #include "extensions/browser/api/extensions_api_client.h" |
| 12 #include "extensions/browser/extension_registry.h" | 12 #include "extensions/browser/extension_registry.h" |
| 13 #include "extensions/browser/extension_system.h" | |
| 14 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" | 13 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" |
| 15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t_delegate.h" | 14 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t_delegate.h" |
| 16 #include "extensions/browser/process_manager.h" | 15 #include "extensions/browser/process_manager.h" |
| 17 #include "extensions/common/extension_messages.h" | 16 #include "extensions/common/extension_messages.h" |
| 18 #include "extensions/common/feature_switch.h" | 17 #include "extensions/common/feature_switch.h" |
| 19 #include "extensions/common/guest_view/guest_view_constants.h" | 18 #include "extensions/common/guest_view/guest_view_constants.h" |
| 20 #include "extensions/strings/grit/extensions_strings.h" | 19 #include "extensions/strings/grit/extensions_strings.h" |
| 21 #include "ipc/ipc_message_macros.h" | 20 #include "ipc/ipc_message_macros.h" |
| 22 #include "net/base/url_util.h" | 21 #include "net/base/url_util.h" |
| 23 | 22 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // terminated (ExtensionRegistry::TERMINATED)? | 90 // terminated (ExtensionRegistry::TERMINATED)? |
| 92 ExtensionRegistry::Get(browser_context())->enabled_extensions().GetByID( | 91 ExtensionRegistry::Get(browser_context())->enabled_extensions().GetByID( |
| 93 mime_handler_extension_url.host()); | 92 mime_handler_extension_url.host()); |
| 94 if (!mime_handler_extension) { | 93 if (!mime_handler_extension) { |
| 95 LOG(ERROR) << "Extension for mime_type not found, mime_type = " | 94 LOG(ERROR) << "Extension for mime_type not found, mime_type = " |
| 96 << orig_mime_type; | 95 << orig_mime_type; |
| 97 callback.Run(NULL); | 96 callback.Run(NULL); |
| 98 return; | 97 return; |
| 99 } | 98 } |
| 100 | 99 |
| 101 ProcessManager* process_manager = | |
| 102 ExtensionSystem::Get(browser_context())->process_manager(); | |
| 103 DCHECK(process_manager); | |
| 104 | |
| 105 // Use the mime handler extension's SiteInstance to create the guest so it | 100 // Use the mime handler extension's SiteInstance to create the guest so it |
| 106 // goes under the same process as the extension. | 101 // goes under the same process as the extension. |
| 102 ProcessManager* process_manager = ProcessManager::Get(browser_context()); |
| 107 content::SiteInstance* guest_site_instance = | 103 content::SiteInstance* guest_site_instance = |
| 108 process_manager->GetSiteInstanceForURL( | 104 process_manager->GetSiteInstanceForURL( |
| 109 Extension::GetBaseURLFromExtensionId(embedder_extension_id)); | 105 Extension::GetBaseURLFromExtensionId(embedder_extension_id)); |
| 110 | 106 |
| 111 WebContents::CreateParams params(browser_context(), guest_site_instance); | 107 WebContents::CreateParams params(browser_context(), guest_site_instance); |
| 112 params.guest_delegate = this; | 108 params.guest_delegate = this; |
| 113 callback.Run(WebContents::Create(params)); | 109 callback.Run(WebContents::Create(params)); |
| 114 } | 110 } |
| 115 | 111 |
| 116 void MimeHandlerViewGuest::DidAttachToEmbedder() { | 112 void MimeHandlerViewGuest::DidAttachToEmbedder() { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 195 |
| 200 void MimeHandlerViewGuest::OnRequest( | 196 void MimeHandlerViewGuest::OnRequest( |
| 201 const ExtensionHostMsg_Request_Params& params) { | 197 const ExtensionHostMsg_Request_Params& params) { |
| 202 if (extension_function_dispatcher_) { | 198 if (extension_function_dispatcher_) { |
| 203 extension_function_dispatcher_->Dispatch( | 199 extension_function_dispatcher_->Dispatch( |
| 204 params, web_contents()->GetRenderViewHost()); | 200 params, web_contents()->GetRenderViewHost()); |
| 205 } | 201 } |
| 206 } | 202 } |
| 207 | 203 |
| 208 } // namespace extensions | 204 } // namespace extensions |
| OLD | NEW |