| 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/extensions/active_install_data.h" |
| 13 #include "chrome/browser/extensions/extension_install_prompt.h" | 14 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 14 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" | 15 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" |
| 15 #include "chrome/browser/extensions/webstore_install_helper.h" | 16 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 16 #include "chrome/browser/extensions/webstore_install_result.h" | 17 #include "chrome/browser/extensions/webstore_install_result.h" |
| 17 #include "chrome/browser/extensions/webstore_installer.h" | 18 #include "chrome/browser/extensions/webstore_installer.h" |
| 18 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 21 |
| 21 class GURL; | 22 class GURL; |
| 22 | 23 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 Profile* profile, | 58 Profile* profile, |
| 58 const Callback& callback); | 59 const Callback& callback); |
| 59 void BeginInstall(); | 60 void BeginInstall(); |
| 60 | 61 |
| 61 protected: | 62 protected: |
| 62 virtual ~WebstoreStandaloneInstaller(); | 63 virtual ~WebstoreStandaloneInstaller(); |
| 63 | 64 |
| 64 // Called when the install should be aborted. The callback is cleared. | 65 // Called when the install should be aborted. The callback is cleared. |
| 65 void AbortInstall(); | 66 void AbortInstall(); |
| 66 | 67 |
| 68 // Checks InstallTracker and returns true if the same extension is not |
| 69 // currently being installed. Registers this install with the InstallTracker. |
| 70 bool EnsureUniqueInstall(webstore_install::Result* reason, |
| 71 std::string* error); |
| 72 |
| 67 // Called when the install is complete. | 73 // Called when the install is complete. |
| 68 virtual void CompleteInstall(webstore_install::Result result, | 74 virtual void CompleteInstall(webstore_install::Result result, |
| 69 const std::string& error); | 75 const std::string& error); |
| 70 | 76 |
| 71 // Called when the installer should proceed to prompt the user. | 77 // Called when the installer should proceed to prompt the user. |
| 72 void ProceedWithInstallPrompt(); | 78 void ProceedWithInstallPrompt(); |
| 73 | 79 |
| 74 // Lazily creates a dummy extension for display from the parsed manifest. This | 80 // Lazily creates a dummy extension for display from the parsed manifest. This |
| 75 // is safe to call from OnManifestParsed() onwards. The manifest may be | 81 // is safe to call from OnManifestParsed() onwards. The manifest may be |
| 76 // invalid, thus the caller must check that the return value is not NULL. | 82 // invalid, thus the caller must check that the return value is not NULL. |
| 77 scoped_refptr<const Extension> GetLocalizedExtensionForDisplay(); | 83 scoped_refptr<const Extension> GetLocalizedExtensionForDisplay(); |
| 78 | 84 |
| 79 // Template Method's hooks to be implemented by subclasses. | 85 // Template Method's hooks to be implemented by subclasses. |
| 80 | 86 |
| 87 // Called when this install is about to be registered with the InstallTracker. |
| 88 // Allows subclasses to set properties of the install data. |
| 89 virtual void InitInstallData(ActiveInstallData* install_data) const; |
| 90 |
| 81 // Called at certain check points of the workflow to decide whether it makes | 91 // Called at certain check points of the workflow to decide whether it makes |
| 82 // sense to proceed with installation. A requestor can be a website that | 92 // sense to proceed with installation. A requestor can be a website that |
| 83 // initiated an inline installation, or a command line option. | 93 // initiated an inline installation, or a command line option. |
| 84 virtual bool CheckRequestorAlive() const = 0; | 94 virtual bool CheckRequestorAlive() const = 0; |
| 85 | 95 |
| 86 // Requestor's URL, if any. Should be an empty GURL if URL is meaningless | 96 // Requestor's URL, if any. Should be an empty GURL if URL is meaningless |
| 87 // (e.g. for a command line option). | 97 // (e.g. for a command line option). |
| 88 virtual const GURL& GetRequestorURL() const = 0; | 98 virtual const GURL& GetRequestorURL() const = 0; |
| 89 | 99 |
| 90 // Should a new tab be opened after installation to show the newly installed | 100 // Should a new tab be opened after installation to show the newly installed |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 std::string localized_name_; | 231 std::string localized_name_; |
| 222 std::string localized_description_; | 232 std::string localized_description_; |
| 223 bool show_user_count_; | 233 bool show_user_count_; |
| 224 std::string localized_user_count_; | 234 std::string localized_user_count_; |
| 225 double average_rating_; | 235 double average_rating_; |
| 226 int rating_count_; | 236 int rating_count_; |
| 227 scoped_ptr<base::DictionaryValue> webstore_data_; | 237 scoped_ptr<base::DictionaryValue> webstore_data_; |
| 228 scoped_ptr<base::DictionaryValue> manifest_; | 238 scoped_ptr<base::DictionaryValue> manifest_; |
| 229 SkBitmap icon_; | 239 SkBitmap icon_; |
| 230 | 240 |
| 241 // Active install registered with the InstallTracker. |
| 242 scoped_ptr<ScopedActiveInstall> scoped_active_install_; |
| 243 |
| 231 // Created by ShowInstallUI() when a prompt is shown (if | 244 // Created by ShowInstallUI() when a prompt is shown (if |
| 232 // the implementor returns a non-NULL in CreateInstallPrompt()). | 245 // the implementor returns a non-NULL in CreateInstallPrompt()). |
| 233 scoped_refptr<Extension> localized_extension_for_display_; | 246 scoped_refptr<Extension> localized_extension_for_display_; |
| 234 | 247 |
| 235 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); | 248 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); |
| 236 }; | 249 }; |
| 237 | 250 |
| 238 } // namespace extensions | 251 } // namespace extensions |
| 239 | 252 |
| 240 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ | 253 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ |
| OLD | NEW |