Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / dashboard_private / dashboard_private_api.h
blobd181966ccfd84ad2f803055496817f35098f9931
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DASHBOARD_PRIVATE_DASHBOARD_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DASHBOARD_PRIVATE_DASHBOARD_PRIVATE_API_H_
8 #include <string>
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"
20 class GURL;
22 namespace chrome {
23 class BitmapFetcher;
24 } // namespace chrome
26 namespace extensions {
28 class Extension;
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)
39 DashboardPrivateShowPermissionPromptForDelegatedInstallFunction();
41 private:
42 using Params =
43 api::dashboard_private::ShowPermissionPromptForDelegatedInstall::Params;
45 ~DashboardPrivateShowPermissionPromptForDelegatedInstallFunction() override;
47 // ExtensionFunction:
48 ExtensionFunction::ResponseAction Run() override;
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;
58 // ExtensionInstallPrompt::Delegate:
59 void InstallUIProceed() override;
60 void InstallUIAbort(bool user_initiated) override;
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;
68 const Params::Details& details() const { return params_->details; }
70 scoped_ptr<Params> params_;
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_;
76 scoped_ptr<ExtensionInstallPrompt> install_prompt_;
79 class DashboardPrivateShowPermissionPromptForDelegatedBundleInstallFunction
80 : public UIThreadExtensionFunction,
81 public chrome::BitmapFetcherDelegate {
82 public:
83 DECLARE_EXTENSION_FUNCTION(
84 "dashboardPrivate.showPermissionPromptForDelegatedBundleInstall",
85 DASHBOARDPRIVATE_SHOWPERMISSIONPROMPTFORDELEGATEDBUNDLEINSTALL)
87 DashboardPrivateShowPermissionPromptForDelegatedBundleInstallFunction();
89 private:
90 using Params = api::dashboard_private::
91 ShowPermissionPromptForDelegatedBundleInstall::Params;
93 ~DashboardPrivateShowPermissionPromptForDelegatedBundleInstallFunction()
94 override;
96 // ExtensionFunction:
97 ExtensionFunction::ResponseAction Run() override;
99 // chrome::BitmapFetcherDelegate:
100 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override;
102 void OnInstallApproval(BundleInstaller::ApprovalState state);
104 const Params::Details& details() const { return params_->details; }
106 ChromeExtensionFunctionDetails chrome_details_;
108 scoped_ptr<Params> params_;
110 scoped_ptr<extensions::BundleInstaller> bundle_;
111 scoped_ptr<chrome::BitmapFetcher> icon_fetcher_;
114 } // namespace extensions
116 #endif // CHROME_BROWSER_EXTENSIONS_API_DASHBOARD_PRIVATE_DASHBOARD_PRIVATE_API_H_