Chromium Code Reviews| 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_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/active_install_data.h" | 10 #include "chrome/browser/extensions/active_install_data.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 // ExtensionFunction: | 151 // ExtensionFunction: |
| 152 bool RunAsync() override; | 152 bool RunAsync() override; |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 scoped_ptr<WebstoreInstaller::Approval> approval_; | 155 scoped_ptr<WebstoreInstaller::Approval> approval_; |
| 156 scoped_ptr<ScopedActiveInstall> scoped_active_install_; | 156 scoped_ptr<ScopedActiveInstall> scoped_active_install_; |
| 157 | 157 |
| 158 void OnInstallSuccess(const std::string& id); | 158 void OnInstallSuccess(const std::string& id); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 class WebstorePrivateShowPermissionPromptForDelegatedInstallFunction | |
| 162 : public ChromeAsyncExtensionFunction, | |
| 163 public ExtensionInstallPrompt::Delegate, | |
| 164 public WebstoreInstallHelper::Delegate { | |
| 165 public: | |
| 166 DECLARE_EXTENSION_FUNCTION( | |
| 167 "webstorePrivate.showPermissionPromptForDelegatedInstall", | |
| 168 WEBSTOREPRIVATE_SHOWPERMISSIONPROMPTFORDELEGATEDINSTALL) | |
| 169 | |
| 170 // Result codes for the return value. If you change this, make sure to | |
| 171 // update the description for the showPermissionPromptForDelegatedInstall | |
| 172 // callback in the extension API JSON. | |
| 173 enum ResultCode { | |
| 174 ERROR_NONE = 0, | |
|
not at google - send to devlin
2015/02/04 21:28:29
We should just formalise this as an enum in the sc
Marc Treib
2015/02/05 10:33:37
Okay, that makes sense. I'll do that in a separate
| |
| 175 | |
| 176 // An unspecified error occurred. | |
| 177 UNKNOWN_ERROR, | |
| 178 | |
| 179 // The user cancelled the confirmation dialog instead of accepting it. | |
| 180 USER_CANCELLED, | |
| 181 | |
| 182 // The manifest failed to parse correctly. | |
| 183 MANIFEST_ERROR, | |
| 184 | |
| 185 // There was a problem parsing the base64 encoded icon data. | |
| 186 ICON_ERROR, | |
| 187 | |
| 188 // The extension id was invalid. | |
| 189 INVALID_ID, | |
| 190 | |
| 191 // Invalid icon url. | |
| 192 INVALID_ICON_URL, | |
| 193 }; | |
| 194 | |
| 195 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction(); | |
| 196 | |
| 197 // WebstoreInstallHelper::Delegate: | |
|
not at google - send to devlin
2015/02/04 21:28:29
All these delegate methods can be private, right?
Marc Treib
2015/02/05 10:33:37
Indeed they can; I just mimicked what all the othe
| |
| 198 void OnWebstoreParseSuccess(const std::string& id, | |
| 199 const SkBitmap& icon, | |
| 200 base::DictionaryValue* parsed_manifest) override; | |
| 201 void OnWebstoreParseFailure(const std::string& id, | |
| 202 InstallHelperResultCode result_code, | |
| 203 const std::string& error_message) override; | |
| 204 | |
| 205 // ExtensionInstallPrompt::Delegate: | |
| 206 void InstallUIProceed() override; | |
| 207 void InstallUIAbort(bool user_initiated) override; | |
| 208 | |
| 209 protected: | |
| 210 ~WebstorePrivateShowPermissionPromptForDelegatedInstallFunction() override; | |
| 211 | |
| 212 // ExtensionFunction: | |
| 213 bool RunAsync() override; | |
|
not at google - send to devlin
2015/02/04 21:28:29
Override Run() not RunAsync().
This will also let
Marc Treib
2015/02/05 10:33:37
This also applies to all the other WebstorePrivate
| |
| 214 | |
| 215 // Sets the result_ as a string based on |code|. | |
| 216 void SetResultCode(ResultCode code); | |
| 217 | |
| 218 private: | |
| 219 const char* ResultCodeToString(ResultCode code); | |
| 220 | |
| 221 // These store the input parameters to the function. | |
| 222 scoped_ptr<api::webstore_private::ShowPermissionPromptForDelegatedInstall:: | |
| 223 Params> params_; | |
| 224 | |
| 225 // The results of parsing manifest_ and icon_data_ go into these two. | |
| 226 scoped_ptr<base::DictionaryValue> parsed_manifest_; | |
| 227 SkBitmap icon_; | |
| 228 | |
| 229 // A dummy Extension object we create for the purposes of using | |
| 230 // ExtensionInstallPrompt to prompt for confirmation of the install. | |
| 231 scoped_refptr<extensions::Extension> dummy_extension_; | |
|
not at google - send to devlin
2015/02/04 21:28:29
This file is already in the extensions:: namespace
Marc Treib
2015/02/05 10:33:37
Done.
| |
| 232 | |
| 233 // The class that displays the install prompt. | |
| 234 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | |
| 235 }; | |
| 236 | |
| 161 class WebstorePrivateEnableAppLauncherFunction | 237 class WebstorePrivateEnableAppLauncherFunction |
| 162 : public ChromeSyncExtensionFunction { | 238 : public ChromeSyncExtensionFunction { |
| 163 public: | 239 public: |
| 164 DECLARE_EXTENSION_FUNCTION("webstorePrivate.enableAppLauncher", | 240 DECLARE_EXTENSION_FUNCTION("webstorePrivate.enableAppLauncher", |
| 165 WEBSTOREPRIVATE_ENABLEAPPLAUNCHER) | 241 WEBSTOREPRIVATE_ENABLEAPPLAUNCHER) |
| 166 | 242 |
| 167 WebstorePrivateEnableAppLauncherFunction(); | 243 WebstorePrivateEnableAppLauncherFunction(); |
| 168 | 244 |
| 169 protected: | 245 protected: |
| 170 ~WebstorePrivateEnableAppLauncherFunction() override; | 246 ~WebstorePrivateEnableAppLauncherFunction() override; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 protected: | 376 protected: |
| 301 ~WebstorePrivateGetEphemeralAppsEnabledFunction() override; | 377 ~WebstorePrivateGetEphemeralAppsEnabledFunction() override; |
| 302 | 378 |
| 303 // ExtensionFunction: | 379 // ExtensionFunction: |
| 304 bool RunSync() override; | 380 bool RunSync() override; |
| 305 }; | 381 }; |
| 306 | 382 |
| 307 } // namespace extensions | 383 } // namespace extensions |
| 308 | 384 |
| 309 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H _ | 385 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H _ |
| OLD | NEW |