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/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 ds->redirectChain(urls); | 162 ds->redirectChain(urls); |
163 result->reserve(urls.size()); | 163 result->reserve(urls.size()); |
164 for (size_t i = 0; i < urls.size(); ++i) { | 164 for (size_t i = 0; i < urls.size(); ++i) { |
165 if (urls[i] != GURL(kSwappedOutURL)) | 165 if (urls[i] != GURL(kSwappedOutURL)) |
166 result->push_back(urls[i]); | 166 result->push_back(urls[i]); |
167 else | 167 else |
168 result->push_back(blank_url); | 168 result->push_back(blank_url); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 // Returns the original request url. If there is no redirect, the original | |
173 // url is the same as ds->request()->url(). If the WebDataSource belongs to a | |
174 // frame was loaded by loadData, the original url will be ds->unreachableURL() | |
175 static GURL GetOriginalRequestURL(WebDataSource* ds) { | |
darin (slow to review)
2014/04/15 22:18:49
nit: It looks like this function is defined inside
hush (inactive)
2014/04/15 22:32:30
I see "static" used in an anonymous namespace in o
| |
176 // WebDataSource has unreachable URL means that the frame is loaded through | |
177 // blink::WebFrame::loadData(), and the base URL will be in the redirect | |
178 // chain. However, we never visited the baseURL. So in this case, we should | |
179 // use the unreachable URL as the original URL. | |
180 if (ds->hasUnreachableURL()) | |
181 return ds->unreachableURL(); | |
182 | |
183 std::vector<GURL> redirects; | |
184 GetRedirectChain(ds, &redirects); | |
185 if (!redirects.empty()) | |
186 return redirects.at(0); | |
187 | |
188 return ds->originalRequest().url(); | |
189 } | |
190 | |
172 NOINLINE static void CrashIntentionally() { | 191 NOINLINE static void CrashIntentionally() { |
173 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 192 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
174 // that the signature is easier to triage in crash reports. | 193 // that the signature is easier to triage in crash reports. |
175 volatile int* zero = NULL; | 194 volatile int* zero = NULL; |
176 *zero = 0; | 195 *zero = 0; |
177 } | 196 } |
178 | 197 |
179 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 198 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
180 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 199 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { |
181 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 200 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2388 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 2407 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
2389 } | 2408 } |
2390 | 2409 |
2391 // Tell the embedding application that the URL of the active page has changed. | 2410 // Tell the embedding application that the URL of the active page has changed. |
2392 void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) { | 2411 void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) { |
2393 DCHECK(!frame_ || frame_ == frame); | 2412 DCHECK(!frame_ || frame_ == frame); |
2394 WebDataSource* ds = frame->dataSource(); | 2413 WebDataSource* ds = frame->dataSource(); |
2395 DCHECK(ds); | 2414 DCHECK(ds); |
2396 | 2415 |
2397 const WebURLRequest& request = ds->request(); | 2416 const WebURLRequest& request = ds->request(); |
2398 const WebURLRequest& original_request = ds->originalRequest(); | |
2399 const WebURLResponse& response = ds->response(); | 2417 const WebURLResponse& response = ds->response(); |
2400 | 2418 |
2401 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2419 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2402 NavigationState* navigation_state = document_state->navigation_state(); | 2420 NavigationState* navigation_state = document_state->navigation_state(); |
2403 InternalDocumentStateData* internal_data = | 2421 InternalDocumentStateData* internal_data = |
2404 InternalDocumentStateData::FromDocumentState(document_state); | 2422 InternalDocumentStateData::FromDocumentState(document_state); |
2405 | 2423 |
2406 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2424 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2407 params.http_status_code = response.httpStatusCode(); | 2425 params.http_status_code = response.httpStatusCode(); |
2408 params.is_post = false; | 2426 params.is_post = false; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2508 params.is_post = true; | 2526 params.is_post = true; |
2509 params.post_id = ExtractPostId(item); | 2527 params.post_id = ExtractPostId(item); |
2510 } | 2528 } |
2511 | 2529 |
2512 // Send the user agent override back. | 2530 // Send the user agent override back. |
2513 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 2531 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
2514 | 2532 |
2515 // Track the URL of the original request. We use the first entry of the | 2533 // Track the URL of the original request. We use the first entry of the |
2516 // redirect chain if it exists because the chain may have started in another | 2534 // redirect chain if it exists because the chain may have started in another |
2517 // process. | 2535 // process. |
2518 if (params.redirects.size() > 0) | 2536 params.original_request_url = GetOriginalRequestURL(ds); |
2519 params.original_request_url = params.redirects.at(0); | |
2520 else | |
2521 params.original_request_url = original_request.url(); | |
2522 | 2537 |
2523 params.history_list_was_cleared = | 2538 params.history_list_was_cleared = |
2524 navigation_state->history_list_was_cleared(); | 2539 navigation_state->history_list_was_cleared(); |
2525 | 2540 |
2526 // Save some histogram data so we can compute the average memory used per | 2541 // Save some histogram data so we can compute the average memory used per |
2527 // page load of the glyphs. | 2542 // page load of the glyphs. |
2528 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 2543 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
2529 blink::WebGlyphCache::pageCount()); | 2544 blink::WebGlyphCache::pageCount()); |
2530 | 2545 |
2531 // This message needs to be sent before any of allowScripts(), | 2546 // This message needs to be sent before any of allowScripts(), |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2919 selection_text_offset_ = offset; | 2934 selection_text_offset_ = offset; |
2920 selection_range_ = range; | 2935 selection_range_ = range; |
2921 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 2936 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
2922 Send(new ViewHostMsg_SelectionChanged( | 2937 Send(new ViewHostMsg_SelectionChanged( |
2923 GetRenderWidget()->routing_id(), text, offset, range)); | 2938 GetRenderWidget()->routing_id(), text, offset, range)); |
2924 } | 2939 } |
2925 GetRenderWidget()->UpdateSelectionBounds(); | 2940 GetRenderWidget()->UpdateSelectionBounds(); |
2926 } | 2941 } |
2927 | 2942 |
2928 } // namespace content | 2943 } // namespace content |
OLD | NEW |