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 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2850 | 2848 |
2851 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( | 2849 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( |
2852 RenderViewHost* render_view_host, | 2850 RenderViewHost* render_view_host, |
2853 int32 page_id) { | 2851 int32 page_id) { |
2854 NotificationService::current()->Notify( | 2852 NotificationService::current()->Notify( |
2855 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 2853 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
2856 Source<WebContents>(this), | 2854 Source<WebContents>(this), |
2857 Details<int>(&page_id)); | 2855 Details<int>(&page_id)); |
2858 } | 2856 } |
2859 | 2857 |
2860 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 2858 void WebContentsImpl::RequestOpenURL( |
2861 const GURL& url, | 2859 RenderViewHost* rvh, |
2862 const Referrer& referrer, | 2860 const GURL& url, |
2863 WindowOpenDisposition disposition, | 2861 const Referrer& referrer, |
2864 int64 source_frame_id) { | 2862 WindowOpenDisposition disposition, |
| 2863 int64 source_frame_id, |
| 2864 std::string extra_header, |
| 2865 scoped_refptr<ResourceRequestBody> request_body) { |
2865 // If this came from a swapped out RenderViewHost, we only allow the request | 2866 // If this came from a swapped out RenderViewHost, we only allow the request |
2866 // if we are still in the same BrowsingInstance. | 2867 // if we are still in the same BrowsingInstance. |
2867 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 2868 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && |
2868 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 2869 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
2869 return; | 2870 return; |
2870 } | 2871 } |
2871 | 2872 |
2872 // Delegate to RequestTransferURL because this is just the generic | 2873 // Delegate to RequestTransferURL because this is just the generic |
2873 // case where |old_request_id| is empty. | 2874 // case where |old_request_id| is empty. |
2874 RequestTransferURL(url, referrer, disposition, source_frame_id, | 2875 RequestTransferURL(url, referrer, disposition, source_frame_id, |
2875 GlobalRequestID()); | 2876 GlobalRequestID(), extra_header, request_body); |
2876 } | 2877 } |
2877 | 2878 |
2878 void WebContentsImpl::RequestTransferURL( | 2879 void WebContentsImpl::RequestTransferURL( |
2879 const GURL& url, | 2880 const GURL& url, |
2880 const Referrer& referrer, | 2881 const Referrer& referrer, |
2881 WindowOpenDisposition disposition, | 2882 WindowOpenDisposition disposition, |
2882 int64 source_frame_id, | 2883 int64 source_frame_id, |
2883 const GlobalRequestID& old_request_id) { | 2884 const GlobalRequestID& old_request_id, |
| 2885 std::string extra_header, |
| 2886 scoped_refptr<ResourceRequestBody> request_body) { |
2884 WebContents* new_contents = NULL; | 2887 WebContents* new_contents = NULL; |
2885 PageTransition transition_type = PAGE_TRANSITION_LINK; | 2888 PageTransition transition_type = PAGE_TRANSITION_LINK; |
2886 if (render_manager_.web_ui()) { | 2889 if (render_manager_.web_ui()) { |
2887 // When we're a Web UI, it will provide a page transition type for us (this | 2890 // When we're a Web UI, it will provide a page transition type for us (this |
2888 // is so the new tab page can specify AUTO_BOOKMARK for automatically | 2891 // is so the new tab page can specify AUTO_BOOKMARK for automatically |
2889 // generated suggestions). | 2892 // generated suggestions). |
2890 // | 2893 // |
2891 // Note also that we hide the referrer for Web UI pages. We don't really | 2894 // Note also that we hide the referrer for Web UI pages. We don't really |
2892 // want web sites to see a referrer of "chrome://blah" (and some | 2895 // want web sites to see a referrer of "chrome://blah" (and some |
2893 // chrome: URLs might have search terms or other stuff we don't want to | 2896 // chrome: URLs might have search terms or other stuff we don't want to |
2894 // send to the site), so we send no referrer. | 2897 // send to the site), so we send no referrer. |
2895 OpenURLParams params(url, Referrer(), source_frame_id, disposition, | 2898 OpenURLParams params(url, Referrer(), source_frame_id, disposition, |
2896 render_manager_.web_ui()->GetLinkTransitionType(), | 2899 render_manager_.web_ui()->GetLinkTransitionType(), |
2897 false /* is_renderer_initiated */); | 2900 false /* is_renderer_initiated */); |
2898 params.transferred_global_request_id = old_request_id; | 2901 params.transferred_global_request_id = old_request_id; |
2899 new_contents = OpenURL(params); | 2902 new_contents = OpenURL(params); |
2900 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); | 2903 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); |
2901 } else { | 2904 } else { |
2902 OpenURLParams params(url, referrer, source_frame_id, disposition, | 2905 OpenURLParams params(url, referrer, source_frame_id, disposition, |
2903 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); | 2906 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); |
2904 params.transferred_global_request_id = old_request_id; | 2907 params.transferred_global_request_id = old_request_id; |
| 2908 if(request_body != NULL) { |
| 2909 params.transition = content::PAGE_TRANSITION_FORM_SUBMIT; |
| 2910 params.extra_headers = extra_header; |
| 2911 params.browser_initiated_post_data = request_body; |
| 2912 } |
2905 new_contents = OpenURL(params); | 2913 new_contents = OpenURL(params); |
2906 } | 2914 } |
2907 if (new_contents) { | 2915 if (new_contents) { |
2908 // Notify observers. | 2916 // Notify observers. |
2909 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2917 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2910 DidOpenRequestedURL(new_contents, | 2918 DidOpenRequestedURL(new_contents, |
2911 url, | 2919 url, |
2912 referrer, | 2920 referrer, |
2913 disposition, | 2921 disposition, |
2914 transition_type, | 2922 transition_type, |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3329 | 3337 |
3330 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3338 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3331 return browser_plugin_guest_.get(); | 3339 return browser_plugin_guest_.get(); |
3332 } | 3340 } |
3333 | 3341 |
3334 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3342 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3335 return browser_plugin_embedder_.get(); | 3343 return browser_plugin_embedder_.get(); |
3336 } | 3344 } |
3337 | 3345 |
3338 } // namespace content | 3346 } // namespace content |
OLD | NEW |