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

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: Added test for serializing a huge data url 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 // CommitNavigation IPC, and then back to the browser again in the 536 // CommitNavigation IPC, and then back to the browser again in the
537 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 537 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
538 base::TimeTicks ui_timestamp = 538 base::TimeTicks ui_timestamp =
539 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 539 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
540 FrameMsg_UILoadMetricsReportType::Value report_type = 540 FrameMsg_UILoadMetricsReportType::Value report_type =
541 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 541 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
542 request->inputPerfMetricReportPolicy()); 542 request->inputPerfMetricReportPolicy());
543 return CommonNavigationParams( 543 return CommonNavigationParams(
544 request->url(), referrer, extra_data->transition_type(), 544 request->url(), referrer, extra_data->transition_type(),
545 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, 545 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry,
546 ui_timestamp, report_type, GURL(), GURL(), LOFI_UNSPECIFIED, 546 ui_timestamp, report_type, GURL(), GURL(), std::string(),
547 base::TimeTicks::Now()); 547 LOFI_UNSPECIFIED, base::TimeTicks::Now());
548 } 548 }
549 549
550 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) 550 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
551 media::Context3D GetSharedMainThreadContext3D() { 551 media::Context3D GetSharedMainThreadContext3D() {
552 cc::ContextProvider* provider = 552 cc::ContextProvider* provider =
553 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 553 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
554 if (!provider) 554 if (!provider)
555 return media::Context3D(); 555 return media::Context3D();
556 return media::Context3D(provider->ContextGL(), provider->GrContext()); 556 return media::Context3D(provider->ContextGL(), provider->GrContext());
557 } 557 }
(...skipping 2817 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 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 WebFrame* frame, 5141 WebFrame* frame,
5142 blink::WebFrameLoadType load_type) { 5142 blink::WebFrameLoadType load_type) {
5143 // A loadData request with a specified base URL. 5143 // A loadData request with a specified base URL.
5144 std::string mime_type, charset, data; 5144 std::string mime_type, charset, data;
5145 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 5145 if (net::DataURL::Parse(params.data_url_as_string.empty()
5146 ? params.url
5147 : GURL(params.data_url_as_string),
Charlie Reis 2015/12/10 20:43:47 This is the kind of check I'm concerned about, whi
mnaganov (inactive) 2015/12/11 23:14:24 Added more checks to ensure that the main url's da
Charlie Reis 2015/12/14 20:35:56 Acknowledged.
5148 &mime_type, &charset, &data)) {
5146 const GURL base_url = params.base_url_for_data_url.is_empty() ? 5149 const GURL base_url = params.base_url_for_data_url.is_empty() ?
5147 params.url : params.base_url_for_data_url; 5150 params.url : params.base_url_for_data_url;
5148 bool replace = load_type == blink::WebFrameLoadType::ReloadFromOrigin || 5151 bool replace = load_type == blink::WebFrameLoadType::ReloadFromOrigin ||
5149 load_type == blink::WebFrameLoadType::Reload; 5152 load_type == blink::WebFrameLoadType::Reload;
5150 frame->loadData( 5153 frame->loadData(
5151 WebData(data.c_str(), data.length()), 5154 WebData(data.c_str(), data.length()),
5152 WebString::fromUTF8(mime_type), 5155 WebString::fromUTF8(mime_type),
5153 WebString::fromUTF8(charset), 5156 WebString::fromUTF8(charset),
5154 base_url, 5157 base_url,
5155 // Needed so that history-url-only changes don't become reloads. 5158 // 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); 5466 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5464 scoped_refptr<media::AudioOutputDevice> device = 5467 scoped_refptr<media::AudioOutputDevice> device =
5465 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5468 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5466 security_origin); 5469 security_origin);
5467 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5470 media::OutputDeviceStatus status = device->GetDeviceStatus();
5468 device->Stop(); 5471 device->Stop();
5469 callback.Run(status); 5472 callback.Run(status);
5470 } 5473 }
5471 5474
5472 } // namespace content 5475 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698