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 22 matching lines...) Expand all Loading... |
33 #include "content/common/child_process_messages.h" | 33 #include "content/common/child_process_messages.h" |
34 #include "content/common/cookie_data.h" | 34 #include "content/common/cookie_data.h" |
35 #include "content/common/desktop_notification_messages.h" | 35 #include "content/common/desktop_notification_messages.h" |
36 #include "content/common/media/media_param_traits.h" | 36 #include "content/common/media/media_param_traits.h" |
37 #include "content/common/view_messages.h" | 37 #include "content/common/view_messages.h" |
38 #include "content/public/browser/browser_child_process_host.h" | 38 #include "content/public/browser/browser_child_process_host.h" |
39 #include "content/public/browser/browser_context.h" | 39 #include "content/public/browser/browser_context.h" |
40 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
41 #include "content/public/browser/content_browser_client.h" | 41 #include "content/public/browser/content_browser_client.h" |
42 #include "content/public/browser/download_save_info.h" | 42 #include "content/public/browser/download_save_info.h" |
| 43 #include "content/public/browser/download_url_parameters.h" |
43 #include "content/public/browser/plugin_service_filter.h" | 44 #include "content/public/browser/plugin_service_filter.h" |
44 #include "content/public/browser/resource_context.h" | 45 #include "content/public/browser/resource_context.h" |
45 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
46 #include "content/public/common/content_constants.h" | 47 #include "content/public/common/content_constants.h" |
47 #include "content/public/common/content_switches.h" | 48 #include "content/public/common/content_switches.h" |
48 #include "content/public/common/context_menu_params.h" | 49 #include "content/public/common/context_menu_params.h" |
49 #include "content/public/common/url_constants.h" | 50 #include "content/public/common/url_constants.h" |
50 #include "content/public/common/webplugininfo.h" | 51 #include "content/public/common/webplugininfo.h" |
51 #include "ipc/ipc_channel_handle.h" | 52 #include "ipc/ipc_channel_handle.h" |
52 #include "ipc/ipc_platform_file.h" | 53 #include "ipc/ipc_platform_file.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 196 |
196 virtual bool OffTheRecord() OVERRIDE { | 197 virtual bool OffTheRecord() OVERRIDE { |
197 return filter_->OffTheRecord(); | 198 return filter_->OffTheRecord(); |
198 } | 199 } |
199 | 200 |
200 private: | 201 private: |
201 scoped_refptr<RenderMessageFilter> filter_; | 202 scoped_refptr<RenderMessageFilter> filter_; |
202 int routing_id_; | 203 int routing_id_; |
203 }; | 204 }; |
204 | 205 |
| 206 // Run on the UI thread to initiate a download. |
| 207 void BeginDownloadOnUIThread(int render_process_id, |
| 208 int routing_id, |
| 209 const GURL& url, |
| 210 const content::Referrer& referrer, |
| 211 const string16& suggested_name, |
| 212 ResourceContext* resource_context) { |
| 213 RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id); |
| 214 DownloadManager* download_manager = |
| 215 BrowserContext::GetDownloadManager(rph->GetBrowserContext()); |
| 216 scoped_ptr<DownloadUrlParameters> download_params(new DownloadUrlParameters( |
| 217 url, render_process_id, routing_id, resource_context)); |
| 218 download_params->set_suggested_name(suggested_name); |
| 219 download_params->set_referrer(referrer); |
| 220 download_params->set_content_initiated(true); |
| 221 download_manager->DownloadUrl(download_params.Pass()); |
| 222 } |
| 223 |
205 } // namespace | 224 } // namespace |
206 | 225 |
207 class RenderMessageFilter::OpenChannelToNpapiPluginCallback | 226 class RenderMessageFilter::OpenChannelToNpapiPluginCallback |
208 : public RenderMessageCompletionCallback, | 227 : public RenderMessageCompletionCallback, |
209 public PluginProcessHost::Client { | 228 public PluginProcessHost::Client { |
210 public: | 229 public: |
211 OpenChannelToNpapiPluginCallback(RenderMessageFilter* filter, | 230 OpenChannelToNpapiPluginCallback(RenderMessageFilter* filter, |
212 ResourceContext* context, | 231 ResourceContext* context, |
213 IPC::Message* reply_msg) | 232 IPC::Message* reply_msg) |
214 : RenderMessageCompletionCallback(filter, reply_msg), | 233 : RenderMessageCompletionCallback(filter, reply_msg), |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 if (BackingStoreWin::ColorManagementEnabled()) | 843 if (BackingStoreWin::ColorManagementEnabled()) |
825 return; | 844 return; |
826 #endif | 845 #endif |
827 *profile = g_color_profile.Get().profile(); | 846 *profile = g_color_profile.Get().profile(); |
828 } | 847 } |
829 | 848 |
830 void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message, | 849 void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message, |
831 const GURL& url, | 850 const GURL& url, |
832 const Referrer& referrer, | 851 const Referrer& referrer, |
833 const string16& suggested_name) { | 852 const string16& suggested_name) { |
834 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); | 853 BrowserThread::PostTask(BrowserThread::UI, |
835 save_info->suggested_name = suggested_name; | 854 FROM_HERE, |
836 scoped_ptr<net::URLRequest> request( | 855 base::Bind(&BeginDownloadOnUIThread, |
837 resource_context_->GetRequestContext()->CreateRequest(url, NULL)); | 856 render_process_id_, |
838 RecordDownloadSource(INITIATED_BY_RENDERER); | 857 message.routing_id(), |
839 resource_dispatcher_host_->BeginDownload( | 858 url, |
840 request.Pass(), | 859 referrer, |
841 referrer, | 860 suggested_name, |
842 true, // is_content_initiated | 861 resource_context_)); |
843 resource_context_, | |
844 render_process_id_, | |
845 message.routing_id(), | |
846 false, | |
847 save_info.Pass(), | |
848 content::DownloadItem::kInvalidId, | |
849 ResourceDispatcherHostImpl::DownloadStartedCallback()); | |
850 } | 862 } |
851 | 863 |
852 void RenderMessageFilter::OnCheckNotificationPermission( | 864 void RenderMessageFilter::OnCheckNotificationPermission( |
853 const GURL& source_origin, int* result) { | 865 const GURL& source_origin, int* result) { |
854 #if defined(ENABLE_NOTIFICATIONS) | 866 #if defined(ENABLE_NOTIFICATIONS) |
855 *result = GetContentClient()->browser()-> | 867 *result = GetContentClient()->browser()-> |
856 CheckDesktopNotificationPermission(source_origin, resource_context_, | 868 CheckDesktopNotificationPermission(source_origin, resource_context_, |
857 render_process_id_); | 869 render_process_id_); |
858 #else | 870 #else |
859 *result = WebKit::WebNotificationPresenter::PermissionAllowed; | 871 *result = WebKit::WebNotificationPresenter::PermissionAllowed; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 // MediaCodec bridge is slow and can block while sending the data to | 1174 // MediaCodec bridge is slow and can block while sending the data to |
1163 // the renderer. | 1175 // the renderer. |
1164 base::WorkerPool::PostTask( | 1176 base::WorkerPool::PostTask( |
1165 FROM_HERE, | 1177 FROM_HERE, |
1166 base::Bind(&media::WebAudioMediaCodecBridge::RunWebAudioMediaCodec, | 1178 base::Bind(&media::WebAudioMediaCodecBridge::RunWebAudioMediaCodec, |
1167 encoded_data_handle, pcm_output, data_size), | 1179 encoded_data_handle, pcm_output, data_size), |
1168 true); | 1180 true); |
1169 } | 1181 } |
1170 #endif | 1182 #endif |
1171 } // namespace content | 1183 } // namespace content |
OLD | NEW |