OLD | NEW |
---|---|
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 OnCreateFullscreenWidget) | 384 OnCreateFullscreenWidget) |
385 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) | 385 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) |
386 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) | 386 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) |
387 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies) | 387 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies) |
388 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) | 388 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) |
389 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled) | 389 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled) |
390 #if defined(OS_MACOSX) | 390 #if defined(OS_MACOSX) |
391 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont) | 391 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont) |
392 #endif | 392 #endif |
393 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) | 393 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) |
394 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveImageFromDataURL, | |
395 OnSaveImageFromDataURL) | |
394 #if defined(ENABLE_PLUGINS) | 396 #if defined(ENABLE_PLUGINS) |
395 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) | 397 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) |
396 IPC_MESSAGE_HANDLER(FrameHostMsg_GetPluginInfo, OnGetPluginInfo) | 398 IPC_MESSAGE_HANDLER(FrameHostMsg_GetPluginInfo, OnGetPluginInfo) |
397 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_OpenChannelToPlugin, | 399 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_OpenChannelToPlugin, |
398 OnOpenChannelToPlugin) | 400 OnOpenChannelToPlugin) |
399 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin, | 401 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin, |
400 OnOpenChannelToPepperPlugin) | 402 OnOpenChannelToPepperPlugin) |
401 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance, | 403 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance, |
402 OnDidCreateOutOfProcessPepperInstance) | 404 OnDidCreateOutOfProcessPepperInstance) |
403 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteOutOfProcessPepperInstance, | 405 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteOutOfProcessPepperInstance, |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
853 media::AudioManagerBase::kDefaultDeviceId); | 855 media::AudioManagerBase::kDefaultDeviceId); |
854 } | 856 } |
855 | 857 |
856 #if defined(OS_WIN) | 858 #if defined(OS_WIN) |
857 void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) { | 859 void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) { |
858 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 860 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
859 *profile = g_color_profile.Get().profile(); | 861 *profile = g_color_profile.Get().profile(); |
860 } | 862 } |
861 #endif | 863 #endif |
862 | 864 |
863 void RenderMessageFilter::OnDownloadUrl(int render_view_id, | 865 void RenderMessageFilter::DownloadUrl(int render_view_id, |
864 const GURL& url, | 866 const GURL& url, |
865 const Referrer& referrer, | 867 const Referrer& referrer, |
866 const base::string16& suggested_name, | 868 const base::string16& suggested_name, |
867 const bool use_prompt) { | 869 const bool use_prompt) { |
868 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); | 870 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); |
869 save_info->suggested_name = suggested_name; | 871 save_info->suggested_name = suggested_name; |
870 save_info->prompt_for_save_location = use_prompt; | 872 save_info->prompt_for_save_location = use_prompt; |
871 | 873 |
872 // There may be a special cookie store that we could use for this download, | 874 // There may be a special cookie store that we could use for this download, |
873 // rather than the default one. Since this feature is generally only used for | 875 // rather than the default one. Since this feature is generally only used for |
874 // proper render views, and not downloads, we do not need to retrieve the | 876 // proper render views, and not downloads, we do not need to retrieve the |
875 // special cookie store here, but just initialize the request to use the | 877 // special cookie store here, but just initialize the request to use the |
876 // default cookie store. | 878 // default cookie store. |
877 // TODO(tburkard): retrieve the appropriate special cookie store, if this | 879 // TODO(tburkard): retrieve the appropriate special cookie store, if this |
878 // is ever to be used for downloads as well. | 880 // is ever to be used for downloads as well. |
879 scoped_ptr<net::URLRequest> request( | 881 scoped_ptr<net::URLRequest> request( |
880 resource_context_->GetRequestContext()->CreateRequest( | 882 resource_context_->GetRequestContext()->CreateRequest( |
881 url, net::DEFAULT_PRIORITY, NULL, NULL)); | 883 url, net::DEFAULT_PRIORITY, NULL, NULL)); |
882 RecordDownloadSource(INITIATED_BY_RENDERER); | 884 RecordDownloadSource(INITIATED_BY_RENDERER); |
883 resource_dispatcher_host_->BeginDownload( | 885 resource_dispatcher_host_->BeginDownload( |
884 request.Pass(), | 886 request.Pass(), |
885 referrer, | 887 referrer, |
886 true, // is_content_initiated | 888 true, // is_content_initiated |
887 resource_context_, | 889 resource_context_, |
888 render_process_id_, | 890 render_process_id_, |
889 render_view_id, | 891 render_view_id, |
890 false, | 892 false, |
891 save_info.Pass(), | 893 save_info.Pass(), |
892 content::DownloadItem::kInvalidId, | 894 content::DownloadItem::kInvalidId, |
893 ResourceDispatcherHostImpl::DownloadStartedCallback()); | 895 ResourceDispatcherHostImpl::DownloadStartedCallback()); |
894 } | 896 } |
895 | 897 |
898 void RenderMessageFilter::OnDownloadUrl(int render_view_id, | |
899 const GURL& url, | |
900 const Referrer& referrer, | |
901 const base::string16& suggested_name) { | |
902 DownloadUrl(render_view_id, url, referrer, suggested_name); | |
903 } | |
904 | |
905 void RenderMessageFilter::OnSaveImageFromDataURL(int render_view_id, | |
906 const std::string& data_url) { | |
907 // Note: |data_url| has a size limitation. (< 10MB) | |
908 // Please refer to RenderViewImpl::saveImageFromDataURL(). | |
909 const int MAX_LENGTH_OF_DATA_URL = 1024 * 1024 * 10; | |
palmer
2014/09/02 17:58:04
This should be a size_t. Note that you are compari
zino
2014/09/03 01:45:58
A stupid mistake. :-P
Done.
| |
910 if (data_url.length() < MAX_LENGTH_OF_DATA_URL) | |
911 DownloadUrl(render_view_id, GURL(data_url), | |
912 Referrer(), base::string16(), true); | |
913 } | |
914 | |
896 void RenderMessageFilter::OnCheckNotificationPermission( | 915 void RenderMessageFilter::OnCheckNotificationPermission( |
897 const GURL& source_origin, int* result) { | 916 const GURL& source_origin, int* result) { |
898 #if defined(ENABLE_NOTIFICATIONS) | 917 #if defined(ENABLE_NOTIFICATIONS) |
899 *result = GetContentClient()->browser()-> | 918 *result = GetContentClient()->browser()-> |
900 CheckDesktopNotificationPermission(source_origin, resource_context_, | 919 CheckDesktopNotificationPermission(source_origin, resource_context_, |
901 render_process_id_); | 920 render_process_id_); |
902 #else | 921 #else |
903 *result = blink::WebNotificationPresenter::PermissionAllowed; | 922 *result = blink::WebNotificationPresenter::PermissionAllowed; |
904 #endif | 923 #endif |
905 } | 924 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 int render_frame_id, | 1239 int render_frame_id, |
1221 const std::string& allowed_destination_host_pattern, | 1240 const std::string& allowed_destination_host_pattern, |
1222 const std::string& selector, | 1241 const std::string& selector, |
1223 const std::string& markup) { | 1242 const std::string& markup) { |
1224 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData( | 1243 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData( |
1225 render_process_id_, render_frame_id, allowed_destination_host_pattern, | 1244 render_process_id_, render_frame_id, allowed_destination_host_pattern, |
1226 selector, markup); | 1245 selector, markup); |
1227 } | 1246 } |
1228 | 1247 |
1229 } // namespace content | 1248 } // namespace content |
OLD | NEW |