Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 22944002: Implementation of the "Redirect URLs to Packaged Apps" feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fully reverted extension_service.cc to original form Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
28 #include "chrome/common/extensions/extension_process_policy.h" 29 #include "chrome/common/extensions/extension_process_policy.h"
29 #include "chrome/common/extensions/extension_set.h" 30 #include "chrome/common/extensions/extension_set.h"
30 #include "chrome/common/extensions/incognito_handler.h" 31 #include "chrome/common/extensions/incognito_handler.h"
31 #include "chrome/common/extensions/manifest_handler.h" 32 #include "chrome/common/extensions/manifest_handler.h"
32 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" 33 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 70 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
70 #include "chrome/renderer/searchbox/searchbox.h" 71 #include "chrome/renderer/searchbox/searchbox.h"
71 #include "chrome/renderer/searchbox/searchbox_extension.h" 72 #include "chrome/renderer/searchbox/searchbox_extension.h"
72 #include "chrome/renderer/spellchecker/spellcheck.h" 73 #include "chrome/renderer/spellchecker/spellcheck.h"
73 #include "chrome/renderer/spellchecker/spellcheck_provider.h" 74 #include "chrome/renderer/spellchecker/spellcheck_provider.h"
74 #include "components/autofill/renderer/autofill_agent.h" 75 #include "components/autofill/renderer/autofill_agent.h"
75 #include "components/autofill/renderer/password_autofill_agent.h" 76 #include "components/autofill/renderer/password_autofill_agent.h"
76 #include "components/autofill/renderer/password_generation_manager.h" 77 #include "components/autofill/renderer/password_generation_manager.h"
77 #include "components/visitedlink/renderer/visitedlink_slave.h" 78 #include "components/visitedlink/renderer/visitedlink_slave.h"
78 #include "content/public/common/content_constants.h" 79 #include "content/public/common/content_constants.h"
80 #include "content/public/common/url_handling_messages.h"
79 #include "content/public/renderer/render_thread.h" 81 #include "content/public/renderer/render_thread.h"
80 #include "content/public/renderer/render_view.h" 82 #include "content/public/renderer/render_view.h"
81 #include "content/public/renderer/render_view_visitor.h" 83 #include "content/public/renderer/render_view_visitor.h"
82 #include "extensions/common/constants.h" 84 #include "extensions/common/constants.h"
83 #include "grit/generated_resources.h" 85 #include "grit/generated_resources.h"
84 #include "grit/locale_settings.h" 86 #include "grit/locale_settings.h"
85 #include "grit/renderer_resources.h" 87 #include "grit/renderer_resources.h"
86 #include "ipc/ipc_sync_channel.h" 88 #include "ipc/ipc_sync_channel.h"
87 #include "net/base/net_errors.h" 89 #include "net/base/net_errors.h"
88 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" 90 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
89 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" 91 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h"
90 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" 92 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
100 #include "ui/base/l10n/l10n_util.h" 103 #include "ui/base/l10n/l10n_util.h"
101 #include "ui/base/layout.h" 104 #include "ui/base/layout.h"
102 #include "ui/base/resource/resource_bundle.h" 105 #include "ui/base/resource/resource_bundle.h"
103 #include "ui/webui/jstemplate_builder.h" 106 #include "ui/webui/jstemplate_builder.h"
104 #include "webkit/plugins/npapi/plugin_list.h" 107 #include "webkit/plugins/npapi/plugin_list.h"
105 #include "webkit/plugins/ppapi/plugin_module.h" 108 #include "webkit/plugins/ppapi/plugin_module.h"
(...skipping 20 matching lines...) Expand all
126 using webkit::WebPluginMimeType; 129 using webkit::WebPluginMimeType;
127 using WebKit::WebPluginParams; 130 using WebKit::WebPluginParams;
128 using WebKit::WebSecurityOrigin; 131 using WebKit::WebSecurityOrigin;
129 using WebKit::WebSecurityPolicy; 132 using WebKit::WebSecurityPolicy;
130 using WebKit::WebString; 133 using WebKit::WebString;
131 using WebKit::WebURL; 134 using WebKit::WebURL;
132 using WebKit::WebURLError; 135 using WebKit::WebURLError;
133 using WebKit::WebURLRequest; 136 using WebKit::WebURLRequest;
134 using WebKit::WebURLResponse; 137 using WebKit::WebURLResponse;
135 using WebKit::WebVector; 138 using WebKit::WebVector;
139 using WebKit::WebNavigationType;
136 140
137 namespace { 141 namespace {
138 142
139 const char kWebViewTagName[] = "WEBVIEW"; 143 const char kWebViewTagName[] = "WEBVIEW";
140 const char kAdViewTagName[] = "ADVIEW"; 144 const char kAdViewTagName[] = "ADVIEW";
141 145
142 chrome::ChromeContentRendererClient* g_current_client; 146 chrome::ChromeContentRendererClient* g_current_client;
143 147
144 // Explicitly register all extension ManifestHandlers needed to parse 148 // Explicitly register all extension ManifestHandlers needed to parse
145 // fields used in the renderer. 149 // fields used in the renderer.
146 void RegisterExtensionManifestHandlers() { 150 void RegisterExtensionManifestHandlers() {
147 (new extensions::AppIsolationHandler)->Register(); 151 (new extensions::AppIsolationHandler)->Register();
148 (new extensions::BackgroundManifestHandler)->Register(); 152 (new extensions::BackgroundManifestHandler)->Register();
149 (new extensions::CSPHandler(false))->Register(); // not platform app. 153 (new extensions::CSPHandler(false))->Register(); // not platform app.
150 (new extensions::CSPHandler(true))->Register(); // platform app. 154 (new extensions::CSPHandler(true))->Register(); // platform app.
151 (new extensions::DevToolsPageHandler)->Register(); 155 (new extensions::DevToolsPageHandler)->Register();
152 (new extensions::IncognitoHandler)->Register(); 156 (new extensions::IncognitoHandler)->Register();
153 (new extensions::PageActionHandler)->Register(); 157 (new extensions::PageActionHandler)->Register();
154 (new extensions::SandboxedPageHandler)->Register(); 158 (new extensions::SandboxedPageHandler)->Register();
159 (new extensions::UrlHandlersParser)->Register();
155 (new extensions::WebAccessibleResourcesHandler)->Register(); 160 (new extensions::WebAccessibleResourcesHandler)->Register();
156 } 161 }
157 162
158 static void AppendParams(const std::vector<string16>& additional_names, 163 static void AppendParams(const std::vector<string16>& additional_names,
159 const std::vector<string16>& additional_values, 164 const std::vector<string16>& additional_values,
160 WebVector<WebString>* existing_names, 165 WebVector<WebString>* existing_names,
161 WebVector<WebString>* existing_values) { 166 WebVector<WebString>* existing_values) {
162 DCHECK(additional_names.size() == additional_values.size()); 167 DCHECK(additional_names.size() == additional_values.size());
163 DCHECK(existing_names->size() == existing_values->size()); 168 DCHECK(existing_names->size() == existing_values->size());
164 169
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 bool ChromeContentRendererClient::AllowPopup() { 889 bool ChromeContentRendererClient::AllowPopup() {
885 extensions::ChromeV8Context* current_context = 890 extensions::ChromeV8Context* current_context =
886 extension_dispatcher_->v8_context_set().GetCurrent(); 891 extension_dispatcher_->v8_context_set().GetCurrent();
887 return current_context && current_context->extension() && 892 return current_context && current_context->extension() &&
888 (current_context->context_type() == 893 (current_context->context_type() ==
889 extensions::Feature::BLESSED_EXTENSION_CONTEXT || 894 extensions::Feature::BLESSED_EXTENSION_CONTEXT ||
890 current_context->context_type() == 895 current_context->context_type() ==
891 extensions::Feature::CONTENT_SCRIPT_CONTEXT); 896 extensions::Feature::CONTENT_SCRIPT_CONTEXT);
892 } 897 }
893 898
899 bool ChromeContentRendererClient::HandleNavigation(
900 WebKit::WebFrame* frame,
901 const WebKit::WebURLRequest& request,
902 WebKit::WebNavigationType type,
903 WebKit::WebNavigationPolicy default_policy,
904 bool is_redirect) {
905 switch (type) {
906 // For user-initiated gestures, try to find a platform app that has
907 // registered a URL handler that matches the URL being navigated to.
908 // If found, delegate further URL processing to the browser (the browser
909 // is supposed to launch the app), and return true to cancel navigation on
910 // on the renderer side. Otherwise, return false to continue navigation.
911 case WebKit::WebNavigationTypeLinkClicked:
912 case WebKit::WebNavigationTypeFormSubmitted:
913 case WebKit::WebNavigationTypeFormResubmitted: {
914 const GURL& url = request.url();
915 const ExtensionSet* exts = extension_dispatcher_->extensions();
916 for (ExtensionSet::const_iterator it = exts->begin();
917 it != exts->end(); ++it) {
918 if (extensions::UrlHandlers::CanExtensionHandleUrl(*it, url)) {
919 const GURL referrer_url(
920 request.httpHeaderField(WebString::fromUTF8("Referer")));
921 return RenderThread::Get()->Send(
922 new RendererHostMsg_ForwardUrlToBrowser(url, referrer_url));
not at google - send to devlin 2013/08/29 17:35:56 I wonder whether there are any issues here with th
sergeygs 2013/09/02 07:36:21 In this first version, apps are severely restricte
923 }
924 }
925 break;
926 }
927
928 default:
929 break;
930 }
931 return false;
932 }
933
894 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, 934 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame,
895 const GURL& url, 935 const GURL& url,
896 const std::string& http_method, 936 const std::string& http_method,
897 bool is_initial_navigation, 937 bool is_initial_navigation,
898 bool* send_referrer) { 938 bool* send_referrer) {
899 DCHECK(!frame->parent()); 939 DCHECK(!frame->parent());
900 940
901 // If this is the Instant process, fork all navigations originating from the 941 // 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 942 // 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. 943 // 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
1232 1272
1233 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { 1273 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])) 1274 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i]))
1235 return true; 1275 return true;
1236 } 1276 }
1237 1277
1238 return false; 1278 return false;
1239 } 1279 }
1240 1280
1241 } // namespace chrome 1281 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698