Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DASHBOARD_PRIVATE_DASHBOARD_PRIVATE_API_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DASHBOARD_PRIVATE_DASHBOARD_PRIVATE_API_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" | |
| 12 #include "chrome/browser/extensions/bundle_installer.h" | |
| 13 #include "chrome/browser/extensions/chrome_extension_function_details.h" | |
| 14 #include "chrome/browser/extensions/extension_install_prompt.h" | |
| 15 #include "chrome/browser/extensions/webstore_install_helper.h" | |
| 16 #include "chrome/common/extensions/api/dashboard_private.h" | |
| 17 #include "extensions/browser/extension_function.h" | |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | |
| 19 | |
| 20 class GURL; | |
| 21 | |
| 22 namespace chrome { | |
| 23 class BitmapFetcher; | |
| 24 } // namespace chrome | |
| 25 | |
| 26 namespace extensions { | |
| 27 | |
| 28 class Extension; | |
| 29 | |
| 30 class DashboardPrivateShowPermissionPromptForDelegatedInstallFunction | |
| 31 : public UIThreadExtensionFunction, | |
| 32 public ExtensionInstallPrompt::Delegate, | |
| 33 public WebstoreInstallHelper::Delegate { | |
| 34 public: | |
| 35 DECLARE_EXTENSION_FUNCTION( | |
| 36 "dashboardPrivate.showPermissionPromptForDelegatedInstall", | |
| 37 DASHBOARDPRIVATE_SHOWPERMISSIONPROMPTFORDELEGATEDINSTALL) | |
| 38 | |
| 39 using Params = | |
|
not at google - send to devlin
2015/07/31 14:42:20
Does it make sense to have this in the private: se
Marc Treib
2015/07/31 15:28:42
Yup, it does :)
Done.
| |
| 40 api::dashboard_private::ShowPermissionPromptForDelegatedInstall::Params; | |
| 41 | |
| 42 DashboardPrivateShowPermissionPromptForDelegatedInstallFunction(); | |
| 43 | |
| 44 private: | |
| 45 ~DashboardPrivateShowPermissionPromptForDelegatedInstallFunction() override; | |
| 46 | |
| 47 // ExtensionFunction: | |
| 48 ExtensionFunction::ResponseAction Run() override; | |
| 49 | |
| 50 // WebstoreInstallHelper::Delegate: | |
| 51 void OnWebstoreParseSuccess(const std::string& id, | |
| 52 const SkBitmap& icon, | |
| 53 base::DictionaryValue* parsed_manifest) override; | |
| 54 void OnWebstoreParseFailure(const std::string& id, | |
| 55 InstallHelperResultCode result, | |
| 56 const std::string& error_message) override; | |
| 57 | |
| 58 // ExtensionInstallPrompt::Delegate: | |
| 59 void InstallUIProceed() override; | |
| 60 void InstallUIAbort(bool user_initiated) override; | |
| 61 | |
| 62 ExtensionFunction::ResponseValue BuildResponse( | |
| 63 api::dashboard_private::Result result, | |
| 64 const std::string& error); | |
| 65 scoped_ptr<base::ListValue> CreateResults( | |
| 66 api::dashboard_private::Result result) const; | |
| 67 | |
| 68 const Params::Details& details() const { return params_->details; } | |
| 69 | |
| 70 scoped_ptr<Params> params_; | |
| 71 | |
| 72 // A dummy Extension object we create for the purposes of using | |
| 73 // ExtensionInstallPrompt to prompt for confirmation of the install. | |
| 74 scoped_refptr<Extension> dummy_extension_; | |
| 75 | |
| 76 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | |
| 77 }; | |
| 78 | |
| 79 class DashboardPrivateShowPermissionPromptForDelegatedBundleInstallFunction | |
| 80 : public UIThreadExtensionFunction, | |
| 81 public chrome::BitmapFetcherDelegate { | |
| 82 public: | |
| 83 DECLARE_EXTENSION_FUNCTION( | |
| 84 "dashboardPrivate.showPermissionPromptForDelegatedBundleInstall", | |
| 85 DASHBOARDPRIVATE_SHOWPERMISSIONPROMPTFORDELEGATEDBUNDLEINSTALL) | |
| 86 | |
| 87 using Params = api::dashboard_private:: | |
| 88 ShowPermissionPromptForDelegatedBundleInstall::Params; | |
| 89 | |
| 90 DashboardPrivateShowPermissionPromptForDelegatedBundleInstallFunction(); | |
| 91 | |
| 92 private: | |
| 93 ~DashboardPrivateShowPermissionPromptForDelegatedBundleInstallFunction() | |
| 94 override; | |
| 95 | |
| 96 // ExtensionFunction: | |
| 97 ExtensionFunction::ResponseAction Run() override; | |
| 98 | |
| 99 // chrome::BitmapFetcherDelegate: | |
| 100 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override; | |
| 101 | |
| 102 void OnInstallApproval(BundleInstaller::ApprovalState state); | |
| 103 | |
| 104 const Params::Details& details() const { return params_->details; } | |
| 105 | |
| 106 ChromeExtensionFunctionDetails chrome_details_; | |
| 107 | |
| 108 scoped_ptr<Params> params_; | |
| 109 | |
| 110 scoped_ptr<extensions::BundleInstaller> bundle_; | |
| 111 scoped_ptr<chrome::BitmapFetcher> icon_fetcher_; | |
| 112 }; | |
| 113 | |
| 114 } // namespace extensions | |
| 115 | |
| 116 #endif // CHROME_BROWSER_EXTENSIONS_API_DASHBOARD_PRIVATE_DASHBOARD_PRIVATE_API _H_ | |
| 117 | |
| OLD | NEW |