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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 typedef base::Callback<void(bool success, | 55 typedef base::Callback<void(bool success, |
56 const std::string& error, | 56 const std::string& error, |
57 webstore_install::Result result)> Callback; | 57 webstore_install::Result result)> Callback; |
58 | 58 |
59 WebstoreStandaloneInstaller(const std::string& webstore_item_id, | 59 WebstoreStandaloneInstaller(const std::string& webstore_item_id, |
60 Profile* profile, | 60 Profile* profile, |
61 const Callback& callback); | 61 const Callback& callback); |
62 void BeginInstall(); | 62 void BeginInstall(); |
63 | 63 |
64 protected: | 64 protected: |
65 virtual ~WebstoreStandaloneInstaller(); | 65 ~WebstoreStandaloneInstaller() override; |
66 | 66 |
67 // Runs the callback; primarily used for running a callback before it is | 67 // Runs the callback; primarily used for running a callback before it is |
68 // cleared in AbortInstall(). | 68 // cleared in AbortInstall(). |
69 void RunCallback( | 69 void RunCallback( |
70 bool success, const std::string& error, webstore_install::Result result); | 70 bool success, const std::string& error, webstore_install::Result result); |
71 | 71 |
72 // Called when the install should be aborted. The callback is cleared. | 72 // Called when the install should be aborted. The callback is cleared. |
73 void AbortInstall(); | 73 void AbortInstall(); |
74 | 74 |
75 // Checks InstallTracker and returns true if the same extension is not | 75 // Checks InstallTracker and returns true if the same extension is not |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 virtual void OnManifestParsed(); | 145 virtual void OnManifestParsed(); |
146 | 146 |
147 // 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 |
148 // that is a transient child of the host window for GetWebContents(). | 148 // that is a transient child of the host window for GetWebContents(). |
149 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI(); | 149 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI(); |
150 | 150 |
151 // Create an approval to pass installation parameters to the CrxInstaller. | 151 // Create an approval to pass installation parameters to the CrxInstaller. |
152 virtual scoped_ptr<WebstoreInstaller::Approval> CreateApproval() const; | 152 virtual scoped_ptr<WebstoreInstaller::Approval> CreateApproval() const; |
153 | 153 |
154 // ExtensionInstallPrompt::Delegate interface implementation. | 154 // ExtensionInstallPrompt::Delegate interface implementation. |
155 virtual void InstallUIProceed() override; | 155 void InstallUIProceed() override; |
156 virtual void InstallUIAbort(bool user_initiated) override; | 156 void InstallUIAbort(bool user_initiated) override; |
157 | 157 |
158 // Accessors to be used by subclasses. | 158 // Accessors to be used by subclasses. |
159 bool show_user_count() const { return show_user_count_; } | 159 bool show_user_count() const { return show_user_count_; } |
160 const std::string& localized_user_count() const { | 160 const std::string& localized_user_count() const { |
161 return localized_user_count_; | 161 return localized_user_count_; |
162 } | 162 } |
163 double average_rating() const { return average_rating_; } | 163 double average_rating() const { return average_rating_; } |
164 int rating_count() const { return rating_count_; } | 164 int rating_count() const { return rating_count_; } |
165 void set_install_source(WebstoreInstaller::InstallSource source) { | 165 void set_install_source(WebstoreInstaller::InstallSource source) { |
166 install_source_ = source; | 166 install_source_ = source; |
(...skipping 19 matching lines...) Expand all Loading... |
186 // 2. OnURLFetchComplete: starts the parsing of data from the webstore | 186 // 2. OnURLFetchComplete: starts the parsing of data from the webstore |
187 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and | 187 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and |
188 // fetching of icon data. | 188 // fetching of icon data. |
189 // 4. OnWebstoreParseSuccess: shows the install UI | 189 // 4. OnWebstoreParseSuccess: shows the install UI |
190 // 5. InstallUIProceed: initiates the .crx download/install | 190 // 5. InstallUIProceed: initiates the .crx download/install |
191 // | 191 // |
192 // All flows (whether successful or not) end up in CompleteInstall, which | 192 // All flows (whether successful or not) end up in CompleteInstall, which |
193 // informs our delegate of success/failure. | 193 // informs our delegate of success/failure. |
194 | 194 |
195 // WebstoreDataFetcherDelegate interface implementation. | 195 // WebstoreDataFetcherDelegate interface implementation. |
196 virtual void OnWebstoreRequestFailure() override; | 196 void OnWebstoreRequestFailure() override; |
197 | 197 |
198 virtual void OnWebstoreResponseParseSuccess( | 198 void OnWebstoreResponseParseSuccess( |
199 scoped_ptr<base::DictionaryValue> webstore_data) override; | 199 scoped_ptr<base::DictionaryValue> webstore_data) override; |
200 | 200 |
201 virtual void OnWebstoreResponseParseFailure( | 201 void OnWebstoreResponseParseFailure(const std::string& error) override; |
202 const std::string& error) override; | |
203 | 202 |
204 // WebstoreInstallHelper::Delegate interface implementation. | 203 // WebstoreInstallHelper::Delegate interface implementation. |
205 virtual void OnWebstoreParseSuccess( | 204 void OnWebstoreParseSuccess(const std::string& id, |
206 const std::string& id, | 205 const SkBitmap& icon, |
207 const SkBitmap& icon, | 206 base::DictionaryValue* parsed_manifest) override; |
208 base::DictionaryValue* parsed_manifest) override; | 207 void OnWebstoreParseFailure(const std::string& id, |
209 virtual void OnWebstoreParseFailure( | 208 InstallHelperResultCode result_code, |
210 const std::string& id, | 209 const std::string& error_message) override; |
211 InstallHelperResultCode result_code, | |
212 const std::string& error_message) override; | |
213 | 210 |
214 // WebstoreInstaller::Delegate interface implementation. | 211 // WebstoreInstaller::Delegate interface implementation. |
215 virtual void OnExtensionInstallSuccess(const std::string& id) override; | 212 void OnExtensionInstallSuccess(const std::string& id) override; |
216 virtual void OnExtensionInstallFailure( | 213 void OnExtensionInstallFailure( |
217 const std::string& id, | 214 const std::string& id, |
218 const std::string& error, | 215 const std::string& error, |
219 WebstoreInstaller::FailureReason reason) override; | 216 WebstoreInstaller::FailureReason reason) override; |
220 | 217 |
221 void ShowInstallUI(); | 218 void ShowInstallUI(); |
222 void OnWebStoreDataFetcherDone(); | 219 void OnWebStoreDataFetcherDone(); |
223 | 220 |
224 // Input configuration. | 221 // Input configuration. |
225 std::string id_; | 222 std::string id_; |
226 Callback callback_; | 223 Callback callback_; |
(...skipping 24 matching lines...) Expand all Loading... |
251 // Created by ShowInstallUI() when a prompt is shown (if | 248 // Created by ShowInstallUI() when a prompt is shown (if |
252 // the implementor returns a non-NULL in CreateInstallPrompt()). | 249 // the implementor returns a non-NULL in CreateInstallPrompt()). |
253 scoped_refptr<Extension> localized_extension_for_display_; | 250 scoped_refptr<Extension> localized_extension_for_display_; |
254 | 251 |
255 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); | 252 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); |
256 }; | 253 }; |
257 | 254 |
258 } // namespace extensions | 255 } // namespace extensions |
259 | 256 |
260 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ | 257 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ |
OLD | NEW |