| 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 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 WebstoreInstaller, content::BrowserThread::DeleteOnUIThread> { | 37 WebstoreInstaller, content::BrowserThread::DeleteOnUIThread> { |
| 38 public: | 38 public: |
| 39 enum Flag { | 39 enum Flag { |
| 40 FLAG_NONE = 0, | 40 FLAG_NONE = 0, |
| 41 | 41 |
| 42 // Inline installs trigger slightly different behavior (install source | 42 // Inline installs trigger slightly different behavior (install source |
| 43 // is different, download referrers are the item's page in the gallery). | 43 // is different, download referrers are the item's page in the gallery). |
| 44 FLAG_INLINE_INSTALL = 1 << 0 | 44 FLAG_INLINE_INSTALL = 1 << 0 |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 enum FailureReason { |
| 48 FAILURE_REASON_CANCELLED, |
| 49 FAILURE_REASON_OTHER |
| 50 }; |
| 51 |
| 47 class Delegate { | 52 class Delegate { |
| 48 public: | 53 public: |
| 54 virtual void OnExtensionDownloadStarted(const std::string& id, |
| 55 content::DownloadItem* item); |
| 56 virtual void OnExtensionDownloadProgress(const std::string& id, |
| 57 content::DownloadItem* item); |
| 49 virtual void OnExtensionInstallSuccess(const std::string& id) = 0; | 58 virtual void OnExtensionInstallSuccess(const std::string& id) = 0; |
| 50 virtual void OnExtensionInstallFailure(const std::string& id, | 59 virtual void OnExtensionInstallFailure(const std::string& id, |
| 51 const std::string& error) = 0; | 60 const std::string& error, |
| 61 FailureReason reason) = 0; |
| 52 | 62 |
| 53 protected: | 63 protected: |
| 54 virtual ~Delegate() {} | 64 virtual ~Delegate() {} |
| 55 }; | 65 }; |
| 56 | 66 |
| 57 // Contains information about what parts of the extension install process can | 67 // Contains information about what parts of the extension install process can |
| 58 // be skipped or modified. If one of these is present, it means that a CRX | 68 // be skipped or modified. If one of these is present, it means that a CRX |
| 59 // download was initiated by WebstoreInstaller. The Approval instance should | 69 // download was initiated by WebstoreInstaller. The Approval instance should |
| 60 // be checked further for additional details. | 70 // be checked further for additional details. |
| 61 struct Approval : public base::SupportsUserData::Data { | 71 struct Approval : public base::SupportsUserData::Data { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 148 |
| 139 // DownloadItem::Observer implementation: | 149 // DownloadItem::Observer implementation: |
| 140 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 150 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
| 141 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; | 151 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; |
| 142 | 152 |
| 143 // Starts downloading the extension to |file_path|. | 153 // Starts downloading the extension to |file_path|. |
| 144 void StartDownload(const FilePath& file_path); | 154 void StartDownload(const FilePath& file_path); |
| 145 | 155 |
| 146 // Reports an install |error| to the delegate for the given extension if this | 156 // Reports an install |error| to the delegate for the given extension if this |
| 147 // managed its installation. This also removes the associated PendingInstall. | 157 // managed its installation. This also removes the associated PendingInstall. |
| 148 void ReportFailure(const std::string& error); | 158 void ReportFailure(const std::string& error, FailureReason reason); |
| 149 | 159 |
| 150 // Reports a successful install to the delegate for the given extension if | 160 // Reports a successful install to the delegate for the given extension if |
| 151 // this managed its installation. This also removes the associated | 161 // this managed its installation. This also removes the associated |
| 152 // PendingInstall. | 162 // PendingInstall. |
| 153 void ReportSuccess(); | 163 void ReportSuccess(); |
| 154 | 164 |
| 155 content::NotificationRegistrar registrar_; | 165 content::NotificationRegistrar registrar_; |
| 156 Profile* profile_; | 166 Profile* profile_; |
| 157 Delegate* delegate_; | 167 Delegate* delegate_; |
| 158 content::NavigationController* controller_; | 168 content::NavigationController* controller_; |
| 159 std::string id_; | 169 std::string id_; |
| 160 // The DownloadItem is owned by the DownloadManager and is valid from when | 170 // The DownloadItem is owned by the DownloadManager and is valid from when |
| 161 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). | 171 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). |
| 162 content::DownloadItem* download_item_; | 172 content::DownloadItem* download_item_; |
| 163 scoped_ptr<Approval> approval_; | 173 scoped_ptr<Approval> approval_; |
| 164 GURL download_url_; | 174 GURL download_url_; |
| 165 }; | 175 }; |
| 166 | 176 |
| 167 } // namespace extensions | 177 } // namespace extensions |
| 168 | 178 |
| 169 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ | 179 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
| OLD | NEW |