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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 #include "ui/gfx/point.h" | 178 #include "ui/gfx/point.h" |
| 179 #include "ui/gfx/rect.h" | 179 #include "ui/gfx/rect.h" |
| 180 #include "ui/gfx/size_conversions.h" | 180 #include "ui/gfx/size_conversions.h" |
| 181 #include "v8/include/v8.h" | 181 #include "v8/include/v8.h" |
| 182 #include "webkit/appcache/web_application_cache_host_impl.h" | 182 #include "webkit/appcache/web_application_cache_host_impl.h" |
| 183 #include "webkit/base/file_path_string_conversions.h" | 183 #include "webkit/base/file_path_string_conversions.h" |
| 184 #include "webkit/dom_storage/dom_storage_types.h" | 184 #include "webkit/dom_storage/dom_storage_types.h" |
| 185 #include "webkit/glue/alt_error_page_resource_fetcher.h" | 185 #include "webkit/glue/alt_error_page_resource_fetcher.h" |
| 186 #include "webkit/glue/dom_operations.h" | 186 #include "webkit/glue/dom_operations.h" |
| 187 #include "webkit/glue/glue_serialize.h" | 187 #include "webkit/glue/glue_serialize.h" |
| 188 #include "webkit/glue/resource_request_body.h" | |
| 188 #include "webkit/glue/web_intent_service_data.h" | 189 #include "webkit/glue/web_intent_service_data.h" |
| 189 #include "webkit/glue/webdropdata.h" | 190 #include "webkit/glue/webdropdata.h" |
| 190 #include "webkit/glue/webkit_constants.h" | 191 #include "webkit/glue/webkit_constants.h" |
| 191 #include "webkit/glue/webkit_glue.h" | 192 #include "webkit/glue/webkit_glue.h" |
| 192 #include "webkit/glue/weburlresponse_extradata_impl.h" | 193 #include "webkit/glue/weburlresponse_extradata_impl.h" |
| 193 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 194 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
| 194 #include "webkit/media/webmediaplayer_impl.h" | 195 #include "webkit/media/webmediaplayer_impl.h" |
| 195 #include "webkit/media/webmediaplayer_ms.h" | 196 #include "webkit/media/webmediaplayer_ms.h" |
| 196 #include "webkit/plugins/npapi/plugin_list.h" | 197 #include "webkit/plugins/npapi/plugin_list.h" |
| 197 #include "webkit/plugins/npapi/webplugin_delegate.h" | 198 #include "webkit/plugins/npapi/webplugin_delegate.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 using WebKit::WebVector; | 314 using WebKit::WebVector; |
| 314 using WebKit::WebView; | 315 using WebKit::WebView; |
| 315 using WebKit::WebWidget; | 316 using WebKit::WebWidget; |
| 316 using WebKit::WebWindowFeatures; | 317 using WebKit::WebWindowFeatures; |
| 317 using appcache::WebApplicationCacheHostImpl; | 318 using appcache::WebApplicationCacheHostImpl; |
| 318 using base::Time; | 319 using base::Time; |
| 319 using base::TimeDelta; | 320 using base::TimeDelta; |
| 320 | 321 |
| 321 using webkit_glue::AltErrorPageResourceFetcher; | 322 using webkit_glue::AltErrorPageResourceFetcher; |
| 322 using webkit_glue::ResourceFetcher; | 323 using webkit_glue::ResourceFetcher; |
| 324 using webkit_glue::ResourceRequestBody; | |
| 323 using webkit_glue::WebPreferences; | 325 using webkit_glue::WebPreferences; |
| 324 using webkit_glue::WebURLResponseExtraDataImpl; | 326 using webkit_glue::WebURLResponseExtraDataImpl; |
| 325 | 327 |
| 326 #if defined(OS_ANDROID) | 328 #if defined(OS_ANDROID) |
| 327 using WebKit::WebContentDetectionResult; | 329 using WebKit::WebContentDetectionResult; |
| 328 using WebKit::WebFloatPoint; | 330 using WebKit::WebFloatPoint; |
| 329 using WebKit::WebFloatRect; | 331 using WebKit::WebFloatRect; |
| 330 using WebKit::WebHitTestResult; | 332 using WebKit::WebHitTestResult; |
| 331 #endif | 333 #endif |
| 332 | 334 |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 | 1128 |
| 1127 if (!params.extra_headers.empty()) { | 1129 if (!params.extra_headers.empty()) { |
| 1128 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | 1130 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 1129 params.extra_headers.end(), "\n"); | 1131 params.extra_headers.end(), "\n"); |
| 1130 i.GetNext(); ) { | 1132 i.GetNext(); ) { |
| 1131 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 1133 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 1132 WebString::fromUTF8(i.values())); | 1134 WebString::fromUTF8(i.values())); |
| 1133 } | 1135 } |
| 1134 } | 1136 } |
| 1135 | 1137 |
| 1136 if (params.is_post) { | 1138 if(params.is_post) { |
| 1137 request.setHTTPMethod(WebString::fromUTF8("POST")); | |
| 1138 | |
| 1139 // Set post data. | |
| 1140 WebHTTPBody http_body; | 1139 WebHTTPBody http_body; |
| 1141 http_body.initialize(); | 1140 http_body.initialize(); |
| 1142 http_body.appendData(WebData( | 1141 const std::vector<ResourceRequestBody::Element>* uploads = |
| 1143 reinterpret_cast<const char*>( | 1142 params.browser_initiated_post_data->elements(); |
| 1144 ¶ms.browser_initiated_post_data.front()), | 1143 std::vector<ResourceRequestBody::Element>::const_iterator iter; |
| 1145 params.browser_initiated_post_data.size())); | 1144 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
| 1145 switch (iter->type()) { | |
| 1146 case ResourceRequestBody::Element::TYPE_BYTES: { | |
| 1147 http_body.appendData(WebData(iter->bytes(), | |
| 1148 static_cast<int>(iter->length()))); | |
| 1149 break; | |
| 1150 } | |
| 1151 case ResourceRequestBody::Element::TYPE_FILE: { | |
| 1152 http_body.appendFileRange( | |
| 1153 WebString::fromUTF8(iter->path().value()), | |
| 1154 static_cast<long long>(iter->offset()), | |
| 1155 static_cast<long long>(iter->length()), | |
| 1156 iter->expected_modification_time().ToDoubleT()); | |
| 1157 break; | |
| 1158 } | |
| 1159 case ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM: { | |
| 1160 CHECK(false); | |
| 1161 break; | |
| 1162 } | |
| 1163 case ResourceRequestBody::Element:: TYPE_BLOB: { | |
| 1164 CHECK(false); | |
| 1165 break; | |
| 1166 } | |
| 1167 default: | |
| 1168 NOTREACHED(); | |
| 1169 } | |
| 1170 } | |
| 1146 request.setHTTPBody(http_body); | 1171 request.setHTTPBody(http_body); |
| 1172 request.setHTTPMethod(WebString::fromUTF8("POST")); | |
| 1173 request.setHTTPHeaderField( | |
| 1174 WebString::fromUTF8("Content-Type"), | |
| 1175 WebString::fromUTF8(params.extra_headers)); | |
| 1147 } | 1176 } |
| 1148 | |
| 1149 main_frame->loadRequest(request); | 1177 main_frame->loadRequest(request); |
| 1150 } | 1178 } |
| 1151 | |
| 1152 // In case LoadRequest failed before DidCreateDataSource was called. | 1179 // In case LoadRequest failed before DidCreateDataSource was called. |
| 1153 pending_navigation_params_.reset(); | 1180 pending_navigation_params_.reset(); |
| 1154 } | 1181 } |
| 1155 | 1182 |
| 1156 bool RenderViewImpl::IsBackForwardToStaleEntry( | 1183 bool RenderViewImpl::IsBackForwardToStaleEntry( |
| 1157 const ViewMsg_Navigate_Params& params, | 1184 const ViewMsg_Navigate_Params& params, |
| 1158 bool is_reload) { | 1185 bool is_reload) { |
| 1159 // Make sure this isn't a back/forward to an entry we have already cropped | 1186 // Make sure this isn't a back/forward to an entry we have already cropped |
| 1160 // or replaced from our history, before the browser knew about it. If so, | 1187 // or replaced from our history, before the browser knew about it. If so, |
| 1161 // a new navigation has committed in the mean time, and we can ignore this. | 1188 // a new navigation has committed in the mean time, and we can ignore this. |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1649 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) | 1676 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) |
| 1650 return; | 1677 return; |
| 1651 | 1678 |
| 1652 Send(new ViewHostMsg_UpdateState( | 1679 Send(new ViewHostMsg_UpdateState( |
| 1653 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1680 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
| 1654 } | 1681 } |
| 1655 | 1682 |
| 1656 void RenderViewImpl::OpenURL(WebFrame* frame, | 1683 void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1657 const GURL& url, | 1684 const GURL& url, |
| 1658 const Referrer& referrer, | 1685 const Referrer& referrer, |
| 1659 WebNavigationPolicy policy) { | 1686 WebNavigationPolicy policy, |
| 1660 Send(new ViewHostMsg_OpenURL( | 1687 std::string extra_header, |
| 1661 routing_id_, | 1688 scoped_refptr<ResourceRequestBody> |
| 1662 url, | 1689 request_body) { |
| 1663 referrer, | 1690 ViewHostMsg_OpenURL_Params params; |
| 1664 NavigationPolicyToDisposition(policy), | 1691 params.url = url; |
| 1665 frame->identifier())); | 1692 params.referrer = referrer; |
| 1693 params.disposition = NavigationPolicyToDisposition(policy); | |
| 1694 params.frame_id = frame->identifier(); | |
| 1695 params.extra_header = extra_header; | |
| 1696 params.request_body = request_body; | |
| 1697 Send(new ViewHostMsg_OpenURL(routing_id_, params)); | |
| 1666 } | 1698 } |
| 1667 | 1699 |
| 1668 // WebViewDelegate ------------------------------------------------------------ | 1700 // WebViewDelegate ------------------------------------------------------------ |
| 1669 | 1701 |
| 1670 void RenderViewImpl::LoadNavigationErrorPage( | 1702 void RenderViewImpl::LoadNavigationErrorPage( |
| 1671 WebFrame* frame, | 1703 WebFrame* frame, |
| 1672 const WebURLRequest& failed_request, | 1704 const WebURLRequest& failed_request, |
| 1673 const WebURLError& error, | 1705 const WebURLError& error, |
| 1674 const std::string& html, | 1706 const std::string& html, |
| 1675 bool replace) { | 1707 bool replace) { |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2661 WebFrame* frame, const WebURLRequest& request, | 2693 WebFrame* frame, const WebURLRequest& request, |
| 2662 WebNavigationPolicy policy, | 2694 WebNavigationPolicy policy, |
| 2663 const WebString& suggested_name) { | 2695 const WebString& suggested_name) { |
| 2664 Referrer referrer( | 2696 Referrer referrer( |
| 2665 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | 2697 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2666 GetReferrerPolicyFromRequest(frame, request)); | 2698 GetReferrerPolicyFromRequest(frame, request)); |
| 2667 if (policy == WebKit::WebNavigationPolicyDownload) { | 2699 if (policy == WebKit::WebNavigationPolicyDownload) { |
| 2668 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, | 2700 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
| 2669 suggested_name)); | 2701 suggested_name)); |
| 2670 } else { | 2702 } else { |
| 2671 OpenURL(frame, request.url(), referrer, policy); | 2703 OpenURL(frame, request.url(), referrer, policy, std::string(""), NULL); |
| 2672 } | 2704 } |
| 2673 } | 2705 } |
| 2674 | 2706 |
| 2675 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 2707 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
| 2676 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, | 2708 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
| 2677 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { | 2709 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
| 2678 Referrer referrer( | 2710 Referrer referrer( |
| 2679 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | 2711 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2680 GetReferrerPolicyFromRequest(frame, request)); | 2712 GetReferrerPolicyFromRequest(frame, request)); |
| 2681 | 2713 |
| 2682 if (is_swapped_out_) { | 2714 if (is_swapped_out_) { |
| 2683 if (request.url() != GURL(kSwappedOutURL)) { | 2715 if (request.url() != GURL(kSwappedOutURL)) { |
| 2684 // Targeted links may try to navigate a swapped out frame. Allow the | 2716 // Targeted links may try to navigate a swapped out frame. Allow the |
| 2685 // browser process to navigate the tab instead. Note that it is also | 2717 // browser process to navigate the tab instead. Note that it is also |
| 2686 // possible for non-targeted navigations (from this view) to arrive | 2718 // possible for non-targeted navigations (from this view) to arrive |
| 2687 // here just after we are swapped out. It's ok to send them to the | 2719 // here just after we are swapped out. It's ok to send them to the |
| 2688 // browser, as long as they're for the top level frame. | 2720 // browser, as long as they're for the top level frame. |
| 2689 // TODO(creis): Ensure this supports targeted form submissions when | 2721 // TODO(creis): Ensure this supports targeted form submissions when |
| 2690 // fixing http://crbug.com/101395. | 2722 // fixing http://crbug.com/101395. |
| 2691 if (frame->parent() == NULL) { | 2723 if (frame->parent() == NULL) { |
| 2692 OpenURL(frame, request.url(), referrer, default_policy); | 2724 OpenURL(frame, request.url(), referrer, |
| 2725 default_policy, std::string(""), NULL); | |
| 2693 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2726 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2694 } | 2727 } |
| 2695 | |
| 2696 // We should otherwise ignore in-process iframe navigations, if they | 2728 // We should otherwise ignore in-process iframe navigations, if they |
| 2697 // arrive just after we are swapped out. | 2729 // arrive just after we are swapped out. |
| 2698 return WebKit::WebNavigationPolicyIgnore; | 2730 return WebKit::WebNavigationPolicyIgnore; |
| 2699 } | 2731 } |
| 2700 | 2732 |
| 2701 // Allow kSwappedOutURL to complete. | 2733 // Allow kSwappedOutURL to complete. |
| 2702 return default_policy; | 2734 return default_policy; |
| 2703 } | 2735 } |
| 2704 | 2736 |
| 2705 // Webkit is asking whether to navigate to a new URL. | 2737 // Webkit is asking whether to navigate to a new URL. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2721 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 2753 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 2722 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && | 2754 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && |
| 2723 !frame->parent() && (is_content_initiated || is_redirect)) { | 2755 !frame->parent() && (is_content_initiated || is_redirect)) { |
| 2724 WebString origin_str = frame->document().securityOrigin().toString(); | 2756 WebString origin_str = frame->document().securityOrigin().toString(); |
| 2725 GURL frame_url(origin_str.utf8().data()); | 2757 GURL frame_url(origin_str.utf8().data()); |
| 2726 // TODO(cevans): revisit whether this site check is still necessary once | 2758 // TODO(cevans): revisit whether this site check is still necessary once |
| 2727 // crbug.com/101395 is fixed. | 2759 // crbug.com/101395 is fixed. |
| 2728 if (!net::RegistryControlledDomainService::SameDomainOrHost(frame_url, | 2760 if (!net::RegistryControlledDomainService::SameDomainOrHost(frame_url, |
| 2729 url) || | 2761 url) || |
| 2730 frame_url.scheme() != url.scheme()) { | 2762 frame_url.scheme() != url.scheme()) { |
| 2731 OpenURL(frame, url, referrer, default_policy); | 2763 WebString method = request.httpMethod(); |
| 2764 if(method != WebString("POST")) { | |
| 2765 OpenURL(frame, url, referrer, default_policy, std::string(""), NULL); | |
| 2766 } else { | |
| 2767 scoped_refptr<ResourceRequestBody> request_body = | |
| 2768 new ResourceRequestBody(); | |
| 2769 WebHTTPBody body = request.httpBody(); | |
| 2770 if (!body.isNull()) { | |
| 2771 WebKit::WebHTTPBody::Element element; | |
| 2772 for (int i=0; body.elementAt(i, element); i++) { | |
| 2773 switch (element.type) { | |
| 2774 case WebHTTPBody::Element::TypeData: | |
| 2775 if (!element.data.isEmpty()) | |
| 2776 request_body->AppendBytes( | |
| 2777 element.data.data(), | |
| 2778 static_cast<int>(element.data.size())); | |
| 2779 break; | |
| 2780 case WebHTTPBody::Element::TypeFile: { | |
| 2781 if (element.fileLength == -1) { | |
| 2782 request_body->AppendFileRange( | |
| 2783 FilePath(element.filePath.utf8()), | |
| 2784 0, kuint64max, base::Time()); | |
| 2785 } else { | |
| 2786 request_body->AppendFileRange( | |
| 2787 FilePath(element.filePath.utf8()), | |
|
irobert
2012/11/09 19:07:57
This statement cannot be built on windows but is o
| |
| 2788 static_cast<uint64>(element.fileStart), | |
| 2789 static_cast<uint64>(element.fileLength), | |
| 2790 base::Time::FromDoubleT(element.modificationTime)); | |
| 2791 } | |
| 2792 break; | |
| 2793 } | |
| 2794 case WebHTTPBody::Element::TypeURL: { | |
| 2795 CHECK(false); | |
| 2796 break; | |
| 2797 } | |
| 2798 case WebHTTPBody::Element::TypeBlob: { | |
| 2799 CHECK(false); | |
| 2800 break; | |
| 2801 } | |
| 2802 default: | |
| 2803 NOTREACHED(); | |
| 2804 } | |
| 2805 } | |
| 2806 } | |
| 2807 | |
| 2808 // Extract Header Info. | |
| 2809 WebString ContentType = | |
| 2810 request.httpHeaderField(WebString::fromUTF8("Content-Type")); | |
| 2811 std::string header(ContentType.utf8().data(), | |
| 2812 ContentType.utf8().length()); | |
| 2813 | |
| 2814 OpenURL(frame, url, referrer, default_policy, header, request_body); | |
| 2815 } | |
| 2732 return WebKit::WebNavigationPolicyIgnore; | 2816 return WebKit::WebNavigationPolicyIgnore; |
| 2733 } | 2817 } |
| 2734 } | 2818 } |
| 2735 | 2819 |
| 2736 // If the browser is interested, then give it a chance to look at the request. | 2820 // If the browser is interested, then give it a chance to look at the request. |
| 2737 if (is_content_initiated) { | 2821 if (is_content_initiated) { |
| 2738 bool browser_handles_request = | 2822 bool browser_handles_request = |
| 2739 renderer_preferences_.browser_handles_non_local_top_level_requests && | 2823 renderer_preferences_.browser_handles_non_local_top_level_requests && |
| 2740 IsNonLocalTopLevelNavigation(url, frame, type); | 2824 IsNonLocalTopLevelNavigation(url, frame, type); |
| 2741 if (!browser_handles_request) { | 2825 if (!browser_handles_request) { |
| 2742 browser_handles_request = | 2826 browser_handles_request = |
| 2743 renderer_preferences_.browser_handles_all_top_level_requests && | 2827 renderer_preferences_.browser_handles_all_top_level_requests && |
| 2744 IsTopLevelNavigation(frame); | 2828 IsTopLevelNavigation(frame); |
| 2745 } | 2829 } |
| 2746 | 2830 |
| 2747 if (browser_handles_request) { | 2831 if (browser_handles_request) { |
| 2748 // Reset these counters as the RenderView could be reused for the next | 2832 // Reset these counters as the RenderView could be reused for the next |
| 2749 // navigation. | 2833 // navigation. |
| 2750 page_id_ = -1; | 2834 page_id_ = -1; |
| 2751 last_page_id_sent_to_browser_ = -1; | 2835 last_page_id_sent_to_browser_ = -1; |
| 2752 OpenURL(frame, url, referrer, default_policy); | 2836 OpenURL(frame, url, referrer, default_policy, std::string(""), NULL); |
| 2753 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2837 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2754 } | 2838 } |
| 2755 } | 2839 } |
| 2756 | 2840 |
| 2757 // Use the frame's original request's URL rather than the document's URL for | 2841 // Use the frame's original request's URL rather than the document's URL for |
| 2758 // subsequent checks. For a popup, the document's URL may become the opener | 2842 // subsequent checks. For a popup, the document's URL may become the opener |
| 2759 // window's URL if the opener has called document.write(). | 2843 // window's URL if the opener has called document.write(). |
| 2760 // See http://crbug.com/93517. | 2844 // See http://crbug.com/93517. |
| 2761 GURL old_url(frame->dataSource()->request().url()); | 2845 GURL old_url(frame->dataSource()->request().url()); |
| 2762 | 2846 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2802 DCHECK(!source_url.is_empty()); | 2886 DCHECK(!source_url.is_empty()); |
| 2803 should_fork = !source_url.SchemeIs(chrome::kFileScheme); | 2887 should_fork = !source_url.SchemeIs(chrome::kFileScheme); |
| 2804 } | 2888 } |
| 2805 | 2889 |
| 2806 if (!should_fork) { | 2890 if (!should_fork) { |
| 2807 // Give the embedder a chance. | 2891 // Give the embedder a chance. |
| 2808 // For now, we skip this for POST submissions. This is because | 2892 // For now, we skip this for POST submissions. This is because |
| 2809 // http://crbug.com/101395 is more likely to cause compatibility issues | 2893 // http://crbug.com/101395 is more likely to cause compatibility issues |
| 2810 // with hosted apps and extensions than WebUI pages. We will remove this | 2894 // with hosted apps and extensions than WebUI pages. We will remove this |
| 2811 // check when cross-process POST submissions are supported. | 2895 // check when cross-process POST submissions are supported. |
| 2812 if (request.httpMethod() == "GET") { | |
| 2813 should_fork = GetContentClient()->renderer()->ShouldFork( | 2896 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 2814 frame, url, is_initial_navigation, &send_referrer); | 2897 frame, url, is_initial_navigation, &send_referrer); |
| 2815 } | |
| 2816 } | 2898 } |
| 2817 | 2899 |
| 2818 if (should_fork) { | 2900 if (should_fork) { |
| 2819 OpenURL( | 2901 if (request.httpMethod() == "GET") { |
| 2820 frame, url, send_referrer ? referrer : Referrer(), default_policy); | 2902 OpenURL(frame, url, |
| 2903 send_referrer ? referrer : Referrer(), | |
| 2904 default_policy, std::string(""), NULL); | |
| 2905 } | |
| 2906 else if (request.httpMethod() == "POST") { | |
| 2907 // Identical with the case when strict site-isolation is enabled. | |
| 2908 // We should find a way to use one copy. | |
| 2909 scoped_refptr<ResourceRequestBody> request_body = | |
| 2910 new ResourceRequestBody(); | |
| 2911 WebHTTPBody body = request.httpBody(); | |
| 2912 if (!body.isNull()) { | |
| 2913 WebKit::WebHTTPBody::Element element; | |
| 2914 for (int i=0; body.elementAt(i, element); i++) { | |
| 2915 switch (element.type) { | |
| 2916 case WebHTTPBody::Element::TypeData: | |
| 2917 if (!element.data.isEmpty()) | |
| 2918 request_body->AppendBytes( | |
| 2919 element.data.data(), | |
| 2920 static_cast<int>(element.data.size())); | |
| 2921 break; | |
| 2922 case WebHTTPBody::Element::TypeFile: { | |
| 2923 if (element.fileLength == -1) { | |
| 2924 request_body->AppendFileRange( | |
| 2925 FilePath(element.filePath.utf8()), | |
| 2926 0, kuint64max, base::Time()); | |
| 2927 } else { | |
| 2928 request_body->AppendFileRange( | |
| 2929 FilePath(element.filePath.utf8()), | |
| 2930 static_cast<uint64>(element.fileStart), | |
| 2931 static_cast<uint64>(element.fileLength), | |
| 2932 base::Time::FromDoubleT(element.modificationTime)); | |
| 2933 } | |
| 2934 break; | |
| 2935 } | |
| 2936 case WebHTTPBody::Element::TypeURL: { | |
| 2937 CHECK(false); | |
| 2938 break; | |
| 2939 } | |
| 2940 case WebHTTPBody::Element::TypeBlob: { | |
| 2941 CHECK(false); | |
| 2942 break; | |
| 2943 } | |
| 2944 default: | |
| 2945 NOTREACHED(); | |
| 2946 } | |
| 2947 } | |
| 2948 } | |
| 2949 // Extract Header Info. | |
| 2950 WebString ContentType = | |
| 2951 request.httpHeaderField(WebString::fromUTF8("Content-Type")); | |
| 2952 std::string header(ContentType.utf8().data(), | |
| 2953 ContentType.utf8().length()); | |
| 2954 OpenURL(frame, url, referrer, default_policy, header, request_body); | |
| 2955 } | |
| 2821 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2956 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2822 } | 2957 } |
| 2823 } | 2958 } |
| 2824 | 2959 |
| 2825 // Detect when a page is "forking" a new tab that can be safely rendered in | 2960 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 2826 // its own process. This is done by sites like Gmail that try to open links | 2961 // its own process. This is done by sites like Gmail that try to open links |
| 2827 // in new windows without script connections back to the original page. We | 2962 // in new windows without script connections back to the original page. We |
| 2828 // treat such cases as browser navigations (in which we will create a new | 2963 // treat such cases as browser navigations (in which we will create a new |
| 2829 // renderer for a cross-site navigation), rather than WebKit navigations. | 2964 // renderer for a cross-site navigation), rather than WebKit navigations. |
| 2830 // | 2965 // |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2849 frame->parent() == NULL && | 2984 frame->parent() == NULL && |
| 2850 // Must not have issued the request from this page. | 2985 // Must not have issued the request from this page. |
| 2851 is_content_initiated && | 2986 is_content_initiated && |
| 2852 // Must be targeted at the current tab. | 2987 // Must be targeted at the current tab. |
| 2853 default_policy == WebKit::WebNavigationPolicyCurrentTab && | 2988 default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2854 // Must be a JavaScript navigation, which appears as "other". | 2989 // Must be a JavaScript navigation, which appears as "other". |
| 2855 type == WebKit::WebNavigationTypeOther; | 2990 type == WebKit::WebNavigationTypeOther; |
| 2856 | 2991 |
| 2857 if (is_fork) { | 2992 if (is_fork) { |
| 2858 // Open the URL via the browser, not via WebKit. | 2993 // Open the URL via the browser, not via WebKit. |
| 2859 OpenURL(frame, url, Referrer(), default_policy); | 2994 OpenURL(frame, url, Referrer(), default_policy, std::string(""), NULL); |
| 2860 return WebKit::WebNavigationPolicyIgnore; | 2995 return WebKit::WebNavigationPolicyIgnore; |
| 2861 } | 2996 } |
| 2862 | |
| 2863 return default_policy; | 2997 return default_policy; |
| 2864 } | 2998 } |
| 2865 | 2999 |
| 2866 bool RenderViewImpl::canHandleRequest( | 3000 bool RenderViewImpl::canHandleRequest( |
| 2867 WebFrame* frame, const WebURLRequest& request) { | 3001 WebFrame* frame, const WebURLRequest& request) { |
| 2868 // We allow WebKit to think that everything can be handled even though | 3002 // We allow WebKit to think that everything can be handled even though |
| 2869 // browser-side we limit what we load. | 3003 // browser-side we limit what we load. |
| 2870 return true; | 3004 return true; |
| 2871 } | 3005 } |
| 2872 | 3006 |
| (...skipping 3480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6353 } | 6487 } |
| 6354 #endif | 6488 #endif |
| 6355 | 6489 |
| 6356 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6490 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
| 6357 TransportDIB::Handle dib_handle) { | 6491 TransportDIB::Handle dib_handle) { |
| 6358 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6492 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
| 6359 RenderProcess::current()->ReleaseTransportDIB(dib); | 6493 RenderProcess::current()->ReleaseTransportDIB(dib); |
| 6360 } | 6494 } |
| 6361 | 6495 |
| 6362 } // namespace content | 6496 } // namespace content |
| OLD | NEW |