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

Side by Side Diff: content/browser/renderer_host/render_message_filter.cc

Issue 518693002: Fix a crash when saving a <canvas> or <img> image which is large. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CONTENT_EXPORT Created 6 years, 3 months 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 (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/renderer_host/render_message_filter.h" 5 #include "content/browser/renderer_host/render_message_filter.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/browser/media/media_internals.h" 25 #include "content/browser/media/media_internals.h"
26 #include "content/browser/plugin_process_host.h" 26 #include "content/browser/plugin_process_host.h"
27 #include "content/browser/renderer_host/pepper/pepper_security_helper.h" 27 #include "content/browser/renderer_host/pepper/pepper_security_helper.h"
28 #include "content/browser/renderer_host/render_process_host_impl.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
29 #include "content/browser/renderer_host/render_view_host_delegate.h" 29 #include "content/browser/renderer_host/render_view_host_delegate.h"
30 #include "content/browser/renderer_host/render_widget_helper.h" 30 #include "content/browser/renderer_host/render_widget_helper.h"
31 #include "content/browser/renderer_host/render_widget_resize_helper.h" 31 #include "content/browser/renderer_host/render_widget_resize_helper.h"
32 #include "content/browser/transition_request_manager.h" 32 #include "content/browser/transition_request_manager.h"
33 #include "content/common/child_process_host_impl.h" 33 #include "content/common/child_process_host_impl.h"
34 #include "content/common/child_process_messages.h" 34 #include "content/common/child_process_messages.h"
35 #include "content/common/content_constants_internal.h"
35 #include "content/common/cookie_data.h" 36 #include "content/common/cookie_data.h"
36 #include "content/common/desktop_notification_messages.h" 37 #include "content/common/desktop_notification_messages.h"
37 #include "content/common/frame_messages.h" 38 #include "content/common/frame_messages.h"
38 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 39 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
39 #include "content/common/host_shared_bitmap_manager.h" 40 #include "content/common/host_shared_bitmap_manager.h"
40 #include "content/common/media/media_param_traits.h" 41 #include "content/common/media/media_param_traits.h"
41 #include "content/common/view_messages.h" 42 #include "content/common/view_messages.h"
42 #include "content/public/browser/browser_child_process_host.h" 43 #include "content/public/browser/browser_child_process_host.h"
43 #include "content/public/browser/browser_context.h" 44 #include "content/public/browser/browser_context.h"
44 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 resource_context_(browser_context->GetResourceContext()), 347 resource_context_(browser_context->GetResourceContext()),
347 render_widget_helper_(render_widget_helper), 348 render_widget_helper_(render_widget_helper),
348 incognito_(browser_context->IsOffTheRecord()), 349 incognito_(browser_context->IsOffTheRecord()),
349 dom_storage_context_(dom_storage_context), 350 dom_storage_context_(dom_storage_context),
350 render_process_id_(render_process_id), 351 render_process_id_(render_process_id),
351 cpu_usage_(0), 352 cpu_usage_(0),
352 audio_manager_(audio_manager), 353 audio_manager_(audio_manager),
353 media_internals_(media_internals) { 354 media_internals_(media_internals) {
354 DCHECK(request_context_.get()); 355 DCHECK(request_context_.get());
355 356
356 render_widget_helper_->Init(render_process_id_, resource_dispatcher_host_); 357 if (render_widget_helper)
358 render_widget_helper_->Init(render_process_id_, resource_dispatcher_host_);
357 } 359 }
358 360
359 RenderMessageFilter::~RenderMessageFilter() { 361 RenderMessageFilter::~RenderMessageFilter() {
360 // This function should be called on the IO thread. 362 // This function should be called on the IO thread.
361 DCHECK_CURRENTLY_ON(BrowserThread::IO); 363 DCHECK_CURRENTLY_ON(BrowserThread::IO);
362 DCHECK(plugin_host_clients_.empty()); 364 DCHECK(plugin_host_clients_.empty());
363 HostSharedBitmapManager::current()->ProcessRemoved(PeerHandle()); 365 HostSharedBitmapManager::current()->ProcessRemoved(PeerHandle());
364 } 366 }
365 367
366 void RenderMessageFilter::OnChannelClosing() { 368 void RenderMessageFilter::OnChannelClosing() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 OnCreateFullscreenWidget) 416 OnCreateFullscreenWidget)
415 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) 417 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie)
416 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) 418 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies)
417 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies) 419 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies)
418 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) 420 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie)
419 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled) 421 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled)
420 #if defined(OS_MACOSX) 422 #if defined(OS_MACOSX)
421 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont) 423 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont)
422 #endif 424 #endif
423 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) 425 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl)
426 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveImageFromDataURL,
427 OnSaveImageFromDataURL)
424 #if defined(ENABLE_PLUGINS) 428 #if defined(ENABLE_PLUGINS)
425 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) 429 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins)
426 IPC_MESSAGE_HANDLER(FrameHostMsg_GetPluginInfo, OnGetPluginInfo) 430 IPC_MESSAGE_HANDLER(FrameHostMsg_GetPluginInfo, OnGetPluginInfo)
427 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_OpenChannelToPlugin, 431 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_OpenChannelToPlugin,
428 OnOpenChannelToPlugin) 432 OnOpenChannelToPlugin)
429 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin, 433 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin,
430 OnOpenChannelToPepperPlugin) 434 OnOpenChannelToPepperPlugin)
431 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance, 435 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance,
432 OnDidCreateOutOfProcessPepperInstance) 436 OnDidCreateOutOfProcessPepperInstance)
433 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteOutOfProcessPepperInstance, 437 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteOutOfProcessPepperInstance,
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 media::AudioManagerBase::kDefaultDeviceId); 892 media::AudioManagerBase::kDefaultDeviceId);
889 } 893 }
890 894
891 #if defined(OS_WIN) 895 #if defined(OS_WIN)
892 void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) { 896 void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) {
893 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); 897 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
894 *profile = g_color_profile.Get().profile(); 898 *profile = g_color_profile.Get().profile();
895 } 899 }
896 #endif 900 #endif
897 901
898 void RenderMessageFilter::OnDownloadUrl(int render_view_id, 902 void RenderMessageFilter::DownloadUrl(int render_view_id,
899 const GURL& url, 903 const GURL& url,
900 const Referrer& referrer, 904 const Referrer& referrer,
901 const base::string16& suggested_name, 905 const base::string16& suggested_name,
902 const bool use_prompt) { 906 const bool use_prompt) const {
903 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); 907 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
904 save_info->suggested_name = suggested_name; 908 save_info->suggested_name = suggested_name;
905 save_info->prompt_for_save_location = use_prompt; 909 save_info->prompt_for_save_location = use_prompt;
906 910
907 // There may be a special cookie store that we could use for this download, 911 // There may be a special cookie store that we could use for this download,
908 // rather than the default one. Since this feature is generally only used for 912 // rather than the default one. Since this feature is generally only used for
909 // proper render views, and not downloads, we do not need to retrieve the 913 // proper render views, and not downloads, we do not need to retrieve the
910 // special cookie store here, but just initialize the request to use the 914 // special cookie store here, but just initialize the request to use the
911 // default cookie store. 915 // default cookie store.
912 // TODO(tburkard): retrieve the appropriate special cookie store, if this 916 // TODO(tburkard): retrieve the appropriate special cookie store, if this
913 // is ever to be used for downloads as well. 917 // is ever to be used for downloads as well.
918
914 scoped_ptr<net::URLRequest> request( 919 scoped_ptr<net::URLRequest> request(
915 resource_context_->GetRequestContext()->CreateRequest( 920 resource_context_->GetRequestContext()->CreateRequest(
916 url, net::DEFAULT_PRIORITY, NULL, NULL)); 921 url, net::DEFAULT_PRIORITY, NULL, NULL));
917 RecordDownloadSource(INITIATED_BY_RENDERER); 922 RecordDownloadSource(INITIATED_BY_RENDERER);
918 resource_dispatcher_host_->BeginDownload( 923 resource_dispatcher_host_->BeginDownload(
919 request.Pass(), 924 request.Pass(),
920 referrer, 925 referrer,
921 true, // is_content_initiated 926 true, // is_content_initiated
922 resource_context_, 927 resource_context_,
923 render_process_id_, 928 render_process_id_,
924 render_view_id, 929 render_view_id,
925 false, 930 false,
926 save_info.Pass(), 931 save_info.Pass(),
927 DownloadItem::kInvalidId, 932 DownloadItem::kInvalidId,
928 ResourceDispatcherHostImpl::DownloadStartedCallback()); 933 ResourceDispatcherHostImpl::DownloadStartedCallback());
929 } 934 }
930 935
936 void RenderMessageFilter::OnDownloadUrl(int render_view_id,
937 const GURL& url,
938 const Referrer& referrer,
939 const base::string16& suggested_name) {
940 DownloadUrl(render_view_id, url, referrer, suggested_name, false);
941 }
942
943 void RenderMessageFilter::OnSaveImageFromDataURL(int render_view_id,
944 const std::string& url_str) {
945 // Please refer to RenderViewImpl::saveImageFromDataURL().
946 if (url_str.length() >= kMaxLengthOfDataURLString)
947 return;
948
949 GURL data_url(url_str);
950 if (!data_url.SchemeIs(url::kDataScheme))
951 return;
952
953 DownloadUrl(render_view_id, data_url, Referrer(), base::string16(), true);
954 }
955
931 void RenderMessageFilter::OnCheckNotificationPermission( 956 void RenderMessageFilter::OnCheckNotificationPermission(
932 const GURL& source_origin, int* result) { 957 const GURL& source_origin, int* result) {
933 #if defined(ENABLE_NOTIFICATIONS) 958 #if defined(ENABLE_NOTIFICATIONS)
934 *result = GetContentClient()->browser()-> 959 *result = GetContentClient()->browser()->
935 CheckDesktopNotificationPermission(source_origin, resource_context_, 960 CheckDesktopNotificationPermission(source_origin, resource_context_,
936 render_process_id_); 961 render_process_id_);
937 #else 962 #else
938 *result = blink::WebNotificationPresenter::PermissionAllowed; 963 *result = blink::WebNotificationPresenter::PermissionAllowed;
939 #endif 964 #endif
940 } 965 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 Send(reply); 1383 Send(reply);
1359 } 1384 }
1360 1385
1361 void RenderMessageFilter::OnDeletedGpuMemoryBuffer( 1386 void RenderMessageFilter::OnDeletedGpuMemoryBuffer(
1362 gfx::GpuMemoryBufferType type, 1387 gfx::GpuMemoryBufferType type,
1363 const gfx::GpuMemoryBufferId& id) { 1388 const gfx::GpuMemoryBufferId& id) {
1364 GpuMemoryBufferImpl::DeletedByChildProcess(type, id, PeerHandle()); 1389 GpuMemoryBufferImpl::DeletedByChildProcess(type, id, PeerHandle());
1365 } 1390 }
1366 1391
1367 } // namespace content 1392 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698