Chromium Code Reviews| 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 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2847 | 2845 |
| 2848 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( | 2846 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( |
| 2849 RenderViewHost* render_view_host, | 2847 RenderViewHost* render_view_host, |
| 2850 int32 page_id) { | 2848 int32 page_id) { |
| 2851 NotificationService::current()->Notify( | 2849 NotificationService::current()->Notify( |
| 2852 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 2850 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 2853 Source<WebContents>(this), | 2851 Source<WebContents>(this), |
| 2854 Details<int>(&page_id)); | 2852 Details<int>(&page_id)); |
| 2855 } | 2853 } |
| 2856 | 2854 |
| 2857 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 2855 void WebContentsImpl::RequestOpenURL( |
| 2858 const GURL& url, | 2856 RenderViewHost* rvh, |
| 2859 const Referrer& referrer, | 2857 const GURL& url, |
| 2860 WindowOpenDisposition disposition, | 2858 const Referrer& referrer, |
| 2861 int64 source_frame_id, | 2859 WindowOpenDisposition disposition, |
| 2862 bool is_cross_site_redirect) { | 2860 int64 source_frame_id, |
| 2861 bool is_cross_site_redirect, | |
| 2862 std::string extra_header, | |
| 2863 scoped_refptr<ResourceRequestBody> request_body) { | |
| 2863 // If this came from a swapped out RenderViewHost, we only allow the request | 2864 // If this came from a swapped out RenderViewHost, we only allow the request |
| 2864 // if we are still in the same BrowsingInstance. | 2865 // if we are still in the same BrowsingInstance. |
| 2865 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 2866 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && |
| 2866 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 2867 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
| 2867 return; | 2868 return; |
| 2868 } | 2869 } |
| 2869 | 2870 |
| 2870 // Delegate to RequestTransferURL because this is just the generic | 2871 // Delegate to RequestTransferURL because this is just the generic |
| 2871 // case where |old_request_id| is empty. | 2872 // case where |old_request_id| is empty. |
| 2872 RequestTransferURL(url, referrer, disposition, source_frame_id, | 2873 RequestTransferURL(url, referrer, disposition, source_frame_id, |
| 2873 GlobalRequestID(), is_cross_site_redirect); | 2874 GlobalRequestID(), is_cross_site_redirect, |
| 2875 extra_header, request_body); | |
| 2874 } | 2876 } |
| 2875 | 2877 |
| 2876 void WebContentsImpl::RequestTransferURL( | 2878 void WebContentsImpl::RequestTransferURL( |
| 2877 const GURL& url, | 2879 const GURL& url, |
| 2878 const Referrer& referrer, | 2880 const Referrer& referrer, |
| 2879 WindowOpenDisposition disposition, | 2881 WindowOpenDisposition disposition, |
| 2880 int64 source_frame_id, | 2882 int64 source_frame_id, |
| 2881 const GlobalRequestID& old_request_id, | 2883 const GlobalRequestID& old_request_id, |
| 2882 bool is_cross_site_redirect) { | 2884 bool is_cross_site_redirect, |
| 2885 std::string extra_header, | |
| 2886 scoped_refptr<ResourceRequestBody> request_body) { | |
| 2883 WebContents* new_contents = NULL; | 2887 WebContents* new_contents = NULL; |
| 2884 PageTransition transition_type = PAGE_TRANSITION_LINK; | 2888 PageTransition transition_type = PAGE_TRANSITION_LINK; |
| 2885 if (render_manager_.web_ui()) { | 2889 if (render_manager_.web_ui()) { |
| 2886 // 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 |
| 2887 // 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 |
| 2888 // generated suggestions). | 2892 // generated suggestions). |
| 2889 // | 2893 // |
| 2890 // 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 |
| 2891 // 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 |
| 2892 // 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 |
| 2893 // send to the site), so we send no referrer. | 2897 // send to the site), so we send no referrer. |
| 2894 OpenURLParams params(url, Referrer(), source_frame_id, disposition, | 2898 OpenURLParams params(url, Referrer(), source_frame_id, disposition, |
| 2895 render_manager_.web_ui()->GetLinkTransitionType(), | 2899 render_manager_.web_ui()->GetLinkTransitionType(), |
| 2896 false /* is_renderer_initiated */); | 2900 false /* is_renderer_initiated */); |
| 2897 params.transferred_global_request_id = old_request_id; | 2901 params.transferred_global_request_id = old_request_id; |
| 2898 new_contents = OpenURL(params); | 2902 new_contents = OpenURL(params); |
| 2899 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); | 2903 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); |
| 2900 } else { | 2904 } else { |
| 2901 OpenURLParams params(url, referrer, source_frame_id, disposition, | 2905 OpenURLParams params(url, referrer, source_frame_id, disposition, |
| 2902 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); | 2906 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); |
| 2903 params.transferred_global_request_id = old_request_id; | 2907 params.transferred_global_request_id = old_request_id; |
| 2904 params.is_cross_site_redirect = is_cross_site_redirect; | 2908 params.is_cross_site_redirect = is_cross_site_redirect; |
| 2909 if(request_body != NULL) { | |
|
Charlie Reis
2012/11/20 05:46:03
nit: Space after if.
nit: Don't need "!= NULL"
irobert
2012/11/22 01:37:00
Done.
| |
| 2910 params.transition = content::PAGE_TRANSITION_FORM_SUBMIT; | |
| 2911 params.extra_headers = extra_header; | |
| 2912 params.browser_initiated_post_data = request_body; | |
| 2913 } | |
| 2905 new_contents = OpenURL(params); | 2914 new_contents = OpenURL(params); |
| 2906 } | 2915 } |
| 2907 if (new_contents) { | 2916 if (new_contents) { |
| 2908 // Notify observers. | 2917 // Notify observers. |
| 2909 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2918 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2910 DidOpenRequestedURL(new_contents, | 2919 DidOpenRequestedURL(new_contents, |
| 2911 url, | 2920 url, |
| 2912 referrer, | 2921 referrer, |
| 2913 disposition, | 2922 disposition, |
| 2914 transition_type, | 2923 transition_type, |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3328 | 3337 |
| 3329 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3338 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3330 return browser_plugin_guest_.get(); | 3339 return browser_plugin_guest_.get(); |
| 3331 } | 3340 } |
| 3332 | 3341 |
| 3333 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3342 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3334 return browser_plugin_embedder_.get(); | 3343 return browser_plugin_embedder_.get(); |
| 3335 } | 3344 } |
| 3336 | 3345 |
| 3337 } // namespace content | 3346 } // namespace content |
| OLD | NEW |