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

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: Fixed the test 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <vector> 9 #include <vector>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/debug/alias.h" 13 #include "base/debug/alias.h"
14 #include "base/debug/asan_invalid_access.h" 14 #include "base/debug/asan_invalid_access.h"
15 #include "base/debug/dump_without_crashing.h" 15 #include "base/debug/dump_without_crashing.h"
16 #include "base/files/file.h" 16 #include "base/files/file.h"
17 #include "base/i18n/char_iterator.h" 17 #include "base/i18n/char_iterator.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/shared_memory.h"
19 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
20 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
21 #include "base/process/process.h" 22 #include "base/process/process.h"
22 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
23 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
24 #include "base/thread_task_runner_handle.h" 25 #include "base/thread_task_runner_handle.h"
25 #include "base/time/time.h" 26 #include "base/time/time.h"
26 #include "cc/base/switches.h" 27 #include "cc/base/switches.h"
27 #include "components/scheduler/renderer/renderer_scheduler.h" 28 #include "components/scheduler/renderer/renderer_scheduler.h"
28 #include "content/child/appcache/appcache_dispatcher.h" 29 #include "content/child/appcache/appcache_dispatcher.h"
(...skipping 3436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3465 if (GetRenderWidget()->has_host_context_menu_location()) { 3466 if (GetRenderWidget()->has_host_context_menu_location()) {
3466 params.x = GetRenderWidget()->host_context_menu_location().x(); 3467 params.x = GetRenderWidget()->host_context_menu_location().x();
3467 params.y = GetRenderWidget()->host_context_menu_location().y(); 3468 params.y = GetRenderWidget()->host_context_menu_location().y();
3468 } 3469 }
3469 3470
3470 // Serializing a GURL longer than kMaxURLChars will fail, so don't do 3471 // Serializing a GURL longer than kMaxURLChars will fail, so don't do
3471 // it. We replace it with an empty GURL so the appropriate items are disabled 3472 // it. We replace it with an empty GURL so the appropriate items are disabled
3472 // in the context menu. 3473 // in the context menu.
3473 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large 3474 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large
3474 // data encoded images. We should have a way to save them. 3475 // data encoded images. We should have a way to save them.
3475 if (params.src_url.spec().size() > GetMaxURLChars()) 3476 if (params.src_url.spec().size() > kMaxURLChars)
3476 params.src_url = GURL(); 3477 params.src_url = GURL();
3477 context_menu_node_ = data.node; 3478 context_menu_node_ = data.node;
3478 3479
3479 #if defined(OS_ANDROID) 3480 #if defined(OS_ANDROID)
3480 gfx::Rect start_rect; 3481 gfx::Rect start_rect;
3481 gfx::Rect end_rect; 3482 gfx::Rect end_rect;
3482 GetRenderWidget()->GetSelectionBounds(&start_rect, &end_rect); 3483 GetRenderWidget()->GetSelectionBounds(&start_rect, &end_rect);
3483 params.selection_start = gfx::Point(start_rect.x(), start_rect.bottom()); 3484 params.selection_start = gfx::Point(start_rect.x(), start_rect.bottom());
3484 params.selection_end = gfx::Point(end_rect.right(), end_rect.bottom()); 3485 params.selection_end = gfx::Point(end_rect.right(), end_rect.bottom());
3485 #endif 3486 #endif
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
5065 5066
5066 if (should_load_request) { 5067 if (should_load_request) {
5067 // Sanitize navigation start now that we know the load_type. 5068 // Sanitize navigation start now that we know the load_type.
5068 pending_navigation_params_->common_params.navigation_start = 5069 pending_navigation_params_->common_params.navigation_start =
5069 SanitizeNavigationTiming(load_type, common_params.navigation_start, 5070 SanitizeNavigationTiming(load_type, common_params.navigation_start,
5070 renderer_navigation_start); 5071 renderer_navigation_start);
5071 // Perform a navigation to a data url if needed. 5072 // Perform a navigation to a data url if needed.
5072 if (!common_params.base_url_for_data_url.is_empty() || 5073 if (!common_params.base_url_for_data_url.is_empty() ||
5073 (browser_side_navigation && 5074 (browser_side_navigation &&
5074 common_params.url.SchemeIs(url::kDataScheme))) { 5075 common_params.url.SchemeIs(url::kDataScheme))) {
5075 LoadDataURL(common_params, frame_, load_type); 5076 LoadDataURL(common_params, request_params, frame_, load_type);
5076 } else { 5077 } else {
5077 // Load the request. 5078 // Load the request.
5078 frame_->toWebLocalFrame()->load(request, load_type, 5079 frame_->toWebLocalFrame()->load(request, load_type,
5079 item_for_history_navigation); 5080 item_for_history_navigation);
5080 } 5081 }
5081 } 5082 }
5082 5083
5083 // In case LoadRequest failed before didCreateDataSource was called. 5084 // In case LoadRequest failed before didCreateDataSource was called.
5084 pending_navigation_params_.reset(); 5085 pending_navigation_params_.reset();
5085 } 5086 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
5305 MakeCommonNavigationParams(request, should_replace_current_entry), 5306 MakeCommonNavigationParams(request, should_replace_current_entry),
5306 BeginNavigationParams( 5307 BeginNavigationParams(
5307 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), 5308 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
5308 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), 5309 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(),
5309 request->skipServiceWorker(), 5310 request->skipServiceWorker(),
5310 GetRequestContextTypeForWebURLRequest(*request)), 5311 GetRequestContextTypeForWebURLRequest(*request)),
5311 GetRequestBodyForWebURLRequest(*request))); 5312 GetRequestBodyForWebURLRequest(*request)));
5312 } 5313 }
5313 5314
5314 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 5315 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
5316 const RequestNavigationParams& request_params,
5315 WebFrame* frame, 5317 WebFrame* frame,
5316 blink::WebFrameLoadType load_type) { 5318 blink::WebFrameLoadType load_type) {
5317 // A loadData request with a specified base URL. 5319 // A loadData request with a specified base URL.
5320 GURL data_url = params.url;
5321 #if defined(OS_ANDROID)
5322 if (!request_params.data_url_as_string.empty()) {
5323 #if DCHECK_IS_ON()
5324 {
5325 std::string mime_type, charset, data;
5326 DCHECK(net::DataURL::Parse(data_url, &mime_type, &charset, &data));
5327 DCHECK(data.empty());
5328 }
5329 #endif
5330 data_url = GURL(request_params.data_url_as_string);
5331 if (!data_url.is_valid() || !data_url.SchemeIs(url::kDataScheme)) {
5332 data_url = params.url;
5333 }
5334 }
5335 #endif
5318 std::string mime_type, charset, data; 5336 std::string mime_type, charset, data;
5319 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 5337 if (net::DataURL::Parse(data_url, &mime_type, &charset, &data)) {
5320 const GURL base_url = params.base_url_for_data_url.is_empty() ? 5338 const GURL base_url = params.base_url_for_data_url.is_empty() ?
5321 params.url : params.base_url_for_data_url; 5339 params.url : params.base_url_for_data_url;
5322 bool replace = load_type == blink::WebFrameLoadType::ReloadFromOrigin || 5340 bool replace = load_type == blink::WebFrameLoadType::ReloadFromOrigin ||
5323 load_type == blink::WebFrameLoadType::Reload; 5341 load_type == blink::WebFrameLoadType::Reload;
5324 frame->loadData( 5342 frame->loadData(
5325 WebData(data.c_str(), data.length()), 5343 WebData(data.c_str(), data.length()),
5326 WebString::fromUTF8(mime_type), 5344 WebString::fromUTF8(mime_type),
5327 WebString::fromUTF8(charset), 5345 WebString::fromUTF8(charset),
5328 base_url, 5346 base_url,
5329 // Needed so that history-url-only changes don't become reloads. 5347 // Needed so that history-url-only changes don't become reloads.
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
5637 media::ConvertToSwitchOutputDeviceCB(web_callbacks); 5655 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5638 scoped_refptr<media::AudioOutputDevice> device = 5656 scoped_refptr<media::AudioOutputDevice> device =
5639 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5657 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5640 security_origin); 5658 security_origin);
5641 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5659 media::OutputDeviceStatus status = device->GetDeviceStatus();
5642 device->Stop(); 5660 device->Stop();
5643 callback.Run(status); 5661 callback.Run(status);
5644 } 5662 }
5645 5663
5646 } // namespace content 5664 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698