Chromium Code Reviews| 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/renderer_host/chrome_resource_dispatcher_host_delegate. h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " | 15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " |
| 16 #include "chrome/browser/download/download_request_limiter.h" | 16 #include "chrome/browser/download/download_request_limiter.h" |
| 17 #include "chrome/browser/download/download_resource_throttle.h" | 17 #include "chrome/browser/download/download_resource_throttle.h" |
| 18 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 18 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| 19 #include "chrome/browser/plugins/plugin_prefs.h" | |
| 19 #include "chrome/browser/prefetch/prefetch.h" | 20 #include "chrome/browser/prefetch/prefetch.h" |
| 20 #include "chrome/browser/prerender/prerender_manager.h" | 21 #include "chrome/browser/prerender/prerender_manager.h" |
| 21 #include "chrome/browser/prerender/prerender_manager_factory.h" | 22 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 22 #include "chrome/browser/prerender/prerender_resource_throttle.h" | 23 #include "chrome/browser/prerender/prerender_resource_throttle.h" |
| 23 #include "chrome/browser/prerender/prerender_tracker.h" | 24 #include "chrome/browser/prerender/prerender_tracker.h" |
| 24 #include "chrome/browser/prerender/prerender_util.h" | 25 #include "chrome/browser/prerender/prerender_util.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_io_data.h" | 27 #include "chrome/browser/profiles/profile_io_data.h" |
| 27 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h " | 28 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h " |
| 28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 29 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 29 #include "chrome/browser/signin/signin_header_helper.h" | 30 #include "chrome/browser/signin/signin_header_helper.h" |
| 30 #include "chrome/browser/tab_contents/tab_util.h" | 31 #include "chrome/browser/tab_contents/tab_util.h" |
| 31 #include "chrome/browser/ui/login/login_prompt.h" | 32 #include "chrome/browser/ui/login/login_prompt.h" |
| 32 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
| 34 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 35 #include "components/content_settings/core/browser/host_content_settings_map.h" | 36 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 36 #include "components/google/core/browser/google_util.h" | 37 #include "components/google/core/browser/google_util.h" |
| 37 #include "components/variations/net/variations_http_header_provider.h" | 38 #include "components/variations/net/variations_http_header_provider.h" |
| 38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/plugin_service.h" | |
| 40 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
| 41 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
| 42 #include "content/public/browser/resource_context.h" | 44 #include "content/public/browser/resource_context.h" |
| 43 #include "content/public/browser/resource_dispatcher_host.h" | 45 #include "content/public/browser/resource_dispatcher_host.h" |
| 44 #include "content/public/browser/resource_request_info.h" | 46 #include "content/public/browser/resource_request_info.h" |
| 45 #include "content/public/browser/service_worker_context.h" | 47 #include "content/public/browser/service_worker_context.h" |
| 46 #include "content/public/browser/stream_info.h" | 48 #include "content/public/browser/stream_info.h" |
| 47 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 48 #include "content/public/common/resource_response.h" | 50 #include "content/public/common/resource_response.h" |
| 49 #include "net/base/load_flags.h" | 51 #include "net/base/load_flags.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 Profile* profile = | 202 Profile* profile = |
| 201 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 203 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 202 | 204 |
| 203 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); | 205 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); |
| 204 if (!streams_private) | 206 if (!streams_private) |
| 205 return; | 207 return; |
| 206 streams_private->ExecuteMimeTypeHandler( | 208 streams_private->ExecuteMimeTypeHandler( |
| 207 extension_id, web_contents, stream.Pass(), view_id, expected_content_size, | 209 extension_id, web_contents, stream.Pass(), view_id, expected_content_size, |
| 208 embedded, render_process_id, render_frame_id); | 210 embedded, render_process_id, render_frame_id); |
| 209 } | 211 } |
| 212 | |
| 213 bool IsPluginEnabledForExtension(const Extension* extension, | |
| 214 int render_process_id, | |
| 215 int render_view_id) { | |
| 216 content::WebPluginInfo plugin_info; | |
| 217 bool found = content::PluginService::GetInstance()->GetPluginInfoByPath( | |
|
Sam McNally
2015/02/18 03:32:15
if (!content::PluginService::GetInstance()->GetPlu
raymes
2015/02/18 04:03:04
Done.
| |
| 218 base::FilePath::FromUTF8Unsafe(extension->url().spec()), &plugin_info); | |
| 219 if (!found) | |
| 220 return false; | |
| 221 | |
| 222 content::WebContents* web_contents = | |
| 223 tab_util::GetWebContentsByID(render_process_id, render_view_id); | |
| 224 if (!web_contents) | |
| 225 return false; | |
| 226 | |
| 227 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); | |
| 228 if (!browser_context) | |
| 229 return false; | |
| 230 | |
| 231 bool enabled = PluginPrefs::GetForProfile(Profile::FromBrowserContext( | |
|
Sam McNally
2015/02/18 03:32:15
if (!PluginPrefs::GetForProfile(Profile::FromBrows
raymes
2015/02/18 04:03:04
Done.
raymes
2015/02/18 04:03:04
Done.
| |
| 232 browser_context))->IsPluginEnabled(plugin_info); | |
| 233 if (!enabled) | |
| 234 return false; | |
| 235 | |
| 236 return true; | |
| 237 } | |
| 210 #endif // !defined(ENABLE_EXTENSIONS) | 238 #endif // !defined(ENABLE_EXTENSIONS) |
| 211 | 239 |
| 212 #if !defined(OS_ANDROID) | 240 #if !defined(OS_ANDROID) |
| 213 void LaunchURL(const GURL& url, int render_process_id, int render_view_id) { | 241 void LaunchURL(const GURL& url, int render_process_id, int render_view_id) { |
| 214 // If there is no longer a WebContents, the request may have raced with tab | 242 // If there is no longer a WebContents, the request may have raced with tab |
| 215 // closing. Don't fire the external request. (It may have been a prerender.) | 243 // closing. Don't fire the external request. (It may have been a prerender.) |
| 216 content::WebContents* web_contents = | 244 content::WebContents* web_contents = |
| 217 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 245 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 218 if (!web_contents) | 246 if (!web_contents) |
| 219 return; | 247 return; |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 const Extension* extension = | 642 const Extension* extension = |
| 615 extension_info_map->extensions().GetByID(extension_id); | 643 extension_info_map->extensions().GetByID(extension_id); |
| 616 // The white-listed extension may not be installed, so we have to NULL check | 644 // The white-listed extension may not be installed, so we have to NULL check |
| 617 // |extension|. | 645 // |extension|. |
| 618 if (!extension || | 646 if (!extension || |
| 619 (profile_is_off_the_record && | 647 (profile_is_off_the_record && |
| 620 !extension_info_map->IsIncognitoEnabled(extension_id))) { | 648 !extension_info_map->IsIncognitoEnabled(extension_id))) { |
| 621 continue; | 649 continue; |
| 622 } | 650 } |
| 623 | 651 |
| 652 if (!IsPluginEnabledForExtension(extension, | |
| 653 info->GetChildID(), | |
| 654 info->GetRouteID())) { | |
| 655 continue; | |
| 656 } | |
| 657 | |
| 624 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 658 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 625 if (handler && handler->CanHandleMIMEType(mime_type)) { | 659 if (handler && handler->CanHandleMIMEType(mime_type)) { |
| 626 StreamTargetInfo target_info; | 660 StreamTargetInfo target_info; |
| 627 *origin = Extension::GetBaseURLFromExtensionId(extension_id); | 661 *origin = Extension::GetBaseURLFromExtensionId(extension_id); |
| 628 target_info.extension_id = extension_id; | 662 target_info.extension_id = extension_id; |
| 629 if (!handler->handler_url().empty()) { | 663 if (!handler->handler_url().empty()) { |
| 630 target_info.view_id = base::GenerateGUID(); | 664 target_info.view_id = base::GenerateGUID(); |
| 631 *payload = target_info.view_id; | 665 *payload = target_info.view_id; |
| 632 } | 666 } |
| 633 stream_target_info_[request] = target_info; | 667 stream_target_info_[request] = target_info; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 url_request->GetTotalReceivedBytes())); | 801 url_request->GetTotalReceivedBytes())); |
| 768 } | 802 } |
| 769 } | 803 } |
| 770 | 804 |
| 771 // static | 805 // static |
| 772 void ChromeResourceDispatcherHostDelegate:: | 806 void ChromeResourceDispatcherHostDelegate:: |
| 773 SetExternalProtocolHandlerDelegateForTesting( | 807 SetExternalProtocolHandlerDelegateForTesting( |
| 774 ExternalProtocolHandler::Delegate* delegate) { | 808 ExternalProtocolHandler::Delegate* delegate) { |
| 775 g_external_protocol_handler_delegate = delegate; | 809 g_external_protocol_handler_delegate = delegate; |
| 776 } | 810 } |
| OLD | NEW |