| Index: chrome/browser/plugins/plugin_installer.cc
|
| diff --git a/chrome/browser/plugins/plugin_installer.cc b/chrome/browser/plugins/plugin_installer.cc
|
| index 6801d13b2454348f41ec0490cc52aeb1ce23ee9f..70fcd974e4de69a5f3d6d1dd67bdb274c46c0bf8 100644
|
| --- a/chrome/browser/plugins/plugin_installer.cc
|
| +++ b/chrome/browser/plugins/plugin_installer.cc
|
| @@ -17,6 +17,8 @@
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/download_item.h"
|
| +#include "content/public/browser/download_manager.h"
|
| +#include "content/public/browser/download_url_parameters.h"
|
| #include "content/public/browser/download_save_info.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/render_view_host.h"
|
| @@ -32,40 +34,6 @@ using content::BrowserThread;
|
| using content::DownloadItem;
|
| using content::ResourceDispatcherHost;
|
|
|
| -namespace {
|
| -
|
| -void BeginDownload(
|
| - const GURL& url,
|
| - content::ResourceContext* resource_context,
|
| - int render_process_host_id,
|
| - int render_view_host_routing_id,
|
| - const ResourceDispatcherHost::DownloadStartedCallback& callback) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| -
|
| - ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
|
| - scoped_ptr<net::URLRequest> request(
|
| - resource_context->GetRequestContext()->CreateRequest(url, NULL));
|
| - net::Error error = rdh->BeginDownload(
|
| - request.Pass(),
|
| - content::Referrer(),
|
| - false, // is_content_initiated
|
| - resource_context,
|
| - render_process_host_id,
|
| - render_view_host_routing_id,
|
| - true, // prefer_cache
|
| - scoped_ptr<content::DownloadSaveInfo>(new content::DownloadSaveInfo()),
|
| - content::DownloadItem::kInvalidId,
|
| - callback);
|
| -
|
| - if (error != net::OK) {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| - base::Bind(callback, static_cast<DownloadItem*>(NULL), error));
|
| - }
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| PluginInstaller::PluginInstaller()
|
| : state_(INSTALLER_STATE_IDLE),
|
| strong_observer_count_(0) {
|
| @@ -92,7 +60,7 @@ void PluginInstaller::OnDownloadUpdated(DownloadItem* download) {
|
| }
|
| case DownloadItem::INTERRUPTED: {
|
| content::DownloadInterruptReason reason = download->GetLastReason();
|
| - DownloadError(content::InterruptReasonDebugString(reason));
|
| + DownloadError(content::DownloadInterruptReasonToString(reason));
|
| break;
|
| }
|
| case DownloadItem::MAX_DOWNLOAD_STATE: {
|
| @@ -137,30 +105,31 @@ void PluginInstaller::StartInstalling(const GURL& plugin_url,
|
| DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
|
| state_ = INSTALLER_STATE_DOWNLOADING;
|
| FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted());
|
| - Profile* profile =
|
| - Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
| RecordDownloadSource(DOWNLOAD_INITIATED_BY_PLUGIN_INSTALLER);
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - base::Bind(&BeginDownload,
|
| - plugin_url,
|
| - profile->GetResourceContext(),
|
| - web_contents->GetRenderProcessHost()->GetID(),
|
| - web_contents->GetRenderViewHost()->GetRoutingID(),
|
| - base::Bind(&PluginInstaller::DownloadStarted,
|
| - base::Unretained(this))));
|
| + scoped_ptr<content::DownloadUrlParameters> download_params(
|
| + content::DownloadUrlParameters::FromWebContents(web_contents,
|
| + plugin_url));
|
| + download_params->set_callback(
|
| + base::Bind(&PluginInstaller::DownloadStarted, base::Unretained(this)));
|
| + content::DownloadManager* download_manager =
|
| + content::BrowserContext::GetDownloadManager(
|
| + web_contents->GetBrowserContext());
|
| + download_manager->DownloadUrl(download_params.Pass());
|
| }
|
|
|
| -void PluginInstaller::DownloadStarted(content::DownloadItem* item,
|
| - net::Error error) {
|
| +void PluginInstaller::DownloadStarted(
|
| + content::DownloadItem* item,
|
| + content::DownloadInterruptReason interrupt_reason) {
|
| if (!item) {
|
| - DCHECK_NE(net::OK, error);
|
| - std::string msg =
|
| - base::StringPrintf("Error %d: %s", error, net::ErrorToString(error));
|
| + DCHECK_NE(content::DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason);
|
| + std::string msg = base::StringPrintf(
|
| + "Error %d: %s",
|
| + interrupt_reason,
|
| + content::DownloadInterruptReasonToString(interrupt_reason).c_str());
|
| DownloadError(msg);
|
| return;
|
| }
|
| - DCHECK_EQ(net::OK, error);
|
| + DCHECK_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason);
|
| item->SetOpenWhenComplete(true);
|
| item->AddObserver(this);
|
| }
|
|
|