| 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_STANDALONE_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // standalone installs: | 38 // standalone installs: |
| 39 // 1) Downloads and parses metadata from the webstore. | 39 // 1) Downloads and parses metadata from the webstore. |
| 40 // 2) Optionally shows an install dialog. | 40 // 2) Optionally shows an install dialog. |
| 41 // 3) Starts download once the user confirms (if confirmation was requested). | 41 // 3) Starts download once the user confirms (if confirmation was requested). |
| 42 // 4) Optionally shows a post-install UI. | 42 // 4) Optionally shows a post-install UI. |
| 43 // Follows the Template Method pattern. Implementing subclasses must override | 43 // Follows the Template Method pattern. Implementing subclasses must override |
| 44 // the primitive hooks in the corresponding section below. | 44 // the primitive hooks in the corresponding section below. |
| 45 | 45 |
| 46 class WebstoreStandaloneInstaller | 46 class WebstoreStandaloneInstaller |
| 47 : public base::RefCountedThreadSafe<WebstoreStandaloneInstaller>, | 47 : public base::RefCountedThreadSafe<WebstoreStandaloneInstaller>, |
| 48 public ExtensionInstallPrompt::Delegate, | |
| 49 public WebstoreDataFetcherDelegate, | 48 public WebstoreDataFetcherDelegate, |
| 50 public WebstoreInstaller::Delegate, | 49 public WebstoreInstaller::Delegate, |
| 51 public WebstoreInstallHelper::Delegate { | 50 public WebstoreInstallHelper::Delegate { |
| 52 public: | 51 public: |
| 53 // A callback for when the install process completes, successfully or not. If | 52 // A callback for when the install process completes, successfully or not. If |
| 54 // there was a failure, |success| will be false and |error| may contain a | 53 // there was a failure, |success| will be false and |error| may contain a |
| 55 // developer-readable error message about why it failed. | 54 // developer-readable error message about why it failed. |
| 56 typedef base::Callback<void(bool success, | 55 typedef base::Callback<void(bool success, |
| 57 const std::string& error, | 56 const std::string& error, |
| 58 webstore_install::Result result)> Callback; | 57 webstore_install::Result result)> Callback; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // ProceedWithInstallPrompt(). | 144 // ProceedWithInstallPrompt(). |
| 146 virtual void OnManifestParsed(); | 145 virtual void OnManifestParsed(); |
| 147 | 146 |
| 148 // Returns an install UI to be shown. By default, this returns an install UI | 147 // Returns an install UI to be shown. By default, this returns an install UI |
| 149 // that is a transient child of the host window for GetWebContents(). | 148 // that is a transient child of the host window for GetWebContents(). |
| 150 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI(); | 149 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI(); |
| 151 | 150 |
| 152 // Create an approval to pass installation parameters to the CrxInstaller. | 151 // Create an approval to pass installation parameters to the CrxInstaller. |
| 153 virtual scoped_ptr<WebstoreInstaller::Approval> CreateApproval() const; | 152 virtual scoped_ptr<WebstoreInstaller::Approval> CreateApproval() const; |
| 154 | 153 |
| 155 // ExtensionInstallPrompt::Delegate interface implementation. | 154 // Called once the install prompt has finished. |
| 156 void InstallUIProceed() override; | 155 virtual void OnInstallPromptDone(ExtensionInstallPrompt::Result result); |
| 157 void InstallUIAbort(bool user_initiated) override; | |
| 158 | 156 |
| 159 // Accessors to be used by subclasses. | 157 // Accessors to be used by subclasses. |
| 160 bool show_user_count() const { return show_user_count_; } | 158 bool show_user_count() const { return show_user_count_; } |
| 161 const std::string& localized_user_count() const { | 159 const std::string& localized_user_count() const { |
| 162 return localized_user_count_; | 160 return localized_user_count_; |
| 163 } | 161 } |
| 164 double average_rating() const { return average_rating_; } | 162 double average_rating() const { return average_rating_; } |
| 165 int rating_count() const { return rating_count_; } | 163 int rating_count() const { return rating_count_; } |
| 166 void set_install_source(WebstoreInstaller::InstallSource source) { | 164 void set_install_source(WebstoreInstaller::InstallSource source) { |
| 167 install_source_ = source; | 165 install_source_ = source; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // Created by ShowInstallUI() when a prompt is shown (if | 246 // Created by ShowInstallUI() when a prompt is shown (if |
| 249 // the implementor returns a non-NULL in CreateInstallPrompt()). | 247 // the implementor returns a non-NULL in CreateInstallPrompt()). |
| 250 scoped_refptr<Extension> localized_extension_for_display_; | 248 scoped_refptr<Extension> localized_extension_for_display_; |
| 251 | 249 |
| 252 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); | 250 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); |
| 253 }; | 251 }; |
| 254 | 252 |
| 255 } // namespace extensions | 253 } // namespace extensions |
| 256 | 254 |
| 257 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ | 255 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ |
| OLD | NEW |