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.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.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_context.h" |
26 #include "content/public/browser/resource_dispatcher_host.h" | 26 #include "content/public/browser/resource_dispatcher_host.h" |
| 27 #include "content/public/browser/storage_partition.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
29 #include "webkit/plugins/npapi/plugin_group.h" | 30 #include "webkit/plugins/npapi/plugin_group.h" |
30 | 31 |
31 using content::BrowserContext; | 32 using content::BrowserContext; |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 using content::DownloadItem; | 34 using content::DownloadItem; |
34 using content::DownloadManager; | 35 using content::DownloadManager; |
35 using content::ResourceDispatcherHost; | 36 using content::ResourceDispatcherHost; |
36 | 37 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); | 200 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); |
200 content::WebContents* web_contents = tab_contents->web_contents(); | 201 content::WebContents* web_contents = tab_contents->web_contents(); |
201 DownloadManager* download_manager = | 202 DownloadManager* download_manager = |
202 BrowserContext::GetDownloadManager(tab_contents->profile()); | 203 BrowserContext::GetDownloadManager(tab_contents->profile()); |
203 download_util::RecordDownloadSource( | 204 download_util::RecordDownloadSource( |
204 download_util::INITIATED_BY_PLUGIN_INSTALLER); | 205 download_util::INITIATED_BY_PLUGIN_INSTALLER); |
205 BrowserThread::PostTask( | 206 BrowserThread::PostTask( |
206 BrowserThread::IO, FROM_HERE, | 207 BrowserThread::IO, FROM_HERE, |
207 base::Bind(&BeginDownload, | 208 base::Bind(&BeginDownload, |
208 plugin_url_, | 209 plugin_url_, |
209 tab_contents->profile()->GetResourceContext(), | 210 content::BrowserContext::GetDefaultStoragePartition( |
| 211 web_contents->GetBrowserContext())->GetResourceContext(), |
210 web_contents->GetRenderProcessHost()->GetID(), | 212 web_contents->GetRenderProcessHost()->GetID(), |
211 web_contents->GetRenderViewHost()->GetRoutingID(), | 213 web_contents->GetRenderViewHost()->GetRoutingID(), |
212 base::Bind(&PluginInstaller::DownloadStarted, | 214 base::Bind(&PluginInstaller::DownloadStarted, |
213 base::Unretained(this), | 215 base::Unretained(this), |
214 make_scoped_refptr(download_manager)))); | 216 make_scoped_refptr(download_manager)))); |
215 } | 217 } |
216 | 218 |
217 void PluginInstaller::DownloadStarted( | 219 void PluginInstaller::DownloadStarted( |
218 scoped_refptr<content::DownloadManager> dlm, | 220 scoped_refptr<content::DownloadManager> dlm, |
219 content::DownloadId download_id, | 221 content::DownloadId download_id, |
(...skipping 29 matching lines...) Expand all Loading... |
249 | 251 |
250 void PluginInstaller::DownloadCancelled() { | 252 void PluginInstaller::DownloadCancelled() { |
251 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 253 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
252 state_ = INSTALLER_STATE_IDLE; | 254 state_ = INSTALLER_STATE_IDLE; |
253 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); | 255 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); |
254 } | 256 } |
255 | 257 |
256 bool PluginInstaller::MatchesPlugin(const webkit::WebPluginInfo& plugin) { | 258 bool PluginInstaller::MatchesPlugin(const webkit::WebPluginInfo& plugin) { |
257 return plugin.name.find(group_name_matcher_) != string16::npos; | 259 return plugin.name.find(group_name_matcher_) != string16::npos; |
258 } | 260 } |
OLD | NEW |