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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 return; | 276 return; |
277 } | 277 } |
278 | 278 |
279 CHECK(id.IsValid()); | 279 CHECK(id.IsValid()); |
280 | 280 |
281 DownloadManager* download_manager = | 281 DownloadManager* download_manager = |
282 BrowserContext::GetDownloadManager(profile_); | 282 BrowserContext::GetDownloadManager(profile_); |
283 download_item_ = download_manager->GetActiveDownloadItem(id.local()); | 283 download_item_ = download_manager->GetActiveDownloadItem(id.local()); |
284 download_item_->AddObserver(this); | 284 download_item_->AddObserver(this); |
285 if (approval_.get()) | 285 if (approval_.get()) |
286 download_item_->SetExternalData(kApprovalKey, approval_.release()); | 286 download_item_->SetUserData(kApprovalKey, approval_.release()); |
287 } | 287 } |
288 | 288 |
289 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { | 289 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { |
290 CHECK_EQ(download_item_, download); | 290 CHECK_EQ(download_item_, download); |
291 | 291 |
292 switch (download->GetState()) { | 292 switch (download->GetState()) { |
293 case DownloadItem::CANCELLED: | 293 case DownloadItem::CANCELLED: |
294 ReportFailure(kDownloadCanceledError); | 294 ReportFailure(kDownloadCanceledError); |
295 break; | 295 break; |
296 case DownloadItem::INTERRUPTED: | 296 case DownloadItem::INTERRUPTED: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 void WebstoreInstaller::ReportSuccess() { | 354 void WebstoreInstaller::ReportSuccess() { |
355 if (delegate_) { | 355 if (delegate_) { |
356 delegate_->OnExtensionInstallSuccess(id_); | 356 delegate_->OnExtensionInstallSuccess(id_); |
357 delegate_ = NULL; | 357 delegate_ = NULL; |
358 } | 358 } |
359 | 359 |
360 Release(); // Balanced in Start(). | 360 Release(); // Balanced in Start(). |
361 } | 361 } |
362 | 362 |
363 } // namespace extensions | 363 } // namespace extensions |
OLD | NEW |