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

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: 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 13 matching lines...) Expand all
24 #include "content/browser/media/media_internals.h" 24 #include "content/browser/media/media_internals.h"
25 #include "content/browser/plugin_process_host.h" 25 #include "content/browser/plugin_process_host.h"
26 #include "content/browser/renderer_host/pepper/pepper_security_helper.h" 26 #include "content/browser/renderer_host/pepper/pepper_security_helper.h"
27 #include "content/browser/renderer_host/render_process_host_impl.h" 27 #include "content/browser/renderer_host/render_process_host_impl.h"
28 #include "content/browser/renderer_host/render_view_host_delegate.h" 28 #include "content/browser/renderer_host/render_view_host_delegate.h"
29 #include "content/browser/renderer_host/render_widget_helper.h" 29 #include "content/browser/renderer_host/render_widget_helper.h"
30 #include "content/browser/renderer_host/render_widget_resize_helper.h" 30 #include "content/browser/renderer_host/render_widget_resize_helper.h"
31 #include "content/browser/transition_request_manager.h" 31 #include "content/browser/transition_request_manager.h"
32 #include "content/common/child_process_host_impl.h" 32 #include "content/common/child_process_host_impl.h"
33 #include "content/common/child_process_messages.h" 33 #include "content/common/child_process_messages.h"
34 #include "content/common/content_constants_internal.h"
34 #include "content/common/cookie_data.h" 35 #include "content/common/cookie_data.h"
35 #include "content/common/desktop_notification_messages.h" 36 #include "content/common/desktop_notification_messages.h"
36 #include "content/common/frame_messages.h" 37 #include "content/common/frame_messages.h"
37 #include "content/common/host_shared_bitmap_manager.h" 38 #include "content/common/host_shared_bitmap_manager.h"
38 #include "content/common/media/media_param_traits.h" 39 #include "content/common/media/media_param_traits.h"
39 #include "content/common/view_messages.h" 40 #include "content/common/view_messages.h"
40 #include "content/public/browser/browser_child_process_host.h" 41 #include "content/public/browser/browser_child_process_host.h"
41 #include "content/public/browser/browser_context.h" 42 #include "content/public/browser/browser_context.h"
42 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/content_browser_client.h" 44 #include "content/public/browser/content_browser_client.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 OnCreateFullscreenWidget) 390 OnCreateFullscreenWidget)
390 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) 391 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie)
391 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) 392 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies)
392 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies) 393 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies)
393 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) 394 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie)
394 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled) 395 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled)
395 #if defined(OS_MACOSX) 396 #if defined(OS_MACOSX)
396 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont) 397 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont)
397 #endif 398 #endif
398 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) 399 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl)
400 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveImageFromDataURL,
401 OnSaveImageFromDataURL)
399 #if defined(ENABLE_PLUGINS) 402 #if defined(ENABLE_PLUGINS)
400 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) 403 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins)
401 IPC_MESSAGE_HANDLER(FrameHostMsg_GetPluginInfo, OnGetPluginInfo) 404 IPC_MESSAGE_HANDLER(FrameHostMsg_GetPluginInfo, OnGetPluginInfo)
402 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_OpenChannelToPlugin, 405 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_OpenChannelToPlugin,
403 OnOpenChannelToPlugin) 406 OnOpenChannelToPlugin)
404 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin, 407 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin,
405 OnOpenChannelToPepperPlugin) 408 OnOpenChannelToPepperPlugin)
406 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance, 409 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance,
407 OnDidCreateOutOfProcessPepperInstance) 410 OnDidCreateOutOfProcessPepperInstance)
408 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteOutOfProcessPepperInstance, 411 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteOutOfProcessPepperInstance,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 media::AudioManagerBase::kDefaultDeviceId); 861 media::AudioManagerBase::kDefaultDeviceId);
859 } 862 }
860 863
861 #if defined(OS_WIN) 864 #if defined(OS_WIN)
862 void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) { 865 void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) {
863 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); 866 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
864 *profile = g_color_profile.Get().profile(); 867 *profile = g_color_profile.Get().profile();
865 } 868 }
866 #endif 869 #endif
867 870
868 void RenderMessageFilter::OnDownloadUrl(int render_view_id, 871 void RenderMessageFilter::DownloadUrl(int render_view_id,
869 const GURL& url, 872 const GURL& url,
870 const Referrer& referrer, 873 const Referrer& referrer,
871 const base::string16& suggested_name, 874 const base::string16& suggested_name,
872 const bool use_prompt) { 875 const bool use_prompt) {
873 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); 876 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
874 save_info->suggested_name = suggested_name; 877 save_info->suggested_name = suggested_name;
875 save_info->prompt_for_save_location = use_prompt; 878 save_info->prompt_for_save_location = use_prompt;
876 879
877 // There may be a special cookie store that we could use for this download, 880 // There may be a special cookie store that we could use for this download,
878 // rather than the default one. Since this feature is generally only used for 881 // rather than the default one. Since this feature is generally only used for
879 // proper render views, and not downloads, we do not need to retrieve the 882 // proper render views, and not downloads, we do not need to retrieve the
880 // special cookie store here, but just initialize the request to use the 883 // special cookie store here, but just initialize the request to use the
881 // default cookie store. 884 // default cookie store.
882 // TODO(tburkard): retrieve the appropriate special cookie store, if this 885 // TODO(tburkard): retrieve the appropriate special cookie store, if this
883 // is ever to be used for downloads as well. 886 // is ever to be used for downloads as well.
884 scoped_ptr<net::URLRequest> request( 887 scoped_ptr<net::URLRequest> request(
885 resource_context_->GetRequestContext()->CreateRequest( 888 resource_context_->GetRequestContext()->CreateRequest(
886 url, net::DEFAULT_PRIORITY, NULL, NULL)); 889 url, net::DEFAULT_PRIORITY, NULL, NULL));
887 RecordDownloadSource(INITIATED_BY_RENDERER); 890 RecordDownloadSource(INITIATED_BY_RENDERER);
888 resource_dispatcher_host_->BeginDownload( 891 resource_dispatcher_host_->BeginDownload(
889 request.Pass(), 892 request.Pass(),
890 referrer, 893 referrer,
891 true, // is_content_initiated 894 true, // is_content_initiated
892 resource_context_, 895 resource_context_,
893 render_process_id_, 896 render_process_id_,
894 render_view_id, 897 render_view_id,
895 false, 898 false,
896 save_info.Pass(), 899 save_info.Pass(),
897 DownloadItem::kInvalidId, 900 DownloadItem::kInvalidId,
898 ResourceDispatcherHostImpl::DownloadStartedCallback()); 901 ResourceDispatcherHostImpl::DownloadStartedCallback());
899 } 902 }
900 903
904 void RenderMessageFilter::OnDownloadUrl(int render_view_id,
905 const GURL& url,
906 const Referrer& referrer,
907 const base::string16& suggested_name) {
908 DownloadUrl(render_view_id, url, referrer, suggested_name, false);
909 }
910
911 void RenderMessageFilter::OnSaveImageFromDataURL(int render_view_id,
912 const std::string& data_url) {
913 // Please refer to RenderViewImpl::saveImageFromDataURL().
914 if (data_url.length() < kMaxLengthOfDataURLString)
915 DownloadUrl(render_view_id, GURL(data_url),
Ken Russell (switch to Gerrit) 2014/09/11 00:38:53 Please construct the GURL in a separate statement
zino 2014/09/12 09:38:27 Done.
916 Referrer(), base::string16(), true);
917 }
918
901 void RenderMessageFilter::OnCheckNotificationPermission( 919 void RenderMessageFilter::OnCheckNotificationPermission(
902 const GURL& source_origin, int* result) { 920 const GURL& source_origin, int* result) {
903 #if defined(ENABLE_NOTIFICATIONS) 921 #if defined(ENABLE_NOTIFICATIONS)
904 *result = GetContentClient()->browser()-> 922 *result = GetContentClient()->browser()->
905 CheckDesktopNotificationPermission(source_origin, resource_context_, 923 CheckDesktopNotificationPermission(source_origin, resource_context_,
906 render_process_id_); 924 render_process_id_);
907 #else 925 #else
908 *result = blink::WebNotificationPresenter::PermissionAllowed; 926 *result = blink::WebNotificationPresenter::PermissionAllowed;
909 #endif 927 #endif
910 } 928 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 int render_frame_id, 1243 int render_frame_id,
1226 const std::string& allowed_destination_host_pattern, 1244 const std::string& allowed_destination_host_pattern,
1227 const std::string& selector, 1245 const std::string& selector,
1228 const std::string& markup) { 1246 const std::string& markup) {
1229 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData( 1247 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData(
1230 render_process_id_, render_frame_id, allowed_destination_host_pattern, 1248 render_process_id_, render_frame_id, allowed_destination_host_pattern,
1231 selector, markup); 1249 selector, markup);
1232 } 1250 }
1233 1251
1234 } // namespace content 1252 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698