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/extensions/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 !controller_->GetWebContents() || | 338 !controller_->GetWebContents() || |
339 !controller_->GetWebContents()->GetRenderProcessHost() || | 339 !controller_->GetWebContents()->GetRenderProcessHost() || |
340 !controller_->GetWebContents()->GetRenderViewHost() || | 340 !controller_->GetWebContents()->GetRenderViewHost() || |
341 !controller_->GetWebContents()->GetBrowserContext() || | 341 !controller_->GetWebContents()->GetBrowserContext() || |
342 !controller_->GetWebContents()->GetBrowserContext() | 342 !controller_->GetWebContents()->GetBrowserContext() |
343 ->GetResourceContext()) { | 343 ->GetResourceContext()) { |
344 ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER); | 344 ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER); |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 content::DownloadSaveInfo save_info; | 348 scoped_ptr<content::DownloadSaveInfo> save_info( |
349 save_info.file_path = file; | 349 new content::DownloadSaveInfo()); |
| 350 save_info->file_path = file; |
350 | 351 |
351 // The download url for the given extension is contained in |download_url_|. | 352 // The download url for the given extension is contained in |download_url_|. |
352 // We will navigate the current tab to this url to start the download. The | 353 // We will navigate the current tab to this url to start the download. The |
353 // download system will then pass the crx to the CrxInstaller. | 354 // download system will then pass the crx to the CrxInstaller. |
354 download_util::RecordDownloadSource( | 355 download_util::RecordDownloadSource( |
355 download_util::INITIATED_BY_WEBSTORE_INSTALLER); | 356 download_util::INITIATED_BY_WEBSTORE_INSTALLER); |
356 scoped_ptr<DownloadUrlParameters> params( | 357 scoped_ptr<DownloadUrlParameters> params( |
357 DownloadUrlParameters::FromWebContents( | 358 DownloadUrlParameters::FromWebContents( |
358 controller_->GetWebContents(), download_url_, save_info)); | 359 controller_->GetWebContents(), download_url_, save_info.Pass())); |
359 if (controller_->GetActiveEntry()) | 360 if (controller_->GetActiveEntry()) |
360 params->set_referrer( | 361 params->set_referrer( |
361 content::Referrer(controller_->GetActiveEntry()->GetURL(), | 362 content::Referrer(controller_->GetActiveEntry()->GetURL(), |
362 WebKit::WebReferrerPolicyDefault)); | 363 WebKit::WebReferrerPolicyDefault)); |
363 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this)); | 364 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this)); |
364 download_manager->DownloadUrl(params.Pass()); | 365 download_manager->DownloadUrl(params.Pass()); |
365 } | 366 } |
366 | 367 |
367 void WebstoreInstaller::ReportFailure(const std::string& error, | 368 void WebstoreInstaller::ReportFailure(const std::string& error, |
368 FailureReason reason) { | 369 FailureReason reason) { |
369 if (delegate_) { | 370 if (delegate_) { |
370 delegate_->OnExtensionInstallFailure(id_, error, reason); | 371 delegate_->OnExtensionInstallFailure(id_, error, reason); |
371 delegate_ = NULL; | 372 delegate_ = NULL; |
372 } | 373 } |
373 | 374 |
374 Release(); // Balanced in Start(). | 375 Release(); // Balanced in Start(). |
375 } | 376 } |
376 | 377 |
377 void WebstoreInstaller::ReportSuccess() { | 378 void WebstoreInstaller::ReportSuccess() { |
378 if (delegate_) { | 379 if (delegate_) { |
379 delegate_->OnExtensionInstallSuccess(id_); | 380 delegate_->OnExtensionInstallSuccess(id_); |
380 delegate_ = NULL; | 381 delegate_ = NULL; |
381 } | 382 } |
382 | 383 |
383 Release(); // Balanced in Start(). | 384 Release(); // Balanced in Start(). |
384 } | 385 } |
385 | 386 |
386 } // namespace extensions | 387 } // namespace extensions |
OLD | NEW |