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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 ds->redirectChain(urls); | 169 ds->redirectChain(urls); |
170 result->reserve(urls.size()); | 170 result->reserve(urls.size()); |
171 for (size_t i = 0; i < urls.size(); ++i) { | 171 for (size_t i = 0; i < urls.size(); ++i) { |
172 if (urls[i] != GURL(kSwappedOutURL)) | 172 if (urls[i] != GURL(kSwappedOutURL)) |
173 result->push_back(urls[i]); | 173 result->push_back(urls[i]); |
174 else | 174 else |
175 result->push_back(blank_url); | 175 result->push_back(blank_url); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
| 179 // Returns the original request url. If there is no redirect, the original |
| 180 // url is the same as ds->request()->url(). If the WebDataSource belongs to a |
| 181 // frame was loaded by loadData, the original url will be ds->unreachableURL() |
| 182 static GURL GetOriginalRequestURL(WebDataSource* ds) { |
| 183 // WebDataSource has unreachable URL means that the frame is loaded through |
| 184 // blink::WebFrame::loadData(), and the base URL will be in the redirect |
| 185 // chain. However, we never visited the baseURL. So in this case, we should |
| 186 // use the unreachable URL as the original URL. |
| 187 if (ds->hasUnreachableURL()) |
| 188 return ds->unreachableURL(); |
| 189 |
| 190 std::vector<GURL> redirects; |
| 191 GetRedirectChain(ds, &redirects); |
| 192 if (!redirects.empty()) |
| 193 return redirects.at(0); |
| 194 |
| 195 return ds->originalRequest().url(); |
| 196 } |
| 197 |
179 NOINLINE static void CrashIntentionally() { | 198 NOINLINE static void CrashIntentionally() { |
180 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 199 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
181 // that the signature is easier to triage in crash reports. | 200 // that the signature is easier to triage in crash reports. |
182 volatile int* zero = NULL; | 201 volatile int* zero = NULL; |
183 *zero = 0; | 202 *zero = 0; |
184 } | 203 } |
185 | 204 |
186 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 205 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
187 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 206 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { |
188 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 207 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
(...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 2654 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
2636 } | 2655 } |
2637 | 2656 |
2638 // Tell the embedding application that the URL of the active page has changed. | 2657 // Tell the embedding application that the URL of the active page has changed. |
2639 void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) { | 2658 void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) { |
2640 DCHECK(!frame_ || frame_ == frame); | 2659 DCHECK(!frame_ || frame_ == frame); |
2641 WebDataSource* ds = frame->dataSource(); | 2660 WebDataSource* ds = frame->dataSource(); |
2642 DCHECK(ds); | 2661 DCHECK(ds); |
2643 | 2662 |
2644 const WebURLRequest& request = ds->request(); | 2663 const WebURLRequest& request = ds->request(); |
2645 const WebURLRequest& original_request = ds->originalRequest(); | |
2646 const WebURLResponse& response = ds->response(); | 2664 const WebURLResponse& response = ds->response(); |
2647 | 2665 |
2648 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2666 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2649 NavigationState* navigation_state = document_state->navigation_state(); | 2667 NavigationState* navigation_state = document_state->navigation_state(); |
2650 InternalDocumentStateData* internal_data = | 2668 InternalDocumentStateData* internal_data = |
2651 InternalDocumentStateData::FromDocumentState(document_state); | 2669 InternalDocumentStateData::FromDocumentState(document_state); |
2652 | 2670 |
2653 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2671 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2654 params.http_status_code = response.httpStatusCode(); | 2672 params.http_status_code = response.httpStatusCode(); |
2655 params.is_post = false; | 2673 params.is_post = false; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2756 params.is_post = true; | 2774 params.is_post = true; |
2757 params.post_id = ExtractPostId(item); | 2775 params.post_id = ExtractPostId(item); |
2758 } | 2776 } |
2759 | 2777 |
2760 // Send the user agent override back. | 2778 // Send the user agent override back. |
2761 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 2779 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
2762 | 2780 |
2763 // Track the URL of the original request. We use the first entry of the | 2781 // Track the URL of the original request. We use the first entry of the |
2764 // redirect chain if it exists because the chain may have started in another | 2782 // redirect chain if it exists because the chain may have started in another |
2765 // process. | 2783 // process. |
2766 if (params.redirects.size() > 0) | 2784 params.original_request_url = GetOriginalRequestURL(ds); |
2767 params.original_request_url = params.redirects.at(0); | |
2768 else | |
2769 params.original_request_url = original_request.url(); | |
2770 | 2785 |
2771 params.history_list_was_cleared = | 2786 params.history_list_was_cleared = |
2772 navigation_state->history_list_was_cleared(); | 2787 navigation_state->history_list_was_cleared(); |
2773 | 2788 |
2774 // Save some histogram data so we can compute the average memory used per | 2789 // Save some histogram data so we can compute the average memory used per |
2775 // page load of the glyphs. | 2790 // page load of the glyphs. |
2776 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 2791 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
2777 blink::WebGlyphCache::pageCount()); | 2792 blink::WebGlyphCache::pageCount()); |
2778 | 2793 |
2779 // This message needs to be sent before any of allowScripts(), | 2794 // This message needs to be sent before any of allowScripts(), |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3154 selection_text_offset_ = offset; | 3169 selection_text_offset_ = offset; |
3155 selection_range_ = range; | 3170 selection_range_ = range; |
3156 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3171 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
3157 Send(new ViewHostMsg_SelectionChanged( | 3172 Send(new ViewHostMsg_SelectionChanged( |
3158 GetRenderWidget()->routing_id(), text, offset, range)); | 3173 GetRenderWidget()->routing_id(), text, offset, range)); |
3159 } | 3174 } |
3160 GetRenderWidget()->UpdateSelectionBounds(); | 3175 GetRenderWidget()->UpdateSelectionBounds(); |
3161 } | 3176 } |
3162 | 3177 |
3163 } // namespace content | 3178 } // namespace content |
OLD | NEW |