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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" | 106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" |
107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" | 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" | 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" |
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" | 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
113 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" | 113 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
115 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 115 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebReferrerPolicy.h" |
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" | 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" |
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
121 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 122 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" | 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" |
123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" | 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" |
124 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 using WebKit::WebPageSerializer; | 207 using WebKit::WebPageSerializer; |
207 using WebKit::WebPageSerializerClient; | 208 using WebKit::WebPageSerializerClient; |
208 using WebKit::WebPlugin; | 209 using WebKit::WebPlugin; |
209 using WebKit::WebPluginContainer; | 210 using WebKit::WebPluginContainer; |
210 using WebKit::WebPluginDocument; | 211 using WebKit::WebPluginDocument; |
211 using WebKit::WebPluginParams; | 212 using WebKit::WebPluginParams; |
212 using WebKit::WebPoint; | 213 using WebKit::WebPoint; |
213 using WebKit::WebPopupMenuInfo; | 214 using WebKit::WebPopupMenuInfo; |
214 using WebKit::WebRange; | 215 using WebKit::WebRange; |
215 using WebKit::WebRect; | 216 using WebKit::WebRect; |
| 217 using WebKit::WebReferrerPolicy; |
216 using WebKit::WebScriptSource; | 218 using WebKit::WebScriptSource; |
217 using WebKit::WebSearchableFormData; | 219 using WebKit::WebSearchableFormData; |
218 using WebKit::WebSecurityOrigin; | 220 using WebKit::WebSecurityOrigin; |
219 using WebKit::WebSecurityPolicy; | 221 using WebKit::WebSecurityPolicy; |
220 using WebKit::WebSettings; | 222 using WebKit::WebSettings; |
221 using WebKit::WebSharedWorker; | 223 using WebKit::WebSharedWorker; |
222 using WebKit::WebSize; | 224 using WebKit::WebSize; |
223 using WebKit::WebStorageNamespace; | 225 using WebKit::WebStorageNamespace; |
224 using WebKit::WebStorageQuotaCallbacks; | 226 using WebKit::WebStorageQuotaCallbacks; |
225 using WebKit::WebStorageQuotaError; | 227 using WebKit::WebStorageQuotaError; |
(...skipping 13 matching lines...) Expand all Loading... |
239 using WebKit::WebWorker; | 241 using WebKit::WebWorker; |
240 using WebKit::WebWorkerClient; | 242 using WebKit::WebWorkerClient; |
241 using appcache::WebApplicationCacheHostImpl; | 243 using appcache::WebApplicationCacheHostImpl; |
242 using base::Time; | 244 using base::Time; |
243 using base::TimeDelta; | 245 using base::TimeDelta; |
244 using content::DocumentState; | 246 using content::DocumentState; |
245 using content::NavigationState; | 247 using content::NavigationState; |
246 using content::RenderThread; | 248 using content::RenderThread; |
247 using content::RenderViewObserver; | 249 using content::RenderViewObserver; |
248 using content::RenderViewVisitor; | 250 using content::RenderViewVisitor; |
| 251 using content::Referrer; |
249 using content::V8ValueConverter; | 252 using content::V8ValueConverter; |
250 using webkit_glue::AltErrorPageResourceFetcher; | 253 using webkit_glue::AltErrorPageResourceFetcher; |
251 using webkit_glue::FormField; | 254 using webkit_glue::FormField; |
252 using webkit_glue::PasswordForm; | 255 using webkit_glue::PasswordForm; |
253 using webkit_glue::PasswordFormDomManager; | 256 using webkit_glue::PasswordFormDomManager; |
254 using webkit_glue::ResourceFetcher; | 257 using webkit_glue::ResourceFetcher; |
255 | 258 |
256 //----------------------------------------------------------------------------- | 259 //----------------------------------------------------------------------------- |
257 | 260 |
258 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; | 261 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 document_state->set_alt_error_page_fetcher(NULL); | 298 document_state->set_alt_error_page_fetcher(NULL); |
296 } | 299 } |
297 } | 300 } |
298 | 301 |
299 static bool IsReload(const ViewMsg_Navigate_Params& params) { | 302 static bool IsReload(const ViewMsg_Navigate_Params& params) { |
300 return | 303 return |
301 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 304 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
302 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 305 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
303 } | 306 } |
304 | 307 |
| 308 static WebReferrerPolicy getReferrerPolicyFromRequest( |
| 309 const WebURLRequest& request) { |
| 310 return request.extraData() ? |
| 311 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : |
| 312 WebKit::WebReferrerPolicyDefault; |
| 313 } |
| 314 |
305 /////////////////////////////////////////////////////////////////////////////// | 315 /////////////////////////////////////////////////////////////////////////////// |
306 | 316 |
307 int32 RenderViewImpl::next_page_id_ = 1; | 317 int32 RenderViewImpl::next_page_id_ = 1; |
308 | 318 |
309 struct RenderViewImpl::PendingFileChooser { | 319 struct RenderViewImpl::PendingFileChooser { |
310 PendingFileChooser(const content::FileChooserParams& p, | 320 PendingFileChooser(const content::FileChooserParams& p, |
311 WebFileChooserCompletion* c) | 321 WebFileChooserCompletion* c) |
312 : params(p), | 322 : params(p), |
313 completion(c) { | 323 completion(c) { |
314 } | 324 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 } else { | 774 } else { |
765 // Navigate to the given URL. | 775 // Navigate to the given URL. |
766 WebURLRequest request(params.url); | 776 WebURLRequest request(params.url); |
767 | 777 |
768 // A session history navigation should have been accompanied by state. | 778 // A session history navigation should have been accompanied by state. |
769 DCHECK_EQ(params.page_id, -1); | 779 DCHECK_EQ(params.page_id, -1); |
770 | 780 |
771 if (main_frame->isViewSourceModeEnabled()) | 781 if (main_frame->isViewSourceModeEnabled()) |
772 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); | 782 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
773 | 783 |
774 if (params.referrer.is_valid()) { | 784 if (params.referrer.url.is_valid()) { |
775 if (!WebSecurityPolicy::shouldHideReferrer( | 785 WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
776 params.url, | 786 params.referrer.policy, |
777 WebString::fromUTF8(params.referrer.spec()))) { | 787 params.url, |
778 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), | 788 WebString::fromUTF8(params.referrer.url.spec())); |
779 WebString::fromUTF8(params.referrer.spec())); | 789 if (!referrer.isEmpty()) |
780 } | 790 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); |
781 } | 791 } |
782 | 792 |
783 if (!params.extra_headers.empty()) { | 793 if (!params.extra_headers.empty()) { |
784 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | 794 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
785 params.extra_headers.end(), "\n"); | 795 params.extra_headers.end(), "\n"); |
786 i.GetNext(); ) { | 796 i.GetNext(); ) { |
787 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 797 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
788 WebString::fromUTF8(i.values())); | 798 WebString::fromUTF8(i.values())); |
789 } | 799 } |
790 } | 800 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 // MANUAL_SUBFRAME, it will be that same transition type here. | 1146 // MANUAL_SUBFRAME, it will be that same transition type here. |
1137 // We don't want that, because any navigation that changes the toplevel | 1147 // We don't want that, because any navigation that changes the toplevel |
1138 // frame should be tracked as a toplevel navigation (this allows us to | 1148 // frame should be tracked as a toplevel navigation (this allows us to |
1139 // update the URL bar, etc). | 1149 // update the URL bar, etc). |
1140 params.transition = content::PAGE_TRANSITION_LINK; | 1150 params.transition = content::PAGE_TRANSITION_LINK; |
1141 } | 1151 } |
1142 | 1152 |
1143 // If we have a valid consumed client redirect source, | 1153 // If we have a valid consumed client redirect source, |
1144 // the page contained a client redirect (meta refresh, document.loc...), | 1154 // the page contained a client redirect (meta refresh, document.loc...), |
1145 // so we set the referrer and transition to match. | 1155 // so we set the referrer and transition to match. |
1146 if (completed_client_redirect_src_.is_valid()) { | 1156 if (completed_client_redirect_src_.url.is_valid()) { |
1147 DCHECK(completed_client_redirect_src_ == params.redirects[0]); | 1157 DCHECK(completed_client_redirect_src_.url == params.redirects[0]); |
1148 params.referrer = completed_client_redirect_src_; | 1158 params.referrer = completed_client_redirect_src_; |
1149 params.transition = static_cast<content::PageTransition>( | 1159 params.transition = static_cast<content::PageTransition>( |
1150 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); | 1160 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); |
1151 } else { | 1161 } else { |
1152 // Bug 654101: the referrer will be empty on https->http transitions. It | 1162 // Bug 654101: the referrer will be empty on https->http transitions. It |
1153 // would be nice if we could get the real referrer from somewhere. | 1163 // would be nice if we could get the real referrer from somewhere. |
1154 params.referrer = GURL( | 1164 params.referrer = Referrer(GURL( |
1155 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); | 1165 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 1166 getReferrerPolicyFromRequest(original_request)); |
1156 } | 1167 } |
1157 | 1168 |
1158 string16 method = request.httpMethod(); | 1169 string16 method = request.httpMethod(); |
1159 if (EqualsASCII(method, "POST")) | 1170 if (EqualsASCII(method, "POST")) |
1160 params.is_post = true; | 1171 params.is_post = true; |
1161 | 1172 |
1162 // Save some histogram data so we can compute the average memory used per | 1173 // Save some histogram data so we can compute the average memory used per |
1163 // page load of the glyphs. | 1174 // page load of the glyphs. |
1164 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 1175 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
1165 webkit_glue::GetGlyphPageCount()); | 1176 webkit_glue::GetGlyphPageCount()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 webview()->mainFrame()->previousHistoryItem(); | 1241 webview()->mainFrame()->previousHistoryItem(); |
1231 if (item.isNull()) | 1242 if (item.isNull()) |
1232 return; | 1243 return; |
1233 | 1244 |
1234 Send(new ViewHostMsg_UpdateState( | 1245 Send(new ViewHostMsg_UpdateState( |
1235 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1246 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
1236 } | 1247 } |
1237 | 1248 |
1238 void RenderViewImpl::OpenURL(WebFrame* frame, | 1249 void RenderViewImpl::OpenURL(WebFrame* frame, |
1239 const GURL& url, | 1250 const GURL& url, |
1240 const GURL& referrer, | 1251 const Referrer& referrer, |
1241 WebNavigationPolicy policy) { | 1252 WebNavigationPolicy policy) { |
1242 Send(new ViewHostMsg_OpenURL( | 1253 Send(new ViewHostMsg_OpenURL( |
1243 routing_id_, | 1254 routing_id_, |
1244 url, | 1255 url, |
1245 referrer, | 1256 referrer, |
1246 NavigationPolicyToDisposition(policy), | 1257 NavigationPolicyToDisposition(policy), |
1247 frame->identifier())); | 1258 frame->identifier())); |
1248 } | 1259 } |
1249 | 1260 |
1250 // WebViewDelegate ------------------------------------------------------------ | 1261 // WebViewDelegate ------------------------------------------------------------ |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 | 1985 |
1975 void RenderViewImpl::loadURLExternally( | 1986 void RenderViewImpl::loadURLExternally( |
1976 WebFrame* frame, const WebURLRequest& request, | 1987 WebFrame* frame, const WebURLRequest& request, |
1977 WebNavigationPolicy policy, | 1988 WebNavigationPolicy policy, |
1978 const WebString& suggested_name) { | 1989 const WebString& suggested_name) { |
1979 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 1990 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
1980 if (policy == WebKit::WebNavigationPolicyDownload) { | 1991 if (policy == WebKit::WebNavigationPolicyDownload) { |
1981 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, | 1992 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
1982 suggested_name)); | 1993 suggested_name)); |
1983 } else { | 1994 } else { |
1984 OpenURL(frame, request.url(), referrer, policy); | 1995 OpenURL(frame, request.url(), |
| 1996 Referrer(referrer, getReferrerPolicyFromRequest(request)), policy); |
1985 } | 1997 } |
1986 } | 1998 } |
1987 | 1999 |
1988 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 2000 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
1989 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, | 2001 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
1990 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { | 2002 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
1991 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. | 2003 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
1992 if (is_swapped_out_) { | 2004 if (is_swapped_out_) { |
1993 DCHECK(request.url() == GURL("about:swappedout")); | 2005 DCHECK(request.url() == GURL("about:swappedout")); |
1994 return default_policy; | 2006 return default_policy; |
(...skipping 16 matching lines...) Expand all Loading... |
2011 // boundaries. This is currently expected to break some script calls and | 2023 // boundaries. This is currently expected to break some script calls and |
2012 // navigations, such as form submissions. | 2024 // navigations, such as form submissions. |
2013 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 2025 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
2014 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && | 2026 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && |
2015 !frame->parent() && (is_content_initiated || is_redirect)) { | 2027 !frame->parent() && (is_content_initiated || is_redirect)) { |
2016 WebString origin_str = frame->document().securityOrigin().toString(); | 2028 WebString origin_str = frame->document().securityOrigin().toString(); |
2017 GURL frame_url(origin_str.utf8().data()); | 2029 GURL frame_url(origin_str.utf8().data()); |
2018 // TODO(cevans): revisit whether this origin check is still necessary once | 2030 // TODO(cevans): revisit whether this origin check is still necessary once |
2019 // crbug.com/101395 is fixed. | 2031 // crbug.com/101395 is fixed. |
2020 if (frame_url.GetOrigin() != url.GetOrigin()) { | 2032 if (frame_url.GetOrigin() != url.GetOrigin()) { |
2021 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2033 Referrer referrer( |
| 2034 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2035 getReferrerPolicyFromRequest(request)); |
2022 OpenURL(frame, url, referrer, default_policy); | 2036 OpenURL(frame, url, referrer, default_policy); |
2023 return WebKit::WebNavigationPolicyIgnore; | 2037 return WebKit::WebNavigationPolicyIgnore; |
2024 } | 2038 } |
2025 } | 2039 } |
2026 | 2040 |
2027 // If the browser is interested, then give it a chance to look at top level | 2041 // If the browser is interested, then give it a chance to look at top level |
2028 // navigations. | 2042 // navigations. |
2029 if (is_content_initiated && | 2043 if (is_content_initiated && |
2030 renderer_preferences_.browser_handles_top_level_requests && | 2044 renderer_preferences_.browser_handles_top_level_requests && |
2031 IsNonLocalTopLevelNavigation(url, frame, type)) { | 2045 IsNonLocalTopLevelNavigation(url, frame, type)) { |
2032 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2046 Referrer referrer( |
| 2047 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2048 getReferrerPolicyFromRequest(request)); |
2033 // Reset these counters as the RenderView could be reused for the next | 2049 // Reset these counters as the RenderView could be reused for the next |
2034 // navigation. | 2050 // navigation. |
2035 page_id_ = -1; | 2051 page_id_ = -1; |
2036 last_page_id_sent_to_browser_ = -1; | 2052 last_page_id_sent_to_browser_ = -1; |
2037 OpenURL(frame, url, referrer, default_policy); | 2053 OpenURL(frame, url, referrer, default_policy); |
2038 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2054 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
2039 } | 2055 } |
2040 | 2056 |
2041 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 2057 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
2042 // an extension or app origin, leaving a WebUI page, etc). We only care about | 2058 // an extension or app origin, leaving a WebUI page, etc). We only care about |
(...skipping 22 matching lines...) Expand all Loading... |
2065 | 2081 |
2066 if (!should_fork) { | 2082 if (!should_fork) { |
2067 // Give the embedder a chance. | 2083 // Give the embedder a chance. |
2068 bool is_initial_navigation = page_id_ == -1; | 2084 bool is_initial_navigation = page_id_ == -1; |
2069 should_fork = content::GetContentClient()->renderer()->ShouldFork( | 2085 should_fork = content::GetContentClient()->renderer()->ShouldFork( |
2070 frame, url, is_content_initiated, is_initial_navigation, | 2086 frame, url, is_content_initiated, is_initial_navigation, |
2071 &send_referrer); | 2087 &send_referrer); |
2072 } | 2088 } |
2073 | 2089 |
2074 if (should_fork) { | 2090 if (should_fork) { |
2075 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2091 Referrer referrer( |
2076 OpenURL(frame, url, send_referrer ? referrer : GURL(), default_policy); | 2092 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2093 getReferrerPolicyFromRequest(request)); |
| 2094 OpenURL( |
| 2095 frame, url, send_referrer ? referrer : Referrer(), default_policy); |
2077 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2096 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
2078 } | 2097 } |
2079 } | 2098 } |
2080 | 2099 |
2081 // Use the frame's original request's URL rather than the document's URL for | 2100 // Use the frame's original request's URL rather than the document's URL for |
2082 // this check. For a popup, the document's URL may become the opener window's | 2101 // this check. For a popup, the document's URL may become the opener window's |
2083 // URL if the opener has called document.write. See http://crbug.com/93517. | 2102 // URL if the opener has called document.write. See http://crbug.com/93517. |
2084 GURL old_url(frame->dataSource()->request().url()); | 2103 GURL old_url(frame->dataSource()->request().url()); |
2085 | 2104 |
2086 // Detect when a page is "forking" a new tab that can be safely rendered in | 2105 // 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... |
2136 frame->name().isNull() && | 2155 frame->name().isNull() && |
2137 // Another frame (with a non-empty creator) should have initiated the | 2156 // Another frame (with a non-empty creator) should have initiated the |
2138 // request, targeted at this frame. | 2157 // request, targeted at this frame. |
2139 !creator_url_.is_empty() && | 2158 !creator_url_.is_empty() && |
2140 is_content_initiated && | 2159 is_content_initiated && |
2141 default_policy == WebKit::WebNavigationPolicyCurrentTab && | 2160 default_policy == WebKit::WebNavigationPolicyCurrentTab && |
2142 type == WebKit::WebNavigationTypeOther; | 2161 type == WebKit::WebNavigationTypeOther; |
2143 | 2162 |
2144 if (is_fork || is_noreferrer_and_blank_target) { | 2163 if (is_fork || is_noreferrer_and_blank_target) { |
2145 // Open the URL via the browser, not via WebKit. | 2164 // Open the URL via the browser, not via WebKit. |
2146 OpenURL(frame, url, GURL(), default_policy); | 2165 OpenURL(frame, url, Referrer(), default_policy); |
2147 return WebKit::WebNavigationPolicyIgnore; | 2166 return WebKit::WebNavigationPolicyIgnore; |
2148 } | 2167 } |
2149 | 2168 |
2150 return default_policy; | 2169 return default_policy; |
2151 } | 2170 } |
2152 | 2171 |
2153 bool RenderViewImpl::canHandleRequest( | 2172 bool RenderViewImpl::canHandleRequest( |
2154 WebFrame* frame, const WebURLRequest& request) { | 2173 WebFrame* frame, const WebURLRequest& request) { |
2155 // We allow WebKit to think that everything can be handled even though | 2174 // We allow WebKit to think that everything can be handled even though |
2156 // browser-side we limit what we load. | 2175 // browser-side we limit what we load. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 WillPerformClientRedirect(frame, from, to, interval, fire_time)); | 2253 WillPerformClientRedirect(frame, from, to, interval, fire_time)); |
2235 } | 2254 } |
2236 | 2255 |
2237 void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { | 2256 void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { |
2238 FOR_EACH_OBSERVER( | 2257 FOR_EACH_OBSERVER( |
2239 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); | 2258 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); |
2240 } | 2259 } |
2241 | 2260 |
2242 void RenderViewImpl::didCompleteClientRedirect( | 2261 void RenderViewImpl::didCompleteClientRedirect( |
2243 WebFrame* frame, const WebURL& from) { | 2262 WebFrame* frame, const WebURL& from) { |
2244 if (!frame->parent()) | 2263 if (!frame->parent()) { |
2245 completed_client_redirect_src_ = from; | 2264 WebDataSource* ds = frame->provisionalDataSource(); |
| 2265 // If there's no provisional data source, it's a reference fragment |
| 2266 // navigation. |
| 2267 completed_client_redirect_src_ = Referrer( |
| 2268 from, ds ? getReferrerPolicyFromRequest(ds->request()) : |
| 2269 frame->referrerPolicy()); |
| 2270 } |
2246 FOR_EACH_OBSERVER( | 2271 FOR_EACH_OBSERVER( |
2247 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); | 2272 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
2248 } | 2273 } |
2249 | 2274 |
2250 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { | 2275 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
2251 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2276 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2252 if (!document_state) { | 2277 if (!document_state) { |
2253 document_state = new DocumentState; | 2278 document_state = new DocumentState; |
2254 ds->setExtraData(document_state); | 2279 ds->setExtraData(document_state); |
2255 } | 2280 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2369 | 2394 |
2370 // Start time is only set after request time. | 2395 // Start time is only set after request time. |
2371 document_state->set_start_load_time(Time::Now()); | 2396 document_state->set_start_load_time(Time::Now()); |
2372 | 2397 |
2373 bool is_top_most = !frame->parent(); | 2398 bool is_top_most = !frame->parent(); |
2374 if (is_top_most) { | 2399 if (is_top_most) { |
2375 navigation_gesture_ = frame->isProcessingUserGesture() ? | 2400 navigation_gesture_ = frame->isProcessingUserGesture() ? |
2376 NavigationGestureUser : NavigationGestureAuto; | 2401 NavigationGestureUser : NavigationGestureAuto; |
2377 | 2402 |
2378 // Make sure redirect tracking state is clear for the new load. | 2403 // Make sure redirect tracking state is clear for the new load. |
2379 completed_client_redirect_src_ = GURL(); | 2404 completed_client_redirect_src_ = Referrer(); |
2380 } else if (frame->parent()->isLoading()) { | 2405 } else if (frame->parent()->isLoading()) { |
2381 // Take note of AUTO_SUBFRAME loads here, so that we can know how to | 2406 // Take note of AUTO_SUBFRAME loads here, so that we can know how to |
2382 // load an error page. See didFailProvisionalLoad. | 2407 // load an error page. See didFailProvisionalLoad. |
2383 document_state->navigation_state()->set_transition_type( | 2408 document_state->navigation_state()->set_transition_type( |
2384 content::PAGE_TRANSITION_AUTO_SUBFRAME); | 2409 content::PAGE_TRANSITION_AUTO_SUBFRAME); |
2385 } | 2410 } |
2386 | 2411 |
2387 FOR_EACH_OBSERVER( | 2412 FOR_EACH_OBSERVER( |
2388 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); | 2413 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
2389 | 2414 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2559 // the session history again. We do this regardless of whether this is | 2584 // the session history again. We do this regardless of whether this is |
2560 // a session history navigation, because if we attempted a session history | 2585 // a session history navigation, because if we attempted a session history |
2561 // navigation without valid HistoryItem state, WebCore will think it is a | 2586 // navigation without valid HistoryItem state, WebCore will think it is a |
2562 // new navigation. | 2587 // new navigation. |
2563 navigation_state->set_request_committed(true); | 2588 navigation_state->set_request_committed(true); |
2564 | 2589 |
2565 UpdateURL(frame); | 2590 UpdateURL(frame); |
2566 | 2591 |
2567 // If this committed load was initiated by a client redirect, we're | 2592 // If this committed load was initiated by a client redirect, we're |
2568 // at the last stop now, so clear it. | 2593 // at the last stop now, so clear it. |
2569 completed_client_redirect_src_ = GURL(); | 2594 completed_client_redirect_src_ = Referrer(); |
2570 | 2595 |
2571 // Check whether we have new encoding name. | 2596 // Check whether we have new encoding name. |
2572 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2597 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2573 } | 2598 } |
2574 | 2599 |
2575 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 2600 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
2576 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2601 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2577 DidClearWindowObject(frame)); | 2602 DidClearWindowObject(frame)); |
2578 | 2603 |
2579 GURL frame_url = frame->document().url(); | 2604 GURL frame_url = frame->document().url(); |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3930 void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( | 3955 void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( |
3931 const GURL& page_url) { | 3956 const GURL& page_url) { |
3932 // Prepare list to storage all savable resource links. | 3957 // Prepare list to storage all savable resource links. |
3933 std::vector<GURL> resources_list; | 3958 std::vector<GURL> resources_list; |
3934 std::vector<GURL> referrers_list; | 3959 std::vector<GURL> referrers_list; |
3935 std::vector<GURL> frames_list; | 3960 std::vector<GURL> frames_list; |
3936 webkit_glue::SavableResourcesResult result(&resources_list, | 3961 webkit_glue::SavableResourcesResult result(&resources_list, |
3937 &referrers_list, | 3962 &referrers_list, |
3938 &frames_list); | 3963 &frames_list); |
3939 | 3964 |
| 3965 // FIXME(rdsmith): When GetAllSavableResourceLinksForCurrentPage starts to |
| 3966 // return referrers, it should also return the referrer policies. |
3940 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( | 3967 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
3941 webview(), | 3968 webview(), |
3942 page_url, | 3969 page_url, |
3943 &result, | 3970 &result, |
3944 chrome::GetSavableSchemes())) { | 3971 chrome::GetSavableSchemes())) { |
3945 // If something is wrong when collecting all savable resource links, | 3972 // If something is wrong when collecting all savable resource links, |
3946 // send empty list to embedder(browser) to tell it failed. | 3973 // send empty list to embedder(browser) to tell it failed. |
3947 referrers_list.clear(); | 3974 referrers_list.clear(); |
3948 resources_list.clear(); | 3975 resources_list.clear(); |
3949 frames_list.clear(); | 3976 frames_list.clear(); |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4762 return !!RenderThreadImpl::current()->compositor_thread(); | 4789 return !!RenderThreadImpl::current()->compositor_thread(); |
4763 } | 4790 } |
4764 | 4791 |
4765 void RenderViewImpl::OnJavaBridgeInit( | 4792 void RenderViewImpl::OnJavaBridgeInit( |
4766 const IPC::ChannelHandle& channel_handle) { | 4793 const IPC::ChannelHandle& channel_handle) { |
4767 DCHECK(!java_bridge_dispatcher_.get()); | 4794 DCHECK(!java_bridge_dispatcher_.get()); |
4768 #if defined(ENABLE_JAVA_BRIDGE) | 4795 #if defined(ENABLE_JAVA_BRIDGE) |
4769 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4796 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
4770 #endif | 4797 #endif |
4771 } | 4798 } |
OLD | NEW |