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 194 matching lines...) Loading... |
205 params->extra_headers = entry.extra_headers(); | 205 params->extra_headers = entry.extra_headers(); |
206 params->transferred_request_child_id = | 206 params->transferred_request_child_id = |
207 entry.transferred_global_request_id().child_id; | 207 entry.transferred_global_request_id().child_id; |
208 params->transferred_request_request_id = | 208 params->transferred_request_request_id = |
209 entry.transferred_global_request_id().request_id; | 209 entry.transferred_global_request_id().request_id; |
210 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); | 210 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); |
211 // Avoid downloading when in view-source mode. | 211 // Avoid downloading when in view-source mode. |
212 params->allow_download = !entry.IsViewSourceMode(); | 212 params->allow_download = !entry.IsViewSourceMode(); |
213 params->is_post = entry.GetHasPostData(); | 213 params->is_post = entry.GetHasPostData(); |
214 if(entry.GetBrowserInitiatedPostData()) { | 214 if(entry.GetBrowserInitiatedPostData()) { |
215 params->browser_initiated_post_data.assign( | 215 params->browser_initiated_post_data = |
216 entry.GetBrowserInitiatedPostData()->front(), | 216 entry.GetBrowserInitiatedPostData(); |
217 entry.GetBrowserInitiatedPostData()->front() + | |
218 entry.GetBrowserInitiatedPostData()->size()); | |
219 | |
220 } | 217 } |
221 | 218 |
222 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL && | 219 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL && |
223 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { | 220 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { |
224 // We may have been redirected when navigating to the current URL. | 221 // 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 | 222 // 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 | 223 // POST wasn't involved; the latter case avoids issues with sending data to |
227 // the wrong page. | 224 // the wrong page. |
228 params->url = entry.GetOriginalRequestURL(); | 225 params->url = entry.GetOriginalRequestURL(); |
229 } else { | 226 } else { |
(...skipping 2638 matching lines...) Loading... |
2868 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 2865 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
2869 return; | 2866 return; |
2870 } | 2867 } |
2871 | 2868 |
2872 // Delegate to RequestTransferURL because this is just the generic | 2869 // Delegate to RequestTransferURL because this is just the generic |
2873 // case where |old_request_id| is empty. | 2870 // case where |old_request_id| is empty. |
2874 RequestTransferURL(url, referrer, disposition, source_frame_id, | 2871 RequestTransferURL(url, referrer, disposition, source_frame_id, |
2875 GlobalRequestID()); | 2872 GlobalRequestID()); |
2876 } | 2873 } |
2877 | 2874 |
| 2875 void WebContentsImpl::RequestOpenPostURL( |
| 2876 RenderViewHost* rvh, |
| 2877 const GURL& url, |
| 2878 const Referrer& referrer, |
| 2879 WindowOpenDisposition disposition, |
| 2880 int64 source_frame_id, |
| 2881 const ViewMsg_PostRequest_Params& request) { |
| 2882 // If this came from a swapped out RenderViewHost, we only allow the request |
| 2883 // if we are still in the same BrowsingInstance. |
| 2884 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && |
| 2885 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
| 2886 return; |
| 2887 } |
| 2888 |
| 2889 // Delegate to RequestTransferURL because this is just the generic |
| 2890 // case where |old_request_id| is empty. |
| 2891 RequestTransferPostURL(url, referrer, disposition, source_frame_id, |
| 2892 GlobalRequestID(), request); |
| 2893 } |
| 2894 |
2878 void WebContentsImpl::RequestTransferURL( | 2895 void WebContentsImpl::RequestTransferURL( |
2879 const GURL& url, | 2896 const GURL& url, |
2880 const Referrer& referrer, | 2897 const Referrer& referrer, |
2881 WindowOpenDisposition disposition, | 2898 WindowOpenDisposition disposition, |
2882 int64 source_frame_id, | 2899 int64 source_frame_id, |
2883 const GlobalRequestID& old_request_id) { | 2900 const GlobalRequestID& old_request_id) { |
2884 WebContents* new_contents = NULL; | 2901 WebContents* new_contents = NULL; |
2885 PageTransition transition_type = PAGE_TRANSITION_LINK; | 2902 PageTransition transition_type = PAGE_TRANSITION_LINK; |
2886 if (render_manager_.web_ui()) { | 2903 if (render_manager_.web_ui()) { |
2887 // When we're a Web UI, it will provide a page transition type for us (this | 2904 // When we're a Web UI, it will provide a page transition type for us (this |
(...skipping 21 matching lines...) Loading... |
2909 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2926 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2910 DidOpenRequestedURL(new_contents, | 2927 DidOpenRequestedURL(new_contents, |
2911 url, | 2928 url, |
2912 referrer, | 2929 referrer, |
2913 disposition, | 2930 disposition, |
2914 transition_type, | 2931 transition_type, |
2915 source_frame_id)); | 2932 source_frame_id)); |
2916 } | 2933 } |
2917 } | 2934 } |
2918 | 2935 |
| 2936 void WebContentsImpl::RequestTransferPostURL( |
| 2937 const GURL& url, |
| 2938 const content::Referrer& referrer, |
| 2939 WindowOpenDisposition disposition, |
| 2940 int64 source_frame_id, |
| 2941 const GlobalRequestID& old_request_id, |
| 2942 const ViewMsg_PostRequest_Params& request) { |
| 2943 WebContents* new_contents = NULL; |
| 2944 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; |
| 2945 if (render_manager_.web_ui()) { |
| 2946 // When we're a Web UI, it will provide a page transition type for us (this |
| 2947 // is so the new tab page can specify AUTO_BOOKMARK for automatically |
| 2948 // generated suggestions). |
| 2949 // |
| 2950 // Note also that we hide the referrer for Web UI pages. We don't really |
| 2951 // want web sites to see a referrer of "chrome://blah" (and some |
| 2952 // chrome: URLs might have search terms or other stuff we don't want to |
| 2953 // send to the site), so we send no referrer. |
| 2954 OpenURLParams params(url, content::Referrer(), source_frame_id, disposition, |
| 2955 render_manager_.web_ui()->GetLinkTransitionType(), |
| 2956 false /* is_renderer_initiated */); |
| 2957 params.transferred_global_request_id = old_request_id; |
| 2958 new_contents = OpenURL(params); |
| 2959 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); |
| 2960 } else { |
| 2961 OpenURLParams params(url, referrer, source_frame_id, disposition, |
| 2962 content::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); |
| 2963 params.transition = content::PAGE_TRANSITION_FORM_SUBMIT; |
| 2964 |
| 2965 params.browser_initiated_post_data = request.request_body; |
| 2966 params.extra_headers = request.extra_header; |
| 2967 |
| 2968 params.transferred_global_request_id = old_request_id; |
| 2969 new_contents = OpenURL(params); |
| 2970 } |
| 2971 if (new_contents) { |
| 2972 // Notify observers. |
| 2973 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2974 DidOpenRequestedURL(new_contents, |
| 2975 url, |
| 2976 referrer, |
| 2977 disposition, |
| 2978 transition_type, |
| 2979 source_frame_id)); |
| 2980 } |
| 2981 } |
| 2982 |
2919 void WebContentsImpl::RouteCloseEvent(RenderViewHost* rvh) { | 2983 void WebContentsImpl::RouteCloseEvent(RenderViewHost* rvh) { |
2920 // Tell the active RenderViewHost to run unload handlers and close, as long | 2984 // Tell the active RenderViewHost to run unload handlers and close, as long |
2921 // as the request came from a RenderViewHost in the same BrowsingInstance. | 2985 // as the request came from a RenderViewHost in the same BrowsingInstance. |
2922 // In most cases, we receive this from a swapped out RenderViewHost. | 2986 // In most cases, we receive this from a swapped out RenderViewHost. |
2923 // It is possible to receive it from one that has just been swapped in, | 2987 // It is possible to receive it from one that has just been swapped in, |
2924 // in which case we might as well deliver the message anyway. | 2988 // in which case we might as well deliver the message anyway. |
2925 if (rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) | 2989 if (rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) |
2926 GetRenderViewHost()->ClosePage(); | 2990 GetRenderViewHost()->ClosePage(); |
2927 } | 2991 } |
2928 | 2992 |
(...skipping 400 matching lines...) Loading... |
3329 | 3393 |
3330 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3394 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3331 return browser_plugin_guest_.get(); | 3395 return browser_plugin_guest_.get(); |
3332 } | 3396 } |
3333 | 3397 |
3334 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3398 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3335 return browser_plugin_embedder_.get(); | 3399 return browser_plugin_embedder_.get(); |
3336 } | 3400 } |
3337 | 3401 |
3338 } // namespace content | 3402 } // namespace content |
OLD | NEW |