| 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" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 manifest_url = url; | 580 manifest_url = url; |
| 581 app_url = frame->top()->document().url(); | 581 app_url = frame->top()->document().url(); |
| 582 } else { | 582 } else { |
| 583 // NaCl is being invoked as a content handler. Look up the NaCl | 583 // NaCl is being invoked as a content handler. Look up the NaCl |
| 584 // module using the MIME type. The app URL is the manifest URL. | 584 // module using the MIME type. The app URL is the manifest URL. |
| 585 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); | 585 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); |
| 586 app_url = manifest_url; | 586 app_url = manifest_url; |
| 587 } | 587 } |
| 588 const Extension* extension = | 588 const Extension* extension = |
| 589 g_current_client->extension_dispatcher_->extensions()-> | 589 g_current_client->extension_dispatcher_->extensions()-> |
| 590 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url)); | 590 GetExtensionOrAppByURL(manifest_url); |
| 591 if (!IsNaClAllowed(manifest_url, | 591 if (!IsNaClAllowed(manifest_url, |
| 592 app_url, | 592 app_url, |
| 593 is_nacl_unrestricted, | 593 is_nacl_unrestricted, |
| 594 extension, | 594 extension, |
| 595 ¶ms)) { | 595 ¶ms)) { |
| 596 frame->addMessageToConsole( | 596 frame->addMessageToConsole( |
| 597 WebConsoleMessage( | 597 WebConsoleMessage( |
| 598 WebConsoleMessage::LevelError, | 598 WebConsoleMessage::LevelError, |
| 599 "Only unpacked extensions and apps installed from the " | 599 "Only unpacked extensions and apps installed from the " |
| 600 "Chrome Web Store can load NaCl modules without enabling " | 600 "Chrome Web Store can load NaCl modules without enabling " |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 const WebKit::WebURLRequest& failed_request, | 819 const WebKit::WebURLRequest& failed_request, |
| 820 const WebKit::WebURLError& error, | 820 const WebKit::WebURLError& error, |
| 821 std::string* error_html, | 821 std::string* error_html, |
| 822 string16* error_description) { | 822 string16* error_description) { |
| 823 const GURL failed_url = error.unreachableURL; | 823 const GURL failed_url = error.unreachableURL; |
| 824 const Extension* extension = NULL; | 824 const Extension* extension = NULL; |
| 825 | 825 |
| 826 if (failed_url.is_valid() && | 826 if (failed_url.is_valid() && |
| 827 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 827 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
| 828 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 828 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
| 829 ExtensionURLInfo(failed_url)); | 829 failed_url); |
| 830 } | 830 } |
| 831 | 831 |
| 832 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | 832 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); |
| 833 | 833 |
| 834 if (error_html) { | 834 if (error_html) { |
| 835 // Use a local error page. | 835 // Use a local error page. |
| 836 int resource_id; | 836 int resource_id; |
| 837 DictionaryValue error_strings; | 837 DictionaryValue error_strings; |
| 838 if (extension && !extension->from_bookmark()) { | 838 if (extension && !extension->from_bookmark()) { |
| 839 LocalizedError::GetAppErrorStrings(error, failed_url, extension, | 839 LocalizedError::GetAppErrorStrings(error, failed_url, extension, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 // to swap in the prerendered page on the browser process. If the prerendered | 918 // to swap in the prerendered page on the browser process. If the prerendered |
| 919 // page no longer exists by the time the OpenURL IPC is handled, a normal | 919 // page no longer exists by the time the OpenURL IPC is handled, a normal |
| 920 // navigation is attempted. | 920 // navigation is attempted. |
| 921 if (prerender_dispatcher_.get() && prerender_dispatcher_->IsPrerenderURL(url)) | 921 if (prerender_dispatcher_.get() && prerender_dispatcher_->IsPrerenderURL(url)) |
| 922 return true; | 922 return true; |
| 923 | 923 |
| 924 const ExtensionSet* extensions = extension_dispatcher_->extensions(); | 924 const ExtensionSet* extensions = extension_dispatcher_->extensions(); |
| 925 | 925 |
| 926 // Determine if the new URL is an extension (excluding bookmark apps). | 926 // Determine if the new URL is an extension (excluding bookmark apps). |
| 927 const Extension* new_url_extension = extensions::GetNonBookmarkAppExtension( | 927 const Extension* new_url_extension = extensions::GetNonBookmarkAppExtension( |
| 928 *extensions, ExtensionURLInfo(url)); | 928 *extensions, url); |
| 929 bool is_extension_url = !!new_url_extension; | 929 bool is_extension_url = !!new_url_extension; |
| 930 | 930 |
| 931 // If the navigation would cross an app extent boundary, we also need | 931 // If the navigation would cross an app extent boundary, we also need |
| 932 // to defer to the browser to ensure process isolation. This is not necessary | 932 // to defer to the browser to ensure process isolation. This is not necessary |
| 933 // for server redirects, which will be transferred to a new process by the | 933 // for server redirects, which will be transferred to a new process by the |
| 934 // browser process when they are ready to commit. It is necessary for client | 934 // browser process when they are ready to commit. It is necessary for client |
| 935 // redirects, which won't be transferred in the same way. | 935 // redirects, which won't be transferred in the same way. |
| 936 if (!is_server_redirect && | 936 if (!is_server_redirect && |
| 937 CrossesExtensionExtents(frame, url, *extensions, is_extension_url, | 937 CrossesExtensionExtents(frame, url, *extensions, is_extension_url, |
| 938 is_initial_navigation)) { | 938 is_initial_navigation)) { |
| 939 // Include the referrer in this case since we're going from a hosted web | 939 // Include the referrer in this case since we're going from a hosted web |
| 940 // page. (the packaged case is handled previously by the extension | 940 // page. (the packaged case is handled previously by the extension |
| 941 // navigation test) | 941 // navigation test) |
| 942 *send_referrer = true; | 942 *send_referrer = true; |
| 943 | 943 |
| 944 const Extension* extension = | 944 const Extension* extension = |
| 945 extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 945 extension_dispatcher_->extensions()->GetExtensionOrAppByURL(url); |
| 946 ExtensionURLInfo(url)); | |
| 947 if (extension && extension->is_app()) { | 946 if (extension && extension->is_app()) { |
| 948 UMA_HISTOGRAM_ENUMERATION( | 947 UMA_HISTOGRAM_ENUMERATION( |
| 949 extension->is_platform_app() ? | 948 extension->is_platform_app() ? |
| 950 extension_misc::kPlatformAppLaunchHistogram : | 949 extension_misc::kPlatformAppLaunchHistogram : |
| 951 extension_misc::kAppLaunchHistogram, | 950 extension_misc::kAppLaunchHistogram, |
| 952 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, | 951 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, |
| 953 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 952 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 954 } | 953 } |
| 955 return true; | 954 return true; |
| 956 } | 955 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 bool is_initial_navigation) { | 1096 bool is_initial_navigation) { |
| 1098 GURL old_url(frame->top()->document().url()); | 1097 GURL old_url(frame->top()->document().url()); |
| 1099 | 1098 |
| 1100 // If old_url is still empty and this is an initial navigation, then this is | 1099 // If old_url is still empty and this is an initial navigation, then this is |
| 1101 // a window.open operation. We should look at the opener URL. | 1100 // a window.open operation. We should look at the opener URL. |
| 1102 if (is_initial_navigation && old_url.is_empty() && frame->opener()) { | 1101 if (is_initial_navigation && old_url.is_empty() && frame->opener()) { |
| 1103 // If we're about to open a normal web page from a same-origin opener stuck | 1102 // If we're about to open a normal web page from a same-origin opener stuck |
| 1104 // in an extension process, we want to keep it in process to allow the | 1103 // in an extension process, we want to keep it in process to allow the |
| 1105 // opener to script it. | 1104 // opener to script it. |
| 1106 WebDocument opener_document = frame->opener()->document(); | 1105 WebDocument opener_document = frame->opener()->document(); |
| 1107 GURL opener_url = opener_document.url(); | |
| 1108 WebSecurityOrigin opener_origin = opener_document.securityOrigin(); | |
| 1109 bool opener_is_extension_url = !!extensions.GetExtensionOrAppByURL( | |
| 1110 ExtensionURLInfo(opener_origin, opener_url)); | |
| 1111 WebSecurityOrigin opener = frame->opener()->document().securityOrigin(); | 1106 WebSecurityOrigin opener = frame->opener()->document().securityOrigin(); |
| 1107 bool opener_is_extension_url = |
| 1108 !opener.isUnique() && !!extensions.GetExtensionOrAppByURL( |
| 1109 opener_document.url()); |
| 1112 if (!is_extension_url && | 1110 if (!is_extension_url && |
| 1113 !opener_is_extension_url && | 1111 !opener_is_extension_url && |
| 1114 extension_dispatcher_->is_extension_process() && | 1112 extension_dispatcher_->is_extension_process() && |
| 1115 opener.canRequest(WebURL(new_url))) | 1113 opener.canRequest(WebURL(new_url))) |
| 1116 return false; | 1114 return false; |
| 1117 | 1115 |
| 1118 // In all other cases, we want to compare against the top frame's URL (as | 1116 // In all other cases, we want to compare against the top frame's URL (as |
| 1119 // opposed to the opener frame's), since that's what determines the type of | 1117 // opposed to the opener frame's), since that's what determines the type of |
| 1120 // process. This allows iframes outside an app to open a popup in the app. | 1118 // process. This allows iframes outside an app to open a popup in the app. |
| 1121 old_url = frame->top()->opener()->top()->document().url(); | 1119 old_url = frame->top()->opener()->top()->document().url(); |
| 1122 } | 1120 } |
| 1123 | 1121 |
| 1124 // Only consider keeping non-app URLs in an app process if this window | 1122 // Only consider keeping non-app URLs in an app process if this window |
| 1125 // has an opener (in which case it might be an OAuth popup that tries to | 1123 // has an opener (in which case it might be an OAuth popup that tries to |
| 1126 // script an iframe within the app). | 1124 // script an iframe within the app). |
| 1127 bool should_consider_workaround = !!frame->opener(); | 1125 bool should_consider_workaround = !!frame->opener(); |
| 1128 | 1126 |
| 1129 return extensions::CrossesExtensionProcessBoundary( | 1127 return extensions::CrossesExtensionProcessBoundary( |
| 1130 extensions, ExtensionURLInfo(old_url), ExtensionURLInfo(new_url), | 1128 extensions, old_url, new_url, should_consider_workaround); |
| 1131 should_consider_workaround); | |
| 1132 } | 1129 } |
| 1133 | 1130 |
| 1134 void ChromeContentRendererClient::SetSpellcheck(SpellCheck* spellcheck) { | 1131 void ChromeContentRendererClient::SetSpellcheck(SpellCheck* spellcheck) { |
| 1135 RenderThread* thread = RenderThread::Get(); | 1132 RenderThread* thread = RenderThread::Get(); |
| 1136 if (spellcheck_.get() && thread) | 1133 if (spellcheck_.get() && thread) |
| 1137 thread->RemoveObserver(spellcheck_.get()); | 1134 thread->RemoveObserver(spellcheck_.get()); |
| 1138 spellcheck_.reset(spellcheck); | 1135 spellcheck_.reset(spellcheck); |
| 1139 SpellCheckReplacer replacer(spellcheck_.get()); | 1136 SpellCheckReplacer replacer(spellcheck_.get()); |
| 1140 content::RenderView::ForEach(&replacer); | 1137 content::RenderView::ForEach(&replacer); |
| 1141 if (thread) | 1138 if (thread) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 | 1202 |
| 1206 if (container->element().shadowHost().isNull()) | 1203 if (container->element().shadowHost().isNull()) |
| 1207 return false; | 1204 return false; |
| 1208 | 1205 |
| 1209 WebString tag_name = container->element().shadowHost().tagName(); | 1206 WebString tag_name = container->element().shadowHost().tagName(); |
| 1210 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1207 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
| 1211 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1208 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
| 1212 } | 1209 } |
| 1213 | 1210 |
| 1214 } // namespace chrome | 1211 } // namespace chrome |
| OLD | NEW |