Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" | 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" |
| 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" | 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
| 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" | 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" |
| 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
| 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" | 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
| 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
| 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" | 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" |
| 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
| 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebReferrerPolicy.h" | |
| 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" | 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" |
| 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
| 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
| 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h " | 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h " |
| 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" | 125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" |
| 125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 127 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 using WebKit::WebPageSerializer; | 208 using WebKit::WebPageSerializer; |
| 208 using WebKit::WebPageSerializerClient; | 209 using WebKit::WebPageSerializerClient; |
| 209 using WebKit::WebPlugin; | 210 using WebKit::WebPlugin; |
| 210 using WebKit::WebPluginContainer; | 211 using WebKit::WebPluginContainer; |
| 211 using WebKit::WebPluginDocument; | 212 using WebKit::WebPluginDocument; |
| 212 using WebKit::WebPluginParams; | 213 using WebKit::WebPluginParams; |
| 213 using WebKit::WebPoint; | 214 using WebKit::WebPoint; |
| 214 using WebKit::WebPopupMenuInfo; | 215 using WebKit::WebPopupMenuInfo; |
| 215 using WebKit::WebRange; | 216 using WebKit::WebRange; |
| 216 using WebKit::WebRect; | 217 using WebKit::WebRect; |
| 218 using WebKit::WebReferrerPolicy; | |
| 217 using WebKit::WebScriptSource; | 219 using WebKit::WebScriptSource; |
| 218 using WebKit::WebSearchableFormData; | 220 using WebKit::WebSearchableFormData; |
| 219 using WebKit::WebSecurityOrigin; | 221 using WebKit::WebSecurityOrigin; |
| 220 using WebKit::WebSecurityPolicy; | 222 using WebKit::WebSecurityPolicy; |
| 221 using WebKit::WebSettings; | 223 using WebKit::WebSettings; |
| 222 using WebKit::WebSharedWorker; | 224 using WebKit::WebSharedWorker; |
| 223 using WebKit::WebSize; | 225 using WebKit::WebSize; |
| 224 using WebKit::WebStorageNamespace; | 226 using WebKit::WebStorageNamespace; |
| 225 using WebKit::WebStorageQuotaCallbacks; | 227 using WebKit::WebStorageQuotaCallbacks; |
| 226 using WebKit::WebStorageQuotaError; | 228 using WebKit::WebStorageQuotaError; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 240 using WebKit::WebWorker; | 242 using WebKit::WebWorker; |
| 241 using WebKit::WebWorkerClient; | 243 using WebKit::WebWorkerClient; |
| 242 using appcache::WebApplicationCacheHostImpl; | 244 using appcache::WebApplicationCacheHostImpl; |
| 243 using base::Time; | 245 using base::Time; |
| 244 using base::TimeDelta; | 246 using base::TimeDelta; |
| 245 using content::DocumentState; | 247 using content::DocumentState; |
| 246 using content::NavigationState; | 248 using content::NavigationState; |
| 247 using content::RenderThread; | 249 using content::RenderThread; |
| 248 using content::RenderViewObserver; | 250 using content::RenderViewObserver; |
| 249 using content::RenderViewVisitor; | 251 using content::RenderViewVisitor; |
| 252 using content::Referrer; | |
| 250 using content::V8ValueConverter; | 253 using content::V8ValueConverter; |
| 251 using webkit_glue::AltErrorPageResourceFetcher; | 254 using webkit_glue::AltErrorPageResourceFetcher; |
| 252 using webkit_glue::FormField; | 255 using webkit_glue::FormField; |
| 253 using webkit_glue::PasswordForm; | 256 using webkit_glue::PasswordForm; |
| 254 using webkit_glue::PasswordFormDomManager; | 257 using webkit_glue::PasswordFormDomManager; |
| 255 using webkit_glue::ResourceFetcher; | 258 using webkit_glue::ResourceFetcher; |
| 256 | 259 |
| 257 //----------------------------------------------------------------------------- | 260 //----------------------------------------------------------------------------- |
| 258 | 261 |
| 259 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; | 262 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 document_state->set_alt_error_page_fetcher(NULL); | 303 document_state->set_alt_error_page_fetcher(NULL); |
| 301 } | 304 } |
| 302 } | 305 } |
| 303 | 306 |
| 304 static bool IsReload(const ViewMsg_Navigate_Params& params) { | 307 static bool IsReload(const ViewMsg_Navigate_Params& params) { |
| 305 return | 308 return |
| 306 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 309 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
| 307 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 310 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 308 } | 311 } |
| 309 | 312 |
| 313 static WebReferrerPolicy getReferrerPolicyFromRequest( | |
| 314 const WebURLRequest& request) { | |
| 315 return request.extraData() ? | |
| 316 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : | |
| 317 WebKit::WebReferrerPolicyDefault; | |
| 318 } | |
| 319 | |
| 310 /////////////////////////////////////////////////////////////////////////////// | 320 /////////////////////////////////////////////////////////////////////////////// |
| 311 | 321 |
| 312 int32 RenderViewImpl::next_page_id_ = 1; | 322 int32 RenderViewImpl::next_page_id_ = 1; |
| 313 | 323 |
| 314 struct RenderViewImpl::PendingFileChooser { | 324 struct RenderViewImpl::PendingFileChooser { |
| 315 PendingFileChooser(const content::FileChooserParams& p, | 325 PendingFileChooser(const content::FileChooserParams& p, |
| 316 WebFileChooserCompletion* c) | 326 WebFileChooserCompletion* c) |
| 317 : params(p), | 327 : params(p), |
| 318 completion(c) { | 328 completion(c) { |
| 319 } | 329 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 } else { | 812 } else { |
| 803 // Navigate to the given URL. | 813 // Navigate to the given URL. |
| 804 WebURLRequest request(params.url); | 814 WebURLRequest request(params.url); |
| 805 | 815 |
| 806 // A session history navigation should have been accompanied by state. | 816 // A session history navigation should have been accompanied by state. |
| 807 DCHECK_EQ(params.page_id, -1); | 817 DCHECK_EQ(params.page_id, -1); |
| 808 | 818 |
| 809 if (main_frame->isViewSourceModeEnabled()) | 819 if (main_frame->isViewSourceModeEnabled()) |
| 810 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); | 820 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
| 811 | 821 |
| 812 if (params.referrer.is_valid()) { | 822 if (params.referrer.url.is_valid()) { |
| 813 if (!WebSecurityPolicy::shouldHideReferrer( | 823 WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
| 814 params.url, | 824 params.referrer.policy, |
| 815 WebString::fromUTF8(params.referrer.spec()))) { | 825 params.url, |
| 816 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), | 826 WebString::fromUTF8(params.referrer.url.spec())); |
| 817 WebString::fromUTF8(params.referrer.spec())); | 827 if (!referrer.isEmpty()) |
| 818 } | 828 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); |
| 819 } | 829 } |
| 820 | 830 |
| 821 if (!params.extra_headers.empty()) { | 831 if (!params.extra_headers.empty()) { |
| 822 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | 832 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 823 params.extra_headers.end(), "\n"); | 833 params.extra_headers.end(), "\n"); |
| 824 i.GetNext(); ) { | 834 i.GetNext(); ) { |
| 825 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 835 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 826 WebString::fromUTF8(i.values())); | 836 WebString::fromUTF8(i.values())); |
| 827 } | 837 } |
| 828 } | 838 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1174 // MANUAL_SUBFRAME, it will be that same transition type here. | 1184 // MANUAL_SUBFRAME, it will be that same transition type here. |
| 1175 // We don't want that, because any navigation that changes the toplevel | 1185 // We don't want that, because any navigation that changes the toplevel |
| 1176 // frame should be tracked as a toplevel navigation (this allows us to | 1186 // frame should be tracked as a toplevel navigation (this allows us to |
| 1177 // update the URL bar, etc). | 1187 // update the URL bar, etc). |
| 1178 params.transition = content::PAGE_TRANSITION_LINK; | 1188 params.transition = content::PAGE_TRANSITION_LINK; |
| 1179 } | 1189 } |
| 1180 | 1190 |
| 1181 // If we have a valid consumed client redirect source, | 1191 // If we have a valid consumed client redirect source, |
| 1182 // the page contained a client redirect (meta refresh, document.loc...), | 1192 // the page contained a client redirect (meta refresh, document.loc...), |
| 1183 // so we set the referrer and transition to match. | 1193 // so we set the referrer and transition to match. |
| 1184 if (completed_client_redirect_src_.is_valid()) { | 1194 if (completed_client_redirect_src_.url.is_valid()) { |
| 1185 DCHECK(completed_client_redirect_src_ == params.redirects[0]); | 1195 DCHECK(completed_client_redirect_src_.url == params.redirects[0]); |
| 1186 params.referrer = completed_client_redirect_src_; | 1196 params.referrer = completed_client_redirect_src_; |
| 1187 params.transition = static_cast<content::PageTransition>( | 1197 params.transition = static_cast<content::PageTransition>( |
| 1188 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); | 1198 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); |
| 1189 } else { | 1199 } else { |
| 1190 // Bug 654101: the referrer will be empty on https->http transitions. It | 1200 // Bug 654101: the referrer will be empty on https->http transitions. It |
| 1191 // would be nice if we could get the real referrer from somewhere. | 1201 // would be nice if we could get the real referrer from somewhere. |
| 1192 params.referrer = GURL( | 1202 params.referrer = Referrer(GURL( |
| 1193 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); | 1203 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 1204 getReferrerPolicyFromRequest(original_request)); | |
| 1194 } | 1205 } |
| 1195 | 1206 |
| 1196 string16 method = request.httpMethod(); | 1207 string16 method = request.httpMethod(); |
| 1197 if (EqualsASCII(method, "POST")) | 1208 if (EqualsASCII(method, "POST")) |
| 1198 params.is_post = true; | 1209 params.is_post = true; |
| 1199 | 1210 |
| 1200 // Save some histogram data so we can compute the average memory used per | 1211 // Save some histogram data so we can compute the average memory used per |
| 1201 // page load of the glyphs. | 1212 // page load of the glyphs. |
| 1202 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 1213 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
| 1203 webkit_glue::GetGlyphPageCount()); | 1214 webkit_glue::GetGlyphPageCount()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 webview()->mainFrame()->previousHistoryItem(); | 1279 webview()->mainFrame()->previousHistoryItem(); |
| 1269 if (item.isNull()) | 1280 if (item.isNull()) |
| 1270 return; | 1281 return; |
| 1271 | 1282 |
| 1272 Send(new ViewHostMsg_UpdateState( | 1283 Send(new ViewHostMsg_UpdateState( |
| 1273 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1284 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
| 1274 } | 1285 } |
| 1275 | 1286 |
| 1276 void RenderViewImpl::OpenURL(WebFrame* frame, | 1287 void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1277 const GURL& url, | 1288 const GURL& url, |
| 1278 const GURL& referrer, | 1289 const Referrer& referrer, |
| 1279 WebNavigationPolicy policy) { | 1290 WebNavigationPolicy policy) { |
| 1280 Send(new ViewHostMsg_OpenURL( | 1291 Send(new ViewHostMsg_OpenURL( |
| 1281 routing_id_, | 1292 routing_id_, |
| 1282 url, | 1293 url, |
| 1283 referrer, | 1294 referrer, |
| 1284 NavigationPolicyToDisposition(policy), | 1295 NavigationPolicyToDisposition(policy), |
| 1285 frame->identifier())); | 1296 frame->identifier())); |
| 1286 } | 1297 } |
| 1287 | 1298 |
| 1288 // WebViewDelegate ------------------------------------------------------------ | 1299 // WebViewDelegate ------------------------------------------------------------ |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2012 | 2023 |
| 2013 void RenderViewImpl::loadURLExternally( | 2024 void RenderViewImpl::loadURLExternally( |
| 2014 WebFrame* frame, const WebURLRequest& request, | 2025 WebFrame* frame, const WebURLRequest& request, |
| 2015 WebNavigationPolicy policy, | 2026 WebNavigationPolicy policy, |
| 2016 const WebString& suggested_name) { | 2027 const WebString& suggested_name) { |
| 2017 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2028 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2018 if (policy == WebKit::WebNavigationPolicyDownload) { | 2029 if (policy == WebKit::WebNavigationPolicyDownload) { |
| 2019 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, | 2030 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
| 2020 suggested_name)); | 2031 suggested_name)); |
| 2021 } else { | 2032 } else { |
| 2022 OpenURL(frame, request.url(), referrer, policy); | 2033 OpenURL(frame, request.url(), |
| 2034 Referrer(referrer, getReferrerPolicyFromRequest(request)), policy); | |
| 2023 } | 2035 } |
| 2024 } | 2036 } |
| 2025 | 2037 |
| 2026 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 2038 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
| 2027 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, | 2039 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
| 2028 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { | 2040 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
| 2029 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. | 2041 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
| 2030 if (is_swapped_out_) { | 2042 if (is_swapped_out_) { |
| 2031 DCHECK(request.url() == GURL("about:swappedout")); | 2043 DCHECK(request.url() == GURL("about:swappedout")); |
| 2032 return default_policy; | 2044 return default_policy; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2049 // boundaries. This is currently expected to break some script calls and | 2061 // boundaries. This is currently expected to break some script calls and |
| 2050 // navigations, such as form submissions. | 2062 // navigations, such as form submissions. |
| 2051 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 2063 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 2052 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && | 2064 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && |
| 2053 !frame->parent() && (is_content_initiated || is_redirect)) { | 2065 !frame->parent() && (is_content_initiated || is_redirect)) { |
| 2054 WebString origin_str = frame->document().securityOrigin().toString(); | 2066 WebString origin_str = frame->document().securityOrigin().toString(); |
| 2055 GURL frame_url(origin_str.utf8().data()); | 2067 GURL frame_url(origin_str.utf8().data()); |
| 2056 // TODO(cevans): revisit whether this origin check is still necessary once | 2068 // TODO(cevans): revisit whether this origin check is still necessary once |
| 2057 // crbug.com/101395 is fixed. | 2069 // crbug.com/101395 is fixed. |
| 2058 if (frame_url.GetOrigin() != url.GetOrigin()) { | 2070 if (frame_url.GetOrigin() != url.GetOrigin()) { |
| 2059 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2071 Referrer referrer( |
| 2072 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | |
| 2073 getReferrerPolicyFromRequest(request)); | |
| 2060 OpenURL(frame, url, referrer, default_policy); | 2074 OpenURL(frame, url, referrer, default_policy); |
| 2061 return WebKit::WebNavigationPolicyIgnore; | 2075 return WebKit::WebNavigationPolicyIgnore; |
| 2062 } | 2076 } |
| 2063 } | 2077 } |
| 2064 | 2078 |
| 2065 // If the browser is interested, then give it a chance to look at top level | 2079 // If the browser is interested, then give it a chance to look at top level |
| 2066 // navigations. | 2080 // navigations. |
| 2067 if (is_content_initiated && | 2081 if (is_content_initiated && |
| 2068 renderer_preferences_.browser_handles_top_level_requests && | 2082 renderer_preferences_.browser_handles_top_level_requests && |
| 2069 IsNonLocalTopLevelNavigation(url, frame, type)) { | 2083 IsNonLocalTopLevelNavigation(url, frame, type)) { |
| 2070 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2084 Referrer referrer( |
| 2085 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | |
| 2086 getReferrerPolicyFromRequest(request)); | |
| 2071 // Reset these counters as the RenderView could be reused for the next | 2087 // Reset these counters as the RenderView could be reused for the next |
| 2072 // navigation. | 2088 // navigation. |
| 2073 page_id_ = -1; | 2089 page_id_ = -1; |
| 2074 last_page_id_sent_to_browser_ = -1; | 2090 last_page_id_sent_to_browser_ = -1; |
| 2075 OpenURL(frame, url, referrer, default_policy); | 2091 OpenURL(frame, url, referrer, default_policy); |
| 2076 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2092 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2077 } | 2093 } |
| 2078 | 2094 |
| 2079 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 2095 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
| 2080 // an extension or app origin, leaving a WebUI page, etc). We only care about | 2096 // an extension or app origin, leaving a WebUI page, etc). We only care about |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2108 | 2124 |
| 2109 if (!should_fork) { | 2125 if (!should_fork) { |
| 2110 // Give the embedder a chance. | 2126 // Give the embedder a chance. |
| 2111 bool is_initial_navigation = page_id_ == -1; | 2127 bool is_initial_navigation = page_id_ == -1; |
| 2112 should_fork = content::GetContentClient()->renderer()->ShouldFork( | 2128 should_fork = content::GetContentClient()->renderer()->ShouldFork( |
| 2113 frame, url, is_content_initiated, is_initial_navigation, | 2129 frame, url, is_content_initiated, is_initial_navigation, |
| 2114 &send_referrer); | 2130 &send_referrer); |
| 2115 } | 2131 } |
| 2116 | 2132 |
| 2117 if (should_fork) { | 2133 if (should_fork) { |
| 2118 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2134 Referrer referrer( |
| 2119 OpenURL(frame, url, send_referrer ? referrer : GURL(), default_policy); | 2135 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2136 getReferrerPolicyFromRequest(request)); | |
| 2137 OpenURL( | |
| 2138 frame, url, send_referrer ? referrer : Referrer(), default_policy); | |
| 2120 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2139 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2121 } | 2140 } |
| 2122 } | 2141 } |
| 2123 | 2142 |
| 2124 // Use the frame's original request's URL rather than the document's URL for | 2143 // Use the frame's original request's URL rather than the document's URL for |
| 2125 // this check. For a popup, the document's URL may become the opener window's | 2144 // this check. For a popup, the document's URL may become the opener window's |
| 2126 // URL if the opener has called document.write. See http://crbug.com/93517. | 2145 // URL if the opener has called document.write. See http://crbug.com/93517. |
| 2127 GURL old_url(frame->dataSource()->request().url()); | 2146 GURL old_url(frame->dataSource()->request().url()); |
| 2128 | 2147 |
| 2129 // Detect when a page is "forking" a new tab that can be safely rendered in | 2148 // Detect when a page is "forking" a new tab that can be safely rendered in |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2179 frame->name().isNull() && | 2198 frame->name().isNull() && |
| 2180 // Another frame (with a non-empty creator) should have initiated the | 2199 // Another frame (with a non-empty creator) should have initiated the |
| 2181 // request, targeted at this frame. | 2200 // request, targeted at this frame. |
| 2182 !creator_url_.is_empty() && | 2201 !creator_url_.is_empty() && |
| 2183 is_content_initiated && | 2202 is_content_initiated && |
| 2184 default_policy == WebKit::WebNavigationPolicyCurrentTab && | 2203 default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2185 type == WebKit::WebNavigationTypeOther; | 2204 type == WebKit::WebNavigationTypeOther; |
| 2186 | 2205 |
| 2187 if (is_fork || is_noreferrer_and_blank_target) { | 2206 if (is_fork || is_noreferrer_and_blank_target) { |
| 2188 // Open the URL via the browser, not via WebKit. | 2207 // Open the URL via the browser, not via WebKit. |
| 2189 OpenURL(frame, url, GURL(), default_policy); | 2208 OpenURL(frame, url, Referrer(), default_policy); |
| 2190 return WebKit::WebNavigationPolicyIgnore; | 2209 return WebKit::WebNavigationPolicyIgnore; |
| 2191 } | 2210 } |
| 2192 | 2211 |
| 2193 return default_policy; | 2212 return default_policy; |
| 2194 } | 2213 } |
| 2195 | 2214 |
| 2196 bool RenderViewImpl::canHandleRequest( | 2215 bool RenderViewImpl::canHandleRequest( |
| 2197 WebFrame* frame, const WebURLRequest& request) { | 2216 WebFrame* frame, const WebURLRequest& request) { |
| 2198 // We allow WebKit to think that everything can be handled even though | 2217 // We allow WebKit to think that everything can be handled even though |
| 2199 // browser-side we limit what we load. | 2218 // browser-side we limit what we load. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2277 WillPerformClientRedirect(frame, from, to, interval, fire_time)); | 2296 WillPerformClientRedirect(frame, from, to, interval, fire_time)); |
| 2278 } | 2297 } |
| 2279 | 2298 |
| 2280 void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { | 2299 void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { |
| 2281 FOR_EACH_OBSERVER( | 2300 FOR_EACH_OBSERVER( |
| 2282 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); | 2301 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); |
| 2283 } | 2302 } |
| 2284 | 2303 |
| 2285 void RenderViewImpl::didCompleteClientRedirect( | 2304 void RenderViewImpl::didCompleteClientRedirect( |
| 2286 WebFrame* frame, const WebURL& from) { | 2305 WebFrame* frame, const WebURL& from) { |
| 2287 if (!frame->parent()) | 2306 if (!frame->parent()) { |
| 2288 completed_client_redirect_src_ = from; | 2307 WebDataSource* ds = frame->provisionalDataSource(); |
| 2308 // If there's no provisional data source, it's a reference fragment | |
| 2309 // navigation. | |
| 2310 completed_client_redirect_src_ = Referrer( | |
| 2311 from, ds ? getReferrerPolicyFromRequest(ds->request()) : | |
|
darin (slow to review)
2011/12/02 22:22:40
if the provisionalDataSource is null, then you sho
jochen (gone - plz use gerrit)
2011/12/02 22:24:39
Since it's an in-page navigation, we can use frame
| |
| 2312 WebKit::WebReferrerPolicyDefault); | |
| 2313 } | |
| 2289 FOR_EACH_OBSERVER( | 2314 FOR_EACH_OBSERVER( |
| 2290 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); | 2315 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
| 2291 } | 2316 } |
| 2292 | 2317 |
| 2293 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { | 2318 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
| 2294 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2319 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2295 if (!document_state) { | 2320 if (!document_state) { |
| 2296 document_state = new DocumentState; | 2321 document_state = new DocumentState; |
| 2297 ds->setExtraData(document_state); | 2322 ds->setExtraData(document_state); |
| 2298 } | 2323 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2408 | 2433 |
| 2409 // Start time is only set after request time. | 2434 // Start time is only set after request time. |
| 2410 document_state->set_start_load_time(Time::Now()); | 2435 document_state->set_start_load_time(Time::Now()); |
| 2411 | 2436 |
| 2412 bool is_top_most = !frame->parent(); | 2437 bool is_top_most = !frame->parent(); |
| 2413 if (is_top_most) { | 2438 if (is_top_most) { |
| 2414 navigation_gesture_ = frame->isProcessingUserGesture() ? | 2439 navigation_gesture_ = frame->isProcessingUserGesture() ? |
| 2415 NavigationGestureUser : NavigationGestureAuto; | 2440 NavigationGestureUser : NavigationGestureAuto; |
| 2416 | 2441 |
| 2417 // Make sure redirect tracking state is clear for the new load. | 2442 // Make sure redirect tracking state is clear for the new load. |
| 2418 completed_client_redirect_src_ = GURL(); | 2443 completed_client_redirect_src_ = Referrer(); |
| 2419 } else if (frame->parent()->isLoading()) { | 2444 } else if (frame->parent()->isLoading()) { |
| 2420 // Take note of AUTO_SUBFRAME loads here, so that we can know how to | 2445 // Take note of AUTO_SUBFRAME loads here, so that we can know how to |
| 2421 // load an error page. See didFailProvisionalLoad. | 2446 // load an error page. See didFailProvisionalLoad. |
| 2422 document_state->navigation_state()->set_transition_type( | 2447 document_state->navigation_state()->set_transition_type( |
| 2423 content::PAGE_TRANSITION_AUTO_SUBFRAME); | 2448 content::PAGE_TRANSITION_AUTO_SUBFRAME); |
| 2424 } | 2449 } |
| 2425 | 2450 |
| 2426 FOR_EACH_OBSERVER( | 2451 FOR_EACH_OBSERVER( |
| 2427 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); | 2452 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
| 2428 | 2453 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2598 // the session history again. We do this regardless of whether this is | 2623 // the session history again. We do this regardless of whether this is |
| 2599 // a session history navigation, because if we attempted a session history | 2624 // a session history navigation, because if we attempted a session history |
| 2600 // navigation without valid HistoryItem state, WebCore will think it is a | 2625 // navigation without valid HistoryItem state, WebCore will think it is a |
| 2601 // new navigation. | 2626 // new navigation. |
| 2602 navigation_state->set_request_committed(true); | 2627 navigation_state->set_request_committed(true); |
| 2603 | 2628 |
| 2604 UpdateURL(frame); | 2629 UpdateURL(frame); |
| 2605 | 2630 |
| 2606 // If this committed load was initiated by a client redirect, we're | 2631 // If this committed load was initiated by a client redirect, we're |
| 2607 // at the last stop now, so clear it. | 2632 // at the last stop now, so clear it. |
| 2608 completed_client_redirect_src_ = GURL(); | 2633 completed_client_redirect_src_ = Referrer(); |
| 2609 | 2634 |
| 2610 // Check whether we have new encoding name. | 2635 // Check whether we have new encoding name. |
| 2611 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2636 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 2612 } | 2637 } |
| 2613 | 2638 |
| 2614 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 2639 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
| 2615 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2640 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2616 DidClearWindowObject(frame)); | 2641 DidClearWindowObject(frame)); |
| 2617 | 2642 |
| 2618 GURL frame_url = frame->document().url(); | 2643 GURL frame_url = frame->document().url(); |
| (...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3967 void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( | 3992 void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( |
| 3968 const GURL& page_url) { | 3993 const GURL& page_url) { |
| 3969 // Prepare list to storage all savable resource links. | 3994 // Prepare list to storage all savable resource links. |
| 3970 std::vector<GURL> resources_list; | 3995 std::vector<GURL> resources_list; |
| 3971 std::vector<GURL> referrers_list; | 3996 std::vector<GURL> referrers_list; |
| 3972 std::vector<GURL> frames_list; | 3997 std::vector<GURL> frames_list; |
| 3973 webkit_glue::SavableResourcesResult result(&resources_list, | 3998 webkit_glue::SavableResourcesResult result(&resources_list, |
| 3974 &referrers_list, | 3999 &referrers_list, |
| 3975 &frames_list); | 4000 &frames_list); |
| 3976 | 4001 |
| 4002 // FIXME(rdsmith): When GetAllSavableResourceLinksForCurrentPage starts to | |
| 4003 // return referrers, it should also return the referrer policies. | |
| 3977 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( | 4004 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
| 3978 webview(), | 4005 webview(), |
| 3979 page_url, | 4006 page_url, |
| 3980 &result, | 4007 &result, |
| 3981 chrome::GetSavableSchemes())) { | 4008 chrome::GetSavableSchemes())) { |
| 3982 // If something is wrong when collecting all savable resource links, | 4009 // If something is wrong when collecting all savable resource links, |
| 3983 // send empty list to embedder(browser) to tell it failed. | 4010 // send empty list to embedder(browser) to tell it failed. |
| 3984 referrers_list.clear(); | 4011 referrers_list.clear(); |
| 3985 resources_list.clear(); | 4012 resources_list.clear(); |
| 3986 frames_list.clear(); | 4013 frames_list.clear(); |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4855 return !!RenderThreadImpl::current()->compositor_thread(); | 4882 return !!RenderThreadImpl::current()->compositor_thread(); |
| 4856 } | 4883 } |
| 4857 | 4884 |
| 4858 void RenderViewImpl::OnJavaBridgeInit( | 4885 void RenderViewImpl::OnJavaBridgeInit( |
| 4859 const IPC::ChannelHandle& channel_handle) { | 4886 const IPC::ChannelHandle& channel_handle) { |
| 4860 DCHECK(!java_bridge_dispatcher_.get()); | 4887 DCHECK(!java_bridge_dispatcher_.get()); |
| 4861 #if defined(ENABLE_JAVA_BRIDGE) | 4888 #if defined(ENABLE_JAVA_BRIDGE) |
| 4862 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4889 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
| 4863 #endif | 4890 #endif |
| 4864 } | 4891 } |
| OLD | NEW |