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/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 14 #include "chrome/browser/extensions/install_tracker.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 |
23 namespace base { | 24 namespace base { |
(...skipping 33 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( |
| 90 InstallTracker::InstallProgressData* install_data) const; |
| 91 |
81 // Called at certain check points of the workflow to decide whether it makes | 92 // 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 | 93 // sense to proceed with installation. A requestor can be a website that |
83 // initiated an inline installation, or a command line option. | 94 // initiated an inline installation, or a command line option. |
84 virtual bool CheckRequestorAlive() const = 0; | 95 virtual bool CheckRequestorAlive() const = 0; |
85 | 96 |
86 // Requestor's URL, if any. Should be an empty GURL if URL is meaningless | 97 // Requestor's URL, if any. Should be an empty GURL if URL is meaningless |
87 // (e.g. for a command line option). | 98 // (e.g. for a command line option). |
88 virtual const GURL& GetRequestorURL() const = 0; | 99 virtual const GURL& GetRequestorURL() const = 0; |
89 | 100 |
90 // Should a new tab be opened after installation to show the newly installed | 101 // Should a new tab be opened after installation to show the newly installed |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 207 |
197 // WebstoreInstaller::Delegate interface implementation. | 208 // WebstoreInstaller::Delegate interface implementation. |
198 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | 209 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
199 virtual void OnExtensionInstallFailure( | 210 virtual void OnExtensionInstallFailure( |
200 const std::string& id, | 211 const std::string& id, |
201 const std::string& error, | 212 const std::string& error, |
202 WebstoreInstaller::FailureReason reason) OVERRIDE; | 213 WebstoreInstaller::FailureReason reason) OVERRIDE; |
203 | 214 |
204 void ShowInstallUI(); | 215 void ShowInstallUI(); |
205 void OnWebStoreDataFetcherDone(); | 216 void OnWebStoreDataFetcherDone(); |
| 217 void DeregisterActiveInstall(); |
206 | 218 |
207 // Input configuration. | 219 // Input configuration. |
208 std::string id_; | 220 std::string id_; |
209 Callback callback_; | 221 Callback callback_; |
210 Profile* profile_; | 222 Profile* profile_; |
211 WebstoreInstaller::InstallSource install_source_; | 223 WebstoreInstaller::InstallSource install_source_; |
212 | 224 |
213 // Installation dialog and its underlying prompt. | 225 // Installation dialog and its underlying prompt. |
214 scoped_ptr<ExtensionInstallPrompt> install_ui_; | 226 scoped_ptr<ExtensionInstallPrompt> install_ui_; |
215 scoped_refptr<ExtensionInstallPrompt::Prompt> install_prompt_; | 227 scoped_refptr<ExtensionInstallPrompt::Prompt> install_prompt_; |
216 | 228 |
217 // For fetching webstore JSON data. | 229 // For fetching webstore JSON data. |
218 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_; | 230 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_; |
219 | 231 |
220 // Extracted from the webstore JSON data response. | 232 // Extracted from the webstore JSON data response. |
221 std::string localized_name_; | 233 std::string localized_name_; |
222 std::string localized_description_; | 234 std::string localized_description_; |
223 bool show_user_count_; | 235 bool show_user_count_; |
224 std::string localized_user_count_; | 236 std::string localized_user_count_; |
225 double average_rating_; | 237 double average_rating_; |
226 int rating_count_; | 238 int rating_count_; |
227 scoped_ptr<base::DictionaryValue> webstore_data_; | 239 scoped_ptr<base::DictionaryValue> webstore_data_; |
228 scoped_ptr<base::DictionaryValue> manifest_; | 240 scoped_ptr<base::DictionaryValue> manifest_; |
229 SkBitmap icon_; | 241 SkBitmap icon_; |
230 | 242 |
| 243 // True if this install was registered with InstallTracker. |
| 244 bool install_registered_; |
| 245 |
231 // Created by ShowInstallUI() when a prompt is shown (if | 246 // Created by ShowInstallUI() when a prompt is shown (if |
232 // the implementor returns a non-NULL in CreateInstallPrompt()). | 247 // the implementor returns a non-NULL in CreateInstallPrompt()). |
233 scoped_refptr<Extension> localized_extension_for_display_; | 248 scoped_refptr<Extension> localized_extension_for_display_; |
234 | 249 |
235 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); | 250 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); |
236 }; | 251 }; |
237 | 252 |
238 } // namespace extensions | 253 } // namespace extensions |
239 | 254 |
240 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ | 255 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ |
OLD | NEW |