| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 result->profile = profile; | 160 result->profile = profile; |
| 161 result->parsed_manifest = parsed_manifest.Pass(); | 161 result->parsed_manifest = parsed_manifest.Pass(); |
| 162 result->skip_install_dialog = true; | 162 result->skip_install_dialog = true; |
| 163 return result.Pass(); | 163 return result.Pass(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 WebstoreInstaller::Approval::~Approval() {} | 166 WebstoreInstaller::Approval::~Approval() {} |
| 167 | 167 |
| 168 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval( | 168 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval( |
| 169 const DownloadItem& download) { | 169 const DownloadItem& download) { |
| 170 return static_cast<const Approval*>(download.GetExternalData(kApprovalKey)); | 170 return static_cast<const Approval*>(download.GetUserData(kApprovalKey)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 WebstoreInstaller::WebstoreInstaller(Profile* profile, | 173 WebstoreInstaller::WebstoreInstaller(Profile* profile, |
| 174 Delegate* delegate, | 174 Delegate* delegate, |
| 175 NavigationController* controller, | 175 NavigationController* controller, |
| 176 const std::string& id, | 176 const std::string& id, |
| 177 scoped_ptr<Approval> approval, | 177 scoped_ptr<Approval> approval, |
| 178 int flags) | 178 int flags) |
| 179 : profile_(profile), | 179 : profile_(profile), |
| 180 delegate_(delegate), | 180 delegate_(delegate), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 | 277 |
| 278 CHECK(id.IsValid()); | 278 CHECK(id.IsValid()); |
| 279 | 279 |
| 280 DownloadManager* download_manager = | 280 DownloadManager* download_manager = |
| 281 BrowserContext::GetDownloadManager(profile_); | 281 BrowserContext::GetDownloadManager(profile_); |
| 282 download_item_ = download_manager->GetActiveDownloadItem(id.local()); | 282 download_item_ = download_manager->GetActiveDownloadItem(id.local()); |
| 283 download_item_->AddObserver(this); | 283 download_item_->AddObserver(this); |
| 284 if (approval_.get()) | 284 if (approval_.get()) |
| 285 download_item_->SetExternalData(kApprovalKey, approval_.release()); | 285 download_item_->SetUserData(kApprovalKey, approval_.release()); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { | 288 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { |
| 289 CHECK_EQ(download_item_, download); | 289 CHECK_EQ(download_item_, download); |
| 290 | 290 |
| 291 switch (download->GetState()) { | 291 switch (download->GetState()) { |
| 292 case DownloadItem::CANCELLED: | 292 case DownloadItem::CANCELLED: |
| 293 ReportFailure(kDownloadCanceledError); | 293 ReportFailure(kDownloadCanceledError); |
| 294 break; | 294 break; |
| 295 case DownloadItem::INTERRUPTED: | 295 case DownloadItem::INTERRUPTED: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 void WebstoreInstaller::ReportSuccess() { | 353 void WebstoreInstaller::ReportSuccess() { |
| 354 if (delegate_) { | 354 if (delegate_) { |
| 355 delegate_->OnExtensionInstallSuccess(id_); | 355 delegate_->OnExtensionInstallSuccess(id_); |
| 356 delegate_ = NULL; | 356 delegate_ = NULL; |
| 357 } | 357 } |
| 358 | 358 |
| 359 Release(); // Balanced in Start(). | 359 Release(); // Balanced in Start(). |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace extensions | 362 } // namespace extensions |
| OLD | NEW |