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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/strings/string_tokenizer.h" | 14 #include "base/strings/string_tokenizer.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/common/child_process_logging.h" | 17 #include "chrome/common/child_process_logging.h" |
18 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/content_settings_pattern.h" | 21 #include "chrome/common/content_settings_pattern.h" |
22 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" | 22 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" |
| 23 #include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h" |
23 #include "chrome/common/extensions/background_info.h" | 24 #include "chrome/common/extensions/background_info.h" |
24 #include "chrome/common/extensions/csp_handler.h" | 25 #include "chrome/common/extensions/csp_handler.h" |
25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
27 #include "chrome/common/extensions/extension_manifest_constants.h" | 28 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 29 #include "chrome/common/extensions/extension_messages.h" |
28 #include "chrome/common/extensions/extension_process_policy.h" | 30 #include "chrome/common/extensions/extension_process_policy.h" |
29 #include "chrome/common/extensions/extension_set.h" | 31 #include "chrome/common/extensions/extension_set.h" |
30 #include "chrome/common/extensions/incognito_handler.h" | 32 #include "chrome/common/extensions/incognito_handler.h" |
31 #include "chrome/common/extensions/manifest_handler.h" | 33 #include "chrome/common/extensions/manifest_handler.h" |
32 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 34 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
33 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" |
34 #include "chrome/common/extensions/manifest_url_handler.h" | 36 #include "chrome/common/extensions/manifest_url_handler.h" |
35 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" | 37 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
36 #include "chrome/common/extensions/web_accessible_resources_handler.h" | 38 #include "chrome/common/extensions/web_accessible_resources_handler.h" |
37 #include "chrome/common/external_ipc_fuzzer.h" | 39 #include "chrome/common/external_ipc_fuzzer.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // fields used in the renderer. | 147 // fields used in the renderer. |
146 void RegisterExtensionManifestHandlers() { | 148 void RegisterExtensionManifestHandlers() { |
147 (new extensions::AppIsolationHandler)->Register(); | 149 (new extensions::AppIsolationHandler)->Register(); |
148 (new extensions::BackgroundManifestHandler)->Register(); | 150 (new extensions::BackgroundManifestHandler)->Register(); |
149 (new extensions::CSPHandler(false))->Register(); // not platform app. | 151 (new extensions::CSPHandler(false))->Register(); // not platform app. |
150 (new extensions::CSPHandler(true))->Register(); // platform app. | 152 (new extensions::CSPHandler(true))->Register(); // platform app. |
151 (new extensions::DevToolsPageHandler)->Register(); | 153 (new extensions::DevToolsPageHandler)->Register(); |
152 (new extensions::IncognitoHandler)->Register(); | 154 (new extensions::IncognitoHandler)->Register(); |
153 (new extensions::PageActionHandler)->Register(); | 155 (new extensions::PageActionHandler)->Register(); |
154 (new extensions::SandboxedPageHandler)->Register(); | 156 (new extensions::SandboxedPageHandler)->Register(); |
| 157 (new extensions::UrlHandlersParser)->Register(); |
155 (new extensions::WebAccessibleResourcesHandler)->Register(); | 158 (new extensions::WebAccessibleResourcesHandler)->Register(); |
156 } | 159 } |
157 | 160 |
158 static void AppendParams(const std::vector<string16>& additional_names, | 161 static void AppendParams(const std::vector<string16>& additional_names, |
159 const std::vector<string16>& additional_values, | 162 const std::vector<string16>& additional_values, |
160 WebVector<WebString>* existing_names, | 163 WebVector<WebString>* existing_names, |
161 WebVector<WebString>* existing_values) { | 164 WebVector<WebString>* existing_values) { |
162 DCHECK(additional_names.size() == additional_values.size()); | 165 DCHECK(additional_names.size() == additional_values.size()); |
163 DCHECK(existing_names->size() == existing_values->size()); | 166 DCHECK(existing_names->size() == existing_values->size()); |
164 | 167 |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 bool ChromeContentRendererClient::AllowPopup() { | 887 bool ChromeContentRendererClient::AllowPopup() { |
885 extensions::ChromeV8Context* current_context = | 888 extensions::ChromeV8Context* current_context = |
886 extension_dispatcher_->v8_context_set().GetCurrent(); | 889 extension_dispatcher_->v8_context_set().GetCurrent(); |
887 return current_context && current_context->extension() && | 890 return current_context && current_context->extension() && |
888 (current_context->context_type() == | 891 (current_context->context_type() == |
889 extensions::Feature::BLESSED_EXTENSION_CONTEXT || | 892 extensions::Feature::BLESSED_EXTENSION_CONTEXT || |
890 current_context->context_type() == | 893 current_context->context_type() == |
891 extensions::Feature::CONTENT_SCRIPT_CONTEXT); | 894 extensions::Feature::CONTENT_SCRIPT_CONTEXT); |
892 } | 895 } |
893 | 896 |
| 897 bool ChromeContentRendererClient::HandleNavigation( |
| 898 WebKit::WebFrame* frame, |
| 899 const WebKit::WebURLRequest& request, |
| 900 WebKit::WebNavigationType type, |
| 901 WebKit::WebNavigationPolicy default_policy, |
| 902 bool is_redirect) { |
| 903 const GURL& url = request.url(); |
| 904 GURL referrer_url(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 905 const ExtensionSet* exts = extension_dispatcher_->extensions(); |
| 906 const extensions::UrlHandlerInfo* handler = exts->GetHandlingAppForURL(url); |
| 907 if (handler) { |
| 908 // content::RenderView* view = GetRenderViewFromWebFrame(frame); |
| 909 // return RenderThread::Get()->Send( |
| 910 // new ExtensionHostMsg_OnRedirectUrlToApp( |
| 911 // view->GetRoutingID(), |
| 912 // handler->app->id(), |
| 913 // handler->id, |
| 914 // url, |
| 915 // referrer_url)); |
| 916 |
| 917 return RenderThread::Get()->Send( |
| 918 new ExtensionHostMsg_OnRedirectUrlToApp( |
| 919 handler->app->id(), |
| 920 handler->id, |
| 921 url, |
| 922 referrer_url)); |
| 923 } else { |
| 924 return false; |
| 925 } |
| 926 } |
| 927 |
894 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, | 928 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, |
895 const GURL& url, | 929 const GURL& url, |
896 const std::string& http_method, | 930 const std::string& http_method, |
897 bool is_initial_navigation, | 931 bool is_initial_navigation, |
898 bool* send_referrer) { | 932 bool* send_referrer) { |
899 DCHECK(!frame->parent()); | 933 DCHECK(!frame->parent()); |
900 | 934 |
901 // If this is the Instant process, fork all navigations originating from the | 935 // If this is the Instant process, fork all navigations originating from the |
902 // renderer. The destination page will then be bucketed back to this Instant | 936 // renderer. The destination page will then be bucketed back to this Instant |
903 // process if it is an Instant url, or to another process if not. | 937 // process if it is an Instant url, or to another process if not. |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 | 1266 |
1233 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { | 1267 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { |
1234 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) | 1268 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) |
1235 return true; | 1269 return true; |
1236 } | 1270 } |
1237 | 1271 |
1238 return false; | 1272 return false; |
1239 } | 1273 } |
1240 | 1274 |
1241 } // namespace chrome | 1275 } // namespace chrome |
OLD | NEW |