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