OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 128 |
129 return item.httpBody().identifier(); | 129 return item.httpBody().identifier(); |
130 } | 130 } |
131 | 131 |
132 WebURLResponseExtraDataImpl* GetExtraDataFromResponse( | 132 WebURLResponseExtraDataImpl* GetExtraDataFromResponse( |
133 const WebURLResponse& response) { | 133 const WebURLResponse& response) { |
134 return static_cast<WebURLResponseExtraDataImpl*>( | 134 return static_cast<WebURLResponseExtraDataImpl*>( |
135 response.extraData()); | 135 response.extraData()); |
136 } | 136 } |
137 | 137 |
138 void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 138 void GetRedirectChain(const WebDataSource* ds, std::vector<GURL>* result) { |
Charlie Reis
2014/03/03 18:21:11
Please don't change this signature. (Why make the
hush (inactive)
2014/03/03 23:12:52
http://google-styleguide.googlecode.com/svn/trunk/
Charlie Reis
2014/03/04 20:32:03
Yes, we generally don't put const on pointer param
hush (inactive)
2014/03/04 23:22:33
Done.
| |
139 if (!result || !ds) { | |
Charlie Reis
2014/03/03 18:21:11
style nit: No braces for a one-line body.
In what
hush (inactive)
2014/03/03 23:12:52
I was just doing this defensively in case that cod
Charlie Reis
2014/03/04 20:32:03
Yes, please remove them. Better to crash early if
hush (inactive)
2014/03/04 23:22:33
Done.
| |
140 return; | |
141 } | |
139 // Replace any occurrences of swappedout:// with about:blank. | 142 // Replace any occurrences of swappedout:// with about:blank. |
140 const WebURL& blank_url = GURL(kAboutBlankURL); | 143 const WebURL& blank_url = GURL(kAboutBlankURL); |
141 WebVector<WebURL> urls; | 144 WebVector<WebURL> urls; |
142 ds->redirectChain(urls); | 145 ds->redirectChain(urls); |
143 result->reserve(urls.size()); | 146 result->reserve(urls.size()); |
144 for (size_t i = 0; i < urls.size(); ++i) { | 147 for (size_t i = 0; i < urls.size(); ++i) { |
145 if (urls[i] != GURL(kSwappedOutURL)) | 148 if (urls[i] != GURL(kSwappedOutURL)) |
146 result->push_back(urls[i]); | 149 result->push_back(urls[i]); |
147 else | 150 else |
148 result->push_back(blank_url); | 151 result->push_back(blank_url); |
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2099 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 2102 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
2100 } | 2103 } |
2101 | 2104 |
2102 // Tell the embedding application that the URL of the active page has changed. | 2105 // Tell the embedding application that the URL of the active page has changed. |
2103 void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) { | 2106 void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) { |
2104 DCHECK(!frame_ || frame_ == frame); | 2107 DCHECK(!frame_ || frame_ == frame); |
2105 WebDataSource* ds = frame->dataSource(); | 2108 WebDataSource* ds = frame->dataSource(); |
2106 DCHECK(ds); | 2109 DCHECK(ds); |
2107 | 2110 |
2108 const WebURLRequest& request = ds->request(); | 2111 const WebURLRequest& request = ds->request(); |
2109 const WebURLRequest& original_request = ds->originalRequest(); | |
2110 const WebURLResponse& response = ds->response(); | 2112 const WebURLResponse& response = ds->response(); |
2111 | 2113 |
2112 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2114 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2113 NavigationState* navigation_state = document_state->navigation_state(); | 2115 NavigationState* navigation_state = document_state->navigation_state(); |
2114 InternalDocumentStateData* internal_data = | 2116 InternalDocumentStateData* internal_data = |
2115 InternalDocumentStateData::FromDocumentState(document_state); | 2117 InternalDocumentStateData::FromDocumentState(document_state); |
2116 | 2118 |
2117 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2119 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2118 params.http_status_code = response.httpStatusCode(); | 2120 params.http_status_code = response.httpStatusCode(); |
2119 params.is_post = false; | 2121 params.is_post = false; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2220 params.is_post = true; | 2222 params.is_post = true; |
2221 params.post_id = ExtractPostId(item); | 2223 params.post_id = ExtractPostId(item); |
2222 } | 2224 } |
2223 | 2225 |
2224 // Send the user agent override back. | 2226 // Send the user agent override back. |
2225 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 2227 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
2226 | 2228 |
2227 // Track the URL of the original request. We use the first entry of the | 2229 // Track the URL of the original request. We use the first entry of the |
2228 // redirect chain if it exists because the chain may have started in another | 2230 // redirect chain if it exists because the chain may have started in another |
2229 // process. | 2231 // process. |
2230 if (params.redirects.size() > 0) | 2232 params.original_request_url = GetOriginalRequestUrl(ds); |
2231 params.original_request_url = params.redirects.at(0); | |
2232 else | |
2233 params.original_request_url = original_request.url(); | |
2234 | 2233 |
2235 params.history_list_was_cleared = | 2234 params.history_list_was_cleared = |
2236 navigation_state->history_list_was_cleared(); | 2235 navigation_state->history_list_was_cleared(); |
2237 | 2236 |
2238 // Save some histogram data so we can compute the average memory used per | 2237 // Save some histogram data so we can compute the average memory used per |
2239 // page load of the glyphs. | 2238 // page load of the glyphs. |
2240 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 2239 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
2241 blink::WebGlyphCache::pageCount()); | 2240 blink::WebGlyphCache::pageCount()); |
2242 | 2241 |
2243 // This message needs to be sent before any of allowScripts(), | 2242 // This message needs to be sent before any of allowScripts(), |
(...skipping 30 matching lines...) Expand all Loading... | |
2274 } | 2273 } |
2275 | 2274 |
2276 void RenderFrameImpl::didStartLoading() { | 2275 void RenderFrameImpl::didStartLoading() { |
2277 Send(new FrameHostMsg_DidStartLoading(routing_id_)); | 2276 Send(new FrameHostMsg_DidStartLoading(routing_id_)); |
2278 } | 2277 } |
2279 | 2278 |
2280 void RenderFrameImpl::didStopLoading() { | 2279 void RenderFrameImpl::didStopLoading() { |
2281 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 2280 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
2282 } | 2281 } |
2283 | 2282 |
2283 const GURL RenderFrameImpl::GetOriginalRequestUrl(const WebDataSource* ds) { | |
Charlie Reis
2014/03/03 18:21:11
No const in either part.
hush (inactive)
2014/03/03 23:12:52
Please see the previous reply about "const"
| |
2284 if (!ds) { | |
Charlie Reis
2014/03/03 18:21:11
This check seems unnecessary.
hush (inactive)
2014/03/03 23:12:52
Please the previous reply about null check.
| |
2285 return GURL(); | |
2286 } | |
2287 | |
2288 std::vector<GURL> redirects; | |
2289 GetRedirectChain(ds, &redirects); | |
2290 | |
2291 if (ds->hasUnreachableURL()) { | |
2292 // The frame is loaded via WebFrame::loadData, where we pass the | |
2293 // history_url_for_data_url as unreachableURL in blink. The | |
Charlie Reis
2014/03/03 18:21:11
I'm not sure this comment is accurate. That's not
hush (inactive)
2014/03/03 23:12:52
You are right, error page uses unreachableURL as w
Charlie Reis
2014/03/04 20:32:03
That's a behavior change that I'm not sure how to
| |
2294 // base_url_for_data_url will be in the redirect chain, but we | |
2295 // never actually visited base_url_for_data_url. So we need to set | |
2296 // history_url_for_data_url as the original_request_url. | |
2297 return ds->unreachableURL(); | |
2298 } | |
2299 | |
2300 if (redirects.size() > 0) { | |
Charlie Reis
2014/03/03 18:21:11
No braces for a one-line body.
hush (inactive)
2014/03/03 23:12:52
Okay
| |
2301 return redirects.at(0); | |
2302 } | |
2303 else { | |
Charlie Reis
2014/03/03 18:21:11
No need for an else block if your if block returns
hush (inactive)
2014/03/03 23:12:52
okay
| |
2304 return ds->originalRequest().url(); | |
2305 } | |
2306 } | |
2307 | |
2284 } // namespace content | 2308 } // namespace content |
OLD | NEW |