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 base::FilePath plugin_path = | |
218 base::FilePath::FromUTF8Unsafe(extension->url().spec()); | |
219 if (!content::PluginService::GetInstance()->GetPluginInfoByPath( | |
220 plugin_path, &plugin_info)) { | |
221 return false; | |
222 } | |
223 | |
224 content::WebContents* web_contents = | |
225 tab_util::GetWebContentsByID(render_process_id, render_view_id); | |
226 if (!web_contents) | |
227 return false; | |
228 | |
229 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); | |
230 if (!browser_context) | |
231 return false; | |
232 | |
233 if (!PluginPrefs::GetForProfile(Profile::FromBrowserContext( | |
Lei Zhang
2015/02/18 04:24:18
You can just return the IsPluginEnabled() result h
raymes
2015/02/18 21:24:27
Done.
| |
234 browser_context))->IsPluginEnabled(plugin_info)) { | |
235 return false; | |
236 } | |
237 | |
238 return true; | |
239 } | |
210 #endif // !defined(ENABLE_EXTENSIONS) | 240 #endif // !defined(ENABLE_EXTENSIONS) |
211 | 241 |
212 #if !defined(OS_ANDROID) | 242 #if !defined(OS_ANDROID) |
213 void LaunchURL(const GURL& url, int render_process_id, int render_view_id) { | 243 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 | 244 // 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.) | 245 // closing. Don't fire the external request. (It may have been a prerender.) |
216 content::WebContents* web_contents = | 246 content::WebContents* web_contents = |
217 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 247 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
218 if (!web_contents) | 248 if (!web_contents) |
219 return; | 249 return; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 const Extension* extension = | 644 const Extension* extension = |
615 extension_info_map->extensions().GetByID(extension_id); | 645 extension_info_map->extensions().GetByID(extension_id); |
616 // The white-listed extension may not be installed, so we have to NULL check | 646 // The white-listed extension may not be installed, so we have to NULL check |
617 // |extension|. | 647 // |extension|. |
618 if (!extension || | 648 if (!extension || |
619 (profile_is_off_the_record && | 649 (profile_is_off_the_record && |
620 !extension_info_map->IsIncognitoEnabled(extension_id))) { | 650 !extension_info_map->IsIncognitoEnabled(extension_id))) { |
621 continue; | 651 continue; |
622 } | 652 } |
623 | 653 |
654 if (!IsPluginEnabledForExtension(extension, | |
655 info->GetChildID(), | |
656 info->GetRouteID())) { | |
657 continue; | |
658 } | |
659 | |
624 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 660 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
625 if (handler && handler->CanHandleMIMEType(mime_type)) { | 661 if (handler && handler->CanHandleMIMEType(mime_type)) { |
626 StreamTargetInfo target_info; | 662 StreamTargetInfo target_info; |
627 *origin = Extension::GetBaseURLFromExtensionId(extension_id); | 663 *origin = Extension::GetBaseURLFromExtensionId(extension_id); |
628 target_info.extension_id = extension_id; | 664 target_info.extension_id = extension_id; |
629 if (!handler->handler_url().empty()) { | 665 if (!handler->handler_url().empty()) { |
630 target_info.view_id = base::GenerateGUID(); | 666 target_info.view_id = base::GenerateGUID(); |
631 *payload = target_info.view_id; | 667 *payload = target_info.view_id; |
632 } | 668 } |
633 stream_target_info_[request] = target_info; | 669 stream_target_info_[request] = target_info; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 url_request->GetTotalReceivedBytes())); | 803 url_request->GetTotalReceivedBytes())); |
768 } | 804 } |
769 } | 805 } |
770 | 806 |
771 // static | 807 // static |
772 void ChromeResourceDispatcherHostDelegate:: | 808 void ChromeResourceDispatcherHostDelegate:: |
773 SetExternalProtocolHandlerDelegateForTesting( | 809 SetExternalProtocolHandlerDelegateForTesting( |
774 ExternalProtocolHandler::Delegate* delegate) { | 810 ExternalProtocolHandler::Delegate* delegate) { |
775 g_external_protocol_handler_delegate = delegate; | 811 g_external_protocol_handler_delegate = delegate; |
776 } | 812 } |
OLD | NEW |