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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/common/child_process_logging.h" | 15 #include "chrome/common/child_process_logging.h" |
16 #include "chrome/common/chrome_content_client.h" | 16 #include "chrome/common/chrome_content_client.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/content_settings_pattern.h" | 19 #include "chrome/common/content_settings_pattern.h" |
20 #include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h" | |
20 #include "chrome/common/extensions/chrome_extensions_client.h" | 21 #include "chrome/common/extensions/chrome_extensions_client.h" |
21 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
23 #include "chrome/common/extensions/extension_manifest_constants.h" | 24 #include "chrome/common/extensions/extension_manifest_constants.h" |
25 #include "chrome/common/extensions/extension_messages.h" | |
24 #include "chrome/common/extensions/extension_process_policy.h" | 26 #include "chrome/common/extensions/extension_process_policy.h" |
25 #include "chrome/common/extensions/extension_set.h" | 27 #include "chrome/common/extensions/extension_set.h" |
26 #include "chrome/common/external_ipc_fuzzer.h" | 28 #include "chrome/common/external_ipc_fuzzer.h" |
27 #include "chrome/common/localized_error.h" | 29 #include "chrome/common/localized_error.h" |
28 #include "chrome/common/pepper_permission_util.h" | 30 #include "chrome/common/pepper_permission_util.h" |
29 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
30 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
31 #include "chrome/renderer/benchmarking_extension.h" | 33 #include "chrome/renderer/benchmarking_extension.h" |
32 #include "chrome/renderer/chrome_render_process_observer.h" | 34 #include "chrome/renderer/chrome_render_process_observer.h" |
33 #include "chrome/renderer/chrome_render_view_observer.h" | 35 #include "chrome/renderer/chrome_render_view_observer.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 #include "components/autofill/content/renderer/autofill_agent.h" | 67 #include "components/autofill/content/renderer/autofill_agent.h" |
66 #include "components/autofill/content/renderer/password_autofill_agent.h" | 68 #include "components/autofill/content/renderer/password_autofill_agent.h" |
67 #include "components/autofill/content/renderer/password_generation_manager.h" | 69 #include "components/autofill/content/renderer/password_generation_manager.h" |
68 #include "components/visitedlink/renderer/visitedlink_slave.h" | 70 #include "components/visitedlink/renderer/visitedlink_slave.h" |
69 #include "content/public/common/content_constants.h" | 71 #include "content/public/common/content_constants.h" |
70 #include "content/public/renderer/render_thread.h" | 72 #include "content/public/renderer/render_thread.h" |
71 #include "content/public/renderer/render_view.h" | 73 #include "content/public/renderer/render_view.h" |
72 #include "content/public/renderer/render_view_visitor.h" | 74 #include "content/public/renderer/render_view_visitor.h" |
73 #include "extensions/common/constants.h" | 75 #include "extensions/common/constants.h" |
74 #include "extensions/common/extension_urls.h" | 76 #include "extensions/common/extension_urls.h" |
77 #include "extensions/common/switches.h" | |
75 #include "grit/generated_resources.h" | 78 #include "grit/generated_resources.h" |
76 #include "grit/locale_settings.h" | 79 #include "grit/locale_settings.h" |
77 #include "grit/renderer_resources.h" | 80 #include "grit/renderer_resources.h" |
78 #include "ipc/ipc_sync_channel.h" | 81 #include "ipc/ipc_sync_channel.h" |
79 #include "net/base/net_errors.h" | 82 #include "net/base/net_errors.h" |
80 #include "ppapi/c/private/ppb_nacl_private.h" | 83 #include "ppapi/c/private/ppb_nacl_private.h" |
81 #include "ppapi/c/private/ppb_pdf.h" | 84 #include "ppapi/c/private/ppb_pdf.h" |
82 #include "ppapi/shared_impl/ppapi_switches.h" | 85 #include "ppapi/shared_impl/ppapi_switches.h" |
83 #include "third_party/WebKit/public/web/WebCache.h" | 86 #include "third_party/WebKit/public/web/WebCache.h" |
84 #include "third_party/WebKit/public/web/WebDataSource.h" | 87 #include "third_party/WebKit/public/web/WebDataSource.h" |
85 #include "third_party/WebKit/public/web/WebDocument.h" | 88 #include "third_party/WebKit/public/web/WebDocument.h" |
86 #include "third_party/WebKit/public/web/WebElement.h" | 89 #include "third_party/WebKit/public/web/WebElement.h" |
87 #include "third_party/WebKit/public/web/WebFrame.h" | 90 #include "third_party/WebKit/public/web/WebFrame.h" |
88 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 91 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
89 #include "third_party/WebKit/public/web/WebPluginParams.h" | 92 #include "third_party/WebKit/public/web/WebPluginParams.h" |
90 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 93 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
91 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 94 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
92 #include "third_party/WebKit/public/platform/WebURL.h" | 95 #include "third_party/WebKit/public/platform/WebURL.h" |
93 #include "third_party/WebKit/public/platform/WebURLError.h" | 96 #include "third_party/WebKit/public/platform/WebURLError.h" |
94 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 97 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
98 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | |
95 #include "ui/base/l10n/l10n_util.h" | 99 #include "ui/base/l10n/l10n_util.h" |
96 #include "ui/base/layout.h" | 100 #include "ui/base/layout.h" |
97 #include "ui/base/resource/resource_bundle.h" | 101 #include "ui/base/resource/resource_bundle.h" |
98 #include "ui/webui/jstemplate_builder.h" | 102 #include "ui/webui/jstemplate_builder.h" |
99 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 103 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
100 | 104 |
101 #if defined(ENABLE_WEBRTC) | 105 #if defined(ENABLE_WEBRTC) |
102 #include "chrome/renderer/media/webrtc_logging_message_filter.h" | 106 #include "chrome/renderer/media/webrtc_logging_message_filter.h" |
103 #endif | 107 #endif |
104 | 108 |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
917 bool ChromeContentRendererClient::AllowPopup() { | 921 bool ChromeContentRendererClient::AllowPopup() { |
918 extensions::ChromeV8Context* current_context = | 922 extensions::ChromeV8Context* current_context = |
919 extension_dispatcher_->v8_context_set().GetCurrent(); | 923 extension_dispatcher_->v8_context_set().GetCurrent(); |
920 return current_context && current_context->extension() && | 924 return current_context && current_context->extension() && |
921 (current_context->context_type() == | 925 (current_context->context_type() == |
922 extensions::Feature::BLESSED_EXTENSION_CONTEXT || | 926 extensions::Feature::BLESSED_EXTENSION_CONTEXT || |
923 current_context->context_type() == | 927 current_context->context_type() == |
924 extensions::Feature::CONTENT_SCRIPT_CONTEXT); | 928 extensions::Feature::CONTENT_SCRIPT_CONTEXT); |
925 } | 929 } |
926 | 930 |
931 // For top-level navigations, tries to find a platform app that has registered | |
932 // a URL handler matching the URL. If found, delegates further URL processing | |
933 // to the browser (the browser is supposed to launch the app), and returns true | |
934 // to cancel navigation on the renderer side. Otherwise, returns false. | |
935 bool ChromeContentRendererClient::HandleNavigation( | |
936 WebKit::WebFrame* frame, | |
937 const WebKit::WebURLRequest& request, | |
938 WebKit::WebNavigationType type, | |
939 WebKit::WebNavigationPolicy default_policy, | |
940 bool is_redirect) { | |
941 // TODO(sergeygs): Remove this and update includes once url_handlers are | |
942 // moved out of experimental. | |
943 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
944 extensions::switches::kEnableExperimentalExtensionApis)) | |
not at google - send to devlin
2013/09/03 18:28:04
this seems unnecessary. Firstly you're gating this
sergeygs
2013/09/04 03:29:17
This switch was only temporary (for debugging). Re
| |
945 return false; | |
946 | |
947 // Limit redirection to top-level frames only. | |
948 if (frame != frame->top()) | |
949 return false; | |
950 | |
951 // Exclude reloads (shouldn't happen anyway) and back/forward. | |
952 bool navigation_type_ok = | |
953 WebKit::WebUserGestureIndicator::isProcessingUserGesture() || | |
954 (type == WebKit::WebNavigationTypeLinkClicked) || | |
955 (((type == WebKit::WebNavigationTypeFormSubmitted) || | |
956 (type == WebKit::WebNavigationTypeFormResubmitted) || | |
957 (type == WebKit::WebNavigationTypeOther) | |
958 ) && frame->opener() | |
959 ); | |
960 | |
961 if (!navigation_type_ok) | |
962 return false; | |
963 | |
964 // Get the top-level RenderView (tab or extension window) so that we can send | |
965 // a routed IPC message to the correct observer. | |
966 content::RenderView* render_view = frame->opener() ? | |
967 content::RenderView::FromWebView(frame->opener()->view()) : | |
968 content::RenderView::FromWebView(frame->view()); | |
969 if (!render_view) | |
970 return false; | |
971 | |
972 // Find out if there is an extension that can handle the URL, and if there is, | |
973 // send an IPC to the render view to launch it. | |
974 const GURL url(request.url()); | |
975 const ExtensionSet* exts = extension_dispatcher_->extensions(); | |
976 for (ExtensionSet::const_iterator iter = exts->begin(); | |
977 iter != exts->end(); | |
978 ++iter) { | |
979 if (extensions::UrlHandlers::CanExtensionHandleUrl(*iter, url)) { | |
980 const GURL referrer_url( | |
981 request.httpHeaderField(WebString::fromUTF8("Referer"))); | |
982 return RenderThread::Get()->Send( | |
983 new ExtensionHostMsg_RedirectUrl( | |
984 render_view->GetRoutingID(), url, referrer_url)); | |
985 } | |
986 } | |
987 | |
988 return false; | |
989 } | |
990 | |
927 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, | 991 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, |
928 const GURL& url, | 992 const GURL& url, |
929 const std::string& http_method, | 993 const std::string& http_method, |
930 bool is_initial_navigation, | 994 bool is_initial_navigation, |
931 bool is_server_redirect, | 995 bool is_server_redirect, |
932 bool* send_referrer) { | 996 bool* send_referrer) { |
933 DCHECK(!frame->parent()); | 997 DCHECK(!frame->parent()); |
934 | 998 |
935 // If this is the Instant process, fork all navigations originating from the | 999 // If this is the Instant process, fork all navigations originating from the |
936 // renderer. The destination page will then be bucketed back to this Instant | 1000 // renderer. The destination page will then be bucketed back to this Instant |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 #endif // !defined(OS_ANDROID) | 1363 #endif // !defined(OS_ANDROID) |
1300 return false; | 1364 return false; |
1301 } | 1365 } |
1302 | 1366 |
1303 bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource( | 1367 bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource( |
1304 const base::string16& source) const { | 1368 const base::string16& source) const { |
1305 return extensions::IsSourceFromAnExtension(source); | 1369 return extensions::IsSourceFromAnExtension(source); |
1306 } | 1370 } |
1307 | 1371 |
1308 } // namespace chrome | 1372 } // namespace chrome |
OLD | NEW |