OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // the ResourceDispatcherHost, who unpauses the response. Data is then sent | 128 // the ResourceDispatcherHost, who unpauses the response. Data is then sent |
129 // to the pending RVH. | 129 // to the pending RVH. |
130 // - The pending renderer sends a FrameNavigate message that invokes the | 130 // - The pending renderer sends a FrameNavigate message that invokes the |
131 // DidNavigate method. This replaces the current RVH with the | 131 // DidNavigate method. This replaces the current RVH with the |
132 // pending RVH. | 132 // pending RVH. |
133 // - The previous renderer is kept swapped out in RenderViewHostManager in case | 133 // - The previous renderer is kept swapped out in RenderViewHostManager in case |
134 // the user goes back. The process only stays live if another tab is using | 134 // the user goes back. The process only stays live if another tab is using |
135 // it, but if so, the existing frame relationships will be maintained. | 135 // it, but if so, the existing frame relationships will be maintained. |
136 | 136 |
137 using webkit_glue::WebPreferences; | 137 using webkit_glue::WebPreferences; |
| 138 using webkit_glue::ResourceRequestBody; |
138 | 139 |
139 namespace content { | 140 namespace content { |
140 namespace { | 141 namespace { |
141 | 142 |
142 // Amount of time we wait between when a key event is received and the renderer | 143 // Amount of time we wait between when a key event is received and the renderer |
143 // is queried for its state and pushed to the NavigationEntry. | 144 // is queried for its state and pushed to the NavigationEntry. |
144 const int kQueryStateDelay = 5000; | 145 const int kQueryStateDelay = 5000; |
145 | 146 |
146 const int kSyncWaitDelay = 40; | 147 const int kSyncWaitDelay = 40; |
147 | 148 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 params->extra_headers = entry.extra_headers(); | 206 params->extra_headers = entry.extra_headers(); |
206 params->transferred_request_child_id = | 207 params->transferred_request_child_id = |
207 entry.transferred_global_request_id().child_id; | 208 entry.transferred_global_request_id().child_id; |
208 params->transferred_request_request_id = | 209 params->transferred_request_request_id = |
209 entry.transferred_global_request_id().request_id; | 210 entry.transferred_global_request_id().request_id; |
210 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); | 211 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); |
211 // Avoid downloading when in view-source mode. | 212 // Avoid downloading when in view-source mode. |
212 params->allow_download = !entry.IsViewSourceMode(); | 213 params->allow_download = !entry.IsViewSourceMode(); |
213 params->is_post = entry.GetHasPostData(); | 214 params->is_post = entry.GetHasPostData(); |
214 if(entry.GetBrowserInitiatedPostData()) { | 215 if(entry.GetBrowserInitiatedPostData()) { |
215 params->browser_initiated_post_data.assign( | 216 params->browser_initiated_post_data = |
216 entry.GetBrowserInitiatedPostData()->front(), | 217 entry.GetBrowserInitiatedPostData(); |
217 entry.GetBrowserInitiatedPostData()->front() + | |
218 entry.GetBrowserInitiatedPostData()->size()); | |
219 | |
220 } | 218 } |
221 | 219 |
222 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL && | 220 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL && |
223 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { | 221 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { |
224 // We may have been redirected when navigating to the current URL. | 222 // We may have been redirected when navigating to the current URL. |
225 // Use the URL the user originally intended to visit, if it's valid and if a | 223 // Use the URL the user originally intended to visit, if it's valid and if a |
226 // POST wasn't involved; the latter case avoids issues with sending data to | 224 // POST wasn't involved; the latter case avoids issues with sending data to |
227 // the wrong page. | 225 // the wrong page. |
228 params->url = entry.GetOriginalRequestURL(); | 226 params->url = entry.GetOriginalRequestURL(); |
229 } else { | 227 } else { |
(...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 | 2875 |
2878 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( | 2876 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( |
2879 RenderViewHost* render_view_host, | 2877 RenderViewHost* render_view_host, |
2880 int32 page_id) { | 2878 int32 page_id) { |
2881 NotificationService::current()->Notify( | 2879 NotificationService::current()->Notify( |
2882 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 2880 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
2883 Source<WebContents>(this), | 2881 Source<WebContents>(this), |
2884 Details<int>(&page_id)); | 2882 Details<int>(&page_id)); |
2885 } | 2883 } |
2886 | 2884 |
2887 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 2885 void WebContentsImpl::RequestOpenURL( |
2888 const GURL& url, | 2886 RenderViewHost* rvh, |
2889 const Referrer& referrer, | 2887 const GURL& url, |
2890 WindowOpenDisposition disposition, | 2888 const Referrer& referrer, |
2891 int64 source_frame_id, | 2889 WindowOpenDisposition disposition, |
2892 bool is_cross_site_redirect) { | 2890 int64 source_frame_id, |
| 2891 bool is_cross_site_redirect, |
| 2892 std::string extra_header, |
| 2893 scoped_refptr<ResourceRequestBody> request_body) { |
2893 // If this came from a swapped out RenderViewHost, we only allow the request | 2894 // If this came from a swapped out RenderViewHost, we only allow the request |
2894 // if we are still in the same BrowsingInstance. | 2895 // if we are still in the same BrowsingInstance. |
2895 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 2896 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && |
2896 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 2897 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
2897 return; | 2898 return; |
2898 } | 2899 } |
2899 | 2900 |
2900 // Delegate to RequestTransferURL because this is just the generic | 2901 // Delegate to RequestTransferURL because this is just the generic |
2901 // case where |old_request_id| is empty. | 2902 // case where |old_request_id| is empty. |
2902 RequestTransferURL(url, referrer, disposition, source_frame_id, | 2903 RequestTransferURL(url, referrer, disposition, source_frame_id, |
2903 GlobalRequestID(), is_cross_site_redirect); | 2904 GlobalRequestID(), is_cross_site_redirect, |
| 2905 extra_header, request_body); |
2904 } | 2906 } |
2905 | 2907 |
2906 void WebContentsImpl::RequestTransferURL( | 2908 void WebContentsImpl::RequestTransferURL( |
2907 const GURL& url, | 2909 const GURL& url, |
2908 const Referrer& referrer, | 2910 const Referrer& referrer, |
2909 WindowOpenDisposition disposition, | 2911 WindowOpenDisposition disposition, |
2910 int64 source_frame_id, | 2912 int64 source_frame_id, |
2911 const GlobalRequestID& old_request_id, | 2913 const GlobalRequestID& old_request_id, |
2912 bool is_cross_site_redirect) { | 2914 bool is_cross_site_redirect, |
| 2915 std::string extra_header, |
| 2916 scoped_refptr<ResourceRequestBody> request_body) { |
2913 WebContents* new_contents = NULL; | 2917 WebContents* new_contents = NULL; |
2914 PageTransition transition_type = PAGE_TRANSITION_LINK; | 2918 PageTransition transition_type = PAGE_TRANSITION_LINK; |
2915 if (render_manager_.web_ui()) { | 2919 if (render_manager_.web_ui()) { |
2916 // When we're a Web UI, it will provide a page transition type for us (this | 2920 // When we're a Web UI, it will provide a page transition type for us (this |
2917 // is so the new tab page can specify AUTO_BOOKMARK for automatically | 2921 // is so the new tab page can specify AUTO_BOOKMARK for automatically |
2918 // generated suggestions). | 2922 // generated suggestions). |
2919 // | 2923 // |
2920 // Note also that we hide the referrer for Web UI pages. We don't really | 2924 // Note also that we hide the referrer for Web UI pages. We don't really |
2921 // want web sites to see a referrer of "chrome://blah" (and some | 2925 // want web sites to see a referrer of "chrome://blah" (and some |
2922 // chrome: URLs might have search terms or other stuff we don't want to | 2926 // chrome: URLs might have search terms or other stuff we don't want to |
2923 // send to the site), so we send no referrer. | 2927 // send to the site), so we send no referrer. |
2924 OpenURLParams params(url, Referrer(), source_frame_id, disposition, | 2928 OpenURLParams params(url, Referrer(), source_frame_id, disposition, |
2925 render_manager_.web_ui()->GetLinkTransitionType(), | 2929 render_manager_.web_ui()->GetLinkTransitionType(), |
2926 false /* is_renderer_initiated */); | 2930 false /* is_renderer_initiated */); |
2927 params.transferred_global_request_id = old_request_id; | 2931 params.transferred_global_request_id = old_request_id; |
2928 new_contents = OpenURL(params); | 2932 new_contents = OpenURL(params); |
2929 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); | 2933 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); |
2930 } else { | 2934 } else { |
2931 OpenURLParams params(url, referrer, source_frame_id, disposition, | 2935 OpenURLParams params(url, referrer, source_frame_id, disposition, |
2932 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); | 2936 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); |
2933 params.transferred_global_request_id = old_request_id; | 2937 params.transferred_global_request_id = old_request_id; |
2934 params.is_cross_site_redirect = is_cross_site_redirect; | 2938 params.is_cross_site_redirect = is_cross_site_redirect; |
| 2939 if (request_body) { |
| 2940 params.transition = content::PAGE_TRANSITION_FORM_SUBMIT; |
| 2941 params.extra_headers = extra_header; |
| 2942 params.browser_initiated_post_data = request_body; |
| 2943 } |
2935 new_contents = OpenURL(params); | 2944 new_contents = OpenURL(params); |
2936 } | 2945 } |
2937 if (new_contents) { | 2946 if (new_contents) { |
2938 // Notify observers. | 2947 // Notify observers. |
2939 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2948 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2940 DidOpenRequestedURL(new_contents, | 2949 DidOpenRequestedURL(new_contents, |
2941 url, | 2950 url, |
2942 referrer, | 2951 referrer, |
2943 disposition, | 2952 disposition, |
2944 transition_type, | 2953 transition_type, |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3358 | 3367 |
3359 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3368 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3360 return browser_plugin_guest_.get(); | 3369 return browser_plugin_guest_.get(); |
3361 } | 3370 } |
3362 | 3371 |
3363 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3372 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3364 return browser_plugin_embedder_.get(); | 3373 return browser_plugin_embedder_.get(); |
3365 } | 3374 } |
3366 | 3375 |
3367 } // namespace content | 3376 } // namespace content |
OLD | NEW |