Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1497743005: Allow huge data: URIs only via WebView.loadDataWithBaseUrl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make specific to Android, use RefCountedString Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 3364 matching lines...) Expand 10 before | Expand all | Expand 10 after
3375 if (GetRenderWidget()->has_host_context_menu_location()) { 3375 if (GetRenderWidget()->has_host_context_menu_location()) {
3376 params.x = GetRenderWidget()->host_context_menu_location().x(); 3376 params.x = GetRenderWidget()->host_context_menu_location().x();
3377 params.y = GetRenderWidget()->host_context_menu_location().y(); 3377 params.y = GetRenderWidget()->host_context_menu_location().y();
3378 } 3378 }
3379 3379
3380 // Serializing a GURL longer than kMaxURLChars will fail, so don't do 3380 // Serializing a GURL longer than kMaxURLChars will fail, so don't do
3381 // it. We replace it with an empty GURL so the appropriate items are disabled 3381 // it. We replace it with an empty GURL so the appropriate items are disabled
3382 // in the context menu. 3382 // in the context menu.
3383 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large 3383 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large
3384 // data encoded images. We should have a way to save them. 3384 // data encoded images. We should have a way to save them.
3385 if (params.src_url.spec().size() > GetMaxURLChars()) 3385 if (params.src_url.spec().size() > kMaxURLChars)
3386 params.src_url = GURL(); 3386 params.src_url = GURL();
3387 context_menu_node_ = data.node; 3387 context_menu_node_ = data.node;
3388 3388
3389 #if defined(OS_ANDROID) 3389 #if defined(OS_ANDROID)
3390 gfx::Rect start_rect; 3390 gfx::Rect start_rect;
3391 gfx::Rect end_rect; 3391 gfx::Rect end_rect;
3392 GetRenderWidget()->GetSelectionBounds(&start_rect, &end_rect); 3392 GetRenderWidget()->GetSelectionBounds(&start_rect, &end_rect);
3393 params.selection_start = gfx::Point(start_rect.x(), start_rect.bottom()); 3393 params.selection_start = gfx::Point(start_rect.x(), start_rect.bottom());
3394 params.selection_end = gfx::Point(end_rect.right(), end_rect.bottom()); 3394 params.selection_end = gfx::Point(end_rect.right(), end_rect.bottom());
3395 #endif 3395 #endif
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
4891 4891
4892 if (should_load_request) { 4892 if (should_load_request) {
4893 // Sanitize navigation start now that we know the load_type. 4893 // Sanitize navigation start now that we know the load_type.
4894 pending_navigation_params_->common_params.navigation_start = 4894 pending_navigation_params_->common_params.navigation_start =
4895 SanitizeNavigationTiming(load_type, common_params.navigation_start, 4895 SanitizeNavigationTiming(load_type, common_params.navigation_start,
4896 renderer_navigation_start); 4896 renderer_navigation_start);
4897 // Perform a navigation to a data url if needed. 4897 // Perform a navigation to a data url if needed.
4898 if (!common_params.base_url_for_data_url.is_empty() || 4898 if (!common_params.base_url_for_data_url.is_empty() ||
4899 (browser_side_navigation && 4899 (browser_side_navigation &&
4900 common_params.url.SchemeIs(url::kDataScheme))) { 4900 common_params.url.SchemeIs(url::kDataScheme))) {
4901 LoadDataURL(common_params, frame_, load_type); 4901 LoadDataURL(common_params, request_params, frame_, load_type);
4902 } else { 4902 } else {
4903 // Load the request. 4903 // Load the request.
4904 frame_->toWebLocalFrame()->load(request, load_type, 4904 frame_->toWebLocalFrame()->load(request, load_type,
4905 item_for_history_navigation); 4905 item_for_history_navigation);
4906 } 4906 }
4907 } 4907 }
4908 4908
4909 // In case LoadRequest failed before didCreateDataSource was called. 4909 // In case LoadRequest failed before didCreateDataSource was called.
4910 pending_navigation_params_.reset(); 4910 pending_navigation_params_.reset();
4911 } 4911 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
5131 MakeCommonNavigationParams(request, should_replace_current_entry), 5131 MakeCommonNavigationParams(request, should_replace_current_entry),
5132 BeginNavigationParams( 5132 BeginNavigationParams(
5133 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), 5133 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
5134 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), 5134 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(),
5135 request->skipServiceWorker(), 5135 request->skipServiceWorker(),
5136 GetRequestContextTypeForWebURLRequest(*request)), 5136 GetRequestContextTypeForWebURLRequest(*request)),
5137 GetRequestBodyForWebURLRequest(*request))); 5137 GetRequestBodyForWebURLRequest(*request)));
5138 } 5138 }
5139 5139
5140 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 5140 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
5141 const RequestNavigationParams& request_params,
5141 WebFrame* frame, 5142 WebFrame* frame,
5142 blink::WebFrameLoadType load_type) { 5143 blink::WebFrameLoadType load_type) {
5143 // A loadData request with a specified base URL. 5144 // A loadData request with a specified base URL.
5145 GURL data_url = params.url;
5146 #if defined(OS_ANDROID)
5147 if (!request_params.data_url_as_string.empty()) {
5148 #if DCHECK_IS_ON()
5149 {
5150 std::string mime_type, charset, data;
5151 DCHECK(net::DataURL::Parse(data_url, &mime_type, &charset, &data));
5152 DCHECK(data.empty());
5153 }
5154 #endif
5155 data_url = GURL(request_params.data_url_as_string);
5156 if (!data_url.is_valid() || !data_url.SchemeIs(url::kDataScheme)) {
5157 data_url = params.url;
5158 }
5159 }
5160 #endif
5144 std::string mime_type, charset, data; 5161 std::string mime_type, charset, data;
5145 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 5162 if (net::DataURL::Parse(data_url, &mime_type, &charset, &data)) {
5146 const GURL base_url = params.base_url_for_data_url.is_empty() ? 5163 const GURL base_url = params.base_url_for_data_url.is_empty() ?
5147 params.url : params.base_url_for_data_url; 5164 params.url : params.base_url_for_data_url;
5148 bool replace = load_type == blink::WebFrameLoadType::ReloadFromOrigin || 5165 bool replace = load_type == blink::WebFrameLoadType::ReloadFromOrigin ||
5149 load_type == blink::WebFrameLoadType::Reload; 5166 load_type == blink::WebFrameLoadType::Reload;
5150 frame->loadData( 5167 frame->loadData(
5151 WebData(data.c_str(), data.length()), 5168 WebData(data.c_str(), data.length()),
5152 WebString::fromUTF8(mime_type), 5169 WebString::fromUTF8(mime_type),
5153 WebString::fromUTF8(charset), 5170 WebString::fromUTF8(charset),
5154 base_url, 5171 base_url,
5155 // Needed so that history-url-only changes don't become reloads. 5172 // Needed so that history-url-only changes don't become reloads.
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
5463 media::ConvertToSwitchOutputDeviceCB(web_callbacks); 5480 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5464 scoped_refptr<media::AudioOutputDevice> device = 5481 scoped_refptr<media::AudioOutputDevice> device =
5465 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5482 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5466 security_origin); 5483 security_origin);
5467 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5484 media::OutputDeviceStatus status = device->GetDeviceStatus();
5468 device->Stop(); 5485 device->Stop();
5469 callback.Run(status); 5486 callback.Run(status);
5470 } 5487 }
5471 5488
5472 } // namespace content 5489 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698