OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/download/download_item.h" | 5 #include "chrome/browser/download/download_item.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/download/download_history.h" | 21 #include "chrome/browser/download/download_history.h" |
22 #include "chrome/browser/download/download_manager.h" | 22 #include "chrome/browser/download/download_manager.h" |
23 #include "chrome/browser/download/download_prefs.h" | 23 #include "chrome/browser/download/download_prefs.h" |
24 #include "chrome/browser/download/download_state_info.h" | 24 #include "chrome/browser/download/download_state_info.h" |
25 #include "chrome/browser/download/download_util.h" | 25 #include "chrome/browser/download/download_util.h" |
26 #include "chrome/browser/extensions/crx_installer.h" | 26 #include "chrome/browser/extensions/crx_installer.h" |
27 #include "chrome/browser/history/download_history_info.h" | 27 #include "chrome/browser/history/download_history_info.h" |
28 #include "chrome/browser/platform_util.h" | 28 #include "chrome/browser/platform_util.h" |
29 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/common/chrome_notification_types.h" |
31 #include "chrome/common/extensions/extension.h" | 32 #include "chrome/common/extensions/extension.h" |
32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
33 #include "content/browser/browser_thread.h" | 34 #include "content/browser/browser_thread.h" |
34 #include "content/common/notification_source.h" | 35 #include "content/common/notification_source.h" |
35 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
36 | 37 |
37 // A DownloadItem normally goes through the following states: | 38 // A DownloadItem normally goes through the following states: |
38 // * Created (when download starts) | 39 // * Created (when download starts) |
39 // * Made visible to consumers (e.g. Javascript) after the | 40 // * Made visible to consumers (e.g. Javascript) after the |
40 // destination file has been determined. | 41 // destination file has been determined. |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 456 |
456 scoped_refptr<CrxInstaller> crx_installer = | 457 scoped_refptr<CrxInstaller> crx_installer = |
457 download_crx_util::OpenChromeExtension( | 458 download_crx_util::OpenChromeExtension( |
458 download_manager_->profile(), | 459 download_manager_->profile(), |
459 *this); | 460 *this); |
460 | 461 |
461 // CRX_INSTALLER_DONE will fire when the install completes. Observe() | 462 // CRX_INSTALLER_DONE will fire when the install completes. Observe() |
462 // will call Completed() on this item. If this DownloadItem is not | 463 // will call Completed() on this item. If this DownloadItem is not |
463 // around when CRX_INSTALLER_DONE fires, Complete() will not be called. | 464 // around when CRX_INSTALLER_DONE fires, Complete() will not be called. |
464 registrar_.Add(this, | 465 registrar_.Add(this, |
465 NotificationType::CRX_INSTALLER_DONE, | 466 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
466 Source<CrxInstaller>(crx_installer.get())); | 467 Source<CrxInstaller>(crx_installer.get())); |
467 | 468 |
468 // The status text and percent complete indicator will change now | 469 // The status text and percent complete indicator will change now |
469 // that we are installing a CRX. Update observers so that they pick | 470 // that we are installing a CRX. Update observers so that they pick |
470 // up the change. | 471 // up the change. |
471 UpdateObservers(); | 472 UpdateObservers(); |
472 } | 473 } |
473 | 474 |
474 // NotificationObserver implementation. | 475 // NotificationObserver implementation. |
475 void DownloadItem::Observe(NotificationType type, | 476 void DownloadItem::Observe(int type, |
476 const NotificationSource& source, | 477 const NotificationSource& source, |
477 const NotificationDetails& details) { | 478 const NotificationDetails& details) { |
478 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 479 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
479 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 480 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
480 | 481 |
481 DCHECK(type == NotificationType::CRX_INSTALLER_DONE); | 482 DCHECK(type == chrome::NOTIFICATION_CRX_INSTALLER_DONE); |
482 | 483 |
483 // No need to listen for CRX_INSTALLER_DONE anymore. | 484 // No need to listen for CRX_INSTALLER_DONE anymore. |
484 registrar_.Remove(this, | 485 registrar_.Remove(this, |
485 NotificationType::CRX_INSTALLER_DONE, | 486 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
486 source); | 487 source); |
487 | 488 |
488 auto_opened_ = true; | 489 auto_opened_ = true; |
489 DCHECK(all_data_saved_); | 490 DCHECK(all_data_saved_); |
490 | 491 |
491 Completed(); | 492 Completed(); |
492 } | 493 } |
493 | 494 |
494 void DownloadItem::Interrupted(int64 size, int os_error) { | 495 void DownloadItem::Interrupted(int64 size, int os_error) { |
495 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 496 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 state_info_.target_name.value().c_str(), | 837 state_info_.target_name.value().c_str(), |
837 full_path().value().c_str()); | 838 full_path().value().c_str()); |
838 } else { | 839 } else { |
839 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); | 840 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); |
840 } | 841 } |
841 | 842 |
842 description += " }"; | 843 description += " }"; |
843 | 844 |
844 return description; | 845 return description; |
845 } | 846 } |
OLD | NEW |