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 "chrome/browser/plugin_installer.h" | 5 #include "chrome/browser/plugin_installer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
11 #include "chrome/browser/download/download_service.h" | 11 #include "chrome/browser/download/download_service.h" |
12 #include "chrome/browser/download/download_service_factory.h" | 12 #include "chrome/browser/download/download_service_factory.h" |
13 #include "chrome/browser/download/download_util.h" | 13 #include "chrome/browser/download/download_util.h" |
14 #include "chrome/browser/platform_util.h" | 14 #include "chrome/browser/platform_util.h" |
15 #include "chrome/browser/plugin_installer_observer.h" | 15 #include "chrome/browser/plugin_installer_observer.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/download_id.h" | 19 #include "content/public/browser/download_id.h" |
20 #include "content/public/browser/download_item.h" | 20 #include "content/public/browser/download_item.h" |
21 #include "content/public/browser/download_manager.h" | 21 #include "content/public/browser/download_manager.h" |
22 #include "content/public/browser/download_save_info.h" | 22 #include "content/public/browser/download_save_info.h" |
23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/resource_context.h" |
25 #include "content/public/browser/resource_dispatcher_host.h" | 26 #include "content/public/browser/resource_dispatcher_host.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
28 #include "webkit/plugins/npapi/plugin_group.h" | 29 #include "webkit/plugins/npapi/plugin_group.h" |
29 | 30 |
30 using content::BrowserContext; | 31 using content::BrowserContext; |
31 using content::BrowserThread; | 32 using content::BrowserThread; |
32 using content::DownloadItem; | 33 using content::DownloadItem; |
33 using content::DownloadManager; | 34 using content::DownloadManager; |
34 using content::ResourceDispatcherHost; | 35 using content::ResourceDispatcherHost; |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 void BeginDownload( | 39 void BeginDownload( |
39 const GURL& url, | 40 const GURL& url, |
40 content::ResourceContext* resource_context, | 41 content::ResourceContext* resource_context, |
41 int render_process_host_id, | 42 int render_process_host_id, |
42 int render_view_host_routing_id, | 43 int render_view_host_routing_id, |
43 const ResourceDispatcherHost::DownloadStartedCallback& callback) { | 44 const ResourceDispatcherHost::DownloadStartedCallback& callback) { |
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
45 | 46 |
46 ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get(); | 47 ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get(); |
47 scoped_ptr<net::URLRequest> request(new net::URLRequest(url, NULL)); | 48 scoped_ptr<net::URLRequest> request(new net::URLRequest( |
| 49 url, |
| 50 NULL, |
| 51 resource_context->GetRequestContext())); |
48 net::Error error = rdh->BeginDownload( | 52 net::Error error = rdh->BeginDownload( |
49 request.Pass(), | 53 request.Pass(), |
50 false, // is_content_initiated | 54 false, // is_content_initiated |
51 resource_context, | 55 resource_context, |
52 render_process_host_id, | 56 render_process_host_id, |
53 render_view_host_routing_id, | 57 render_view_host_routing_id, |
54 true, // prefer_cache | 58 true, // prefer_cache |
55 content::DownloadSaveInfo(), | 59 content::DownloadSaveInfo(), |
56 callback); | 60 callback); |
57 | 61 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 245 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
242 state_ = INSTALLER_STATE_IDLE; | 246 state_ = INSTALLER_STATE_IDLE; |
243 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); | 247 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); |
244 } | 248 } |
245 | 249 |
246 void PluginInstaller::DownloadCancelled() { | 250 void PluginInstaller::DownloadCancelled() { |
247 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 251 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
248 state_ = INSTALLER_STATE_IDLE; | 252 state_ = INSTALLER_STATE_IDLE; |
249 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); | 253 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); |
250 } | 254 } |
OLD | NEW |