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/bundle_installer.h" | 10 #include "chrome/browser/extensions/bundle_installer.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 static void SetWebstoreInstallerDelegateForTesting( | 33 static void SetWebstoreInstallerDelegateForTesting( |
34 WebstoreInstaller::Delegate* delegate); | 34 WebstoreInstaller::Delegate* delegate); |
35 | 35 |
36 // Gets the pending approval for the |extension_id| in |profile|. Pending | 36 // Gets the pending approval for the |extension_id| in |profile|. Pending |
37 // approvals are held between the calls to beginInstallWithManifest and | 37 // approvals are held between the calls to beginInstallWithManifest and |
38 // completeInstall. This should only be used for testing. | 38 // completeInstall. This should only be used for testing. |
39 static scoped_ptr<WebstoreInstaller::Approval> PopApprovalForTesting( | 39 static scoped_ptr<WebstoreInstaller::Approval> PopApprovalForTesting( |
40 Profile* profile, const std::string& extension_id); | 40 Profile* profile, const std::string& extension_id); |
41 }; | 41 }; |
42 | 42 |
43 class InstallBundleFunction : public AsyncExtensionFunction, | 43 class WebstorePrivateInstallBundleFunction : public AsyncExtensionFunction, |
44 public extensions::BundleInstaller::Delegate { | 44 public extensions::BundleInstaller::Delegate { |
45 public: | 45 public: |
46 DECLARE_EXTENSION_FUNCTION("webstorePrivate.installBundle", | 46 DECLARE_EXTENSION_FUNCTION("webstorePrivate.installBundle", |
47 WEBSTOREPRIVATE_INSTALLBUNDLE) | 47 WEBSTOREPRIVATE_INSTALLBUNDLE) |
48 | 48 |
49 InstallBundleFunction(); | 49 WebstorePrivateInstallBundleFunction(); |
50 | 50 |
51 // BundleInstaller::Delegate: | 51 // BundleInstaller::Delegate: |
52 virtual void OnBundleInstallApproved() OVERRIDE; | 52 virtual void OnBundleInstallApproved() OVERRIDE; |
53 virtual void OnBundleInstallCanceled(bool user_initiated) OVERRIDE; | 53 virtual void OnBundleInstallCanceled(bool user_initiated) OVERRIDE; |
54 virtual void OnBundleInstallCompleted() OVERRIDE; | 54 virtual void OnBundleInstallCompleted() OVERRIDE; |
55 | 55 |
56 protected: | 56 protected: |
57 virtual ~InstallBundleFunction(); | 57 virtual ~WebstorePrivateInstallBundleFunction(); |
58 | 58 |
59 // ExtensionFunction: | 59 // ExtensionFunction: |
60 virtual bool RunImpl() OVERRIDE; | 60 virtual bool RunImpl() OVERRIDE; |
61 | 61 |
62 // Reads the extension |details| into |items|. | 62 // Reads the extension |details| into |items|. |
63 bool ReadBundleInfo(base::ListValue* details, | 63 bool ReadBundleInfo(base::ListValue* details, |
64 extensions::BundleInstaller::ItemList* items); | 64 extensions::BundleInstaller::ItemList* items); |
65 | 65 |
66 private: | 66 private: |
67 scoped_refptr<extensions::BundleInstaller> bundle_; | 67 scoped_refptr<extensions::BundleInstaller> bundle_; |
68 }; | 68 }; |
69 | 69 |
70 class BeginInstallWithManifestFunction | 70 class WebstorePrivateBeginInstallWithManifest3Function |
71 : public AsyncExtensionFunction, | 71 : public AsyncExtensionFunction, |
72 public ExtensionInstallPrompt::Delegate, | 72 public ExtensionInstallPrompt::Delegate, |
73 public WebstoreInstallHelper::Delegate { | 73 public WebstoreInstallHelper::Delegate { |
74 public: | 74 public: |
75 DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", | 75 DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", |
76 WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) | 76 WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) |
77 | 77 |
78 // Result codes for the return value. If you change this, make sure to | 78 // Result codes for the return value. If you change this, make sure to |
79 // update the description for the beginInstallWithManifest3 callback in | 79 // update the description for the beginInstallWithManifest3 callback in |
80 // the extension API JSON. | 80 // the extension API JSON. |
(...skipping 15 matching lines...) Expand all Loading... |
96 // The extension id was invalid. | 96 // The extension id was invalid. |
97 INVALID_ID, | 97 INVALID_ID, |
98 | 98 |
99 // The page does not have permission to call this function. | 99 // The page does not have permission to call this function. |
100 PERMISSION_DENIED, | 100 PERMISSION_DENIED, |
101 | 101 |
102 // Invalid icon url. | 102 // Invalid icon url. |
103 INVALID_ICON_URL | 103 INVALID_ICON_URL |
104 }; | 104 }; |
105 | 105 |
106 BeginInstallWithManifestFunction(); | 106 WebstorePrivateBeginInstallWithManifest3Function(); |
107 | 107 |
108 // WebstoreInstallHelper::Delegate: | 108 // WebstoreInstallHelper::Delegate: |
109 virtual void OnWebstoreParseSuccess( | 109 virtual void OnWebstoreParseSuccess( |
110 const std::string& id, | 110 const std::string& id, |
111 const SkBitmap& icon, | 111 const SkBitmap& icon, |
112 base::DictionaryValue* parsed_manifest) OVERRIDE; | 112 base::DictionaryValue* parsed_manifest) OVERRIDE; |
113 virtual void OnWebstoreParseFailure( | 113 virtual void OnWebstoreParseFailure( |
114 const std::string& id, | 114 const std::string& id, |
115 InstallHelperResultCode result_code, | 115 InstallHelperResultCode result_code, |
116 const std::string& error_message) OVERRIDE; | 116 const std::string& error_message) OVERRIDE; |
117 | 117 |
118 // ExtensionInstallPrompt::Delegate: | 118 // ExtensionInstallPrompt::Delegate: |
119 virtual void InstallUIProceed() OVERRIDE; | 119 virtual void InstallUIProceed() OVERRIDE; |
120 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 120 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
121 | 121 |
122 protected: | 122 protected: |
123 virtual ~BeginInstallWithManifestFunction(); | 123 virtual ~WebstorePrivateBeginInstallWithManifest3Function(); |
124 | 124 |
125 // ExtensionFunction: | 125 // ExtensionFunction: |
126 virtual bool RunImpl() OVERRIDE; | 126 virtual bool RunImpl() OVERRIDE; |
127 | 127 |
128 // Sets the result_ as a string based on |code|. | 128 // Sets the result_ as a string based on |code|. |
129 void SetResultCode(ResultCode code); | 129 void SetResultCode(ResultCode code); |
130 | 130 |
131 private: | 131 private: |
132 // These store the input parameters to the function. | 132 // These store the input parameters to the function. |
133 std::string id_; | 133 std::string id_; |
134 std::string manifest_; | 134 std::string manifest_; |
135 std::string icon_data_; | 135 std::string icon_data_; |
136 std::string localized_name_; | 136 std::string localized_name_; |
137 bool use_app_installed_bubble_; | 137 bool use_app_installed_bubble_; |
138 | 138 |
139 // The results of parsing manifest_ and icon_data_ go into these two. | 139 // The results of parsing manifest_ and icon_data_ go into these two. |
140 scoped_ptr<base::DictionaryValue> parsed_manifest_; | 140 scoped_ptr<base::DictionaryValue> parsed_manifest_; |
141 SkBitmap icon_; | 141 SkBitmap icon_; |
142 | 142 |
143 // A dummy Extension object we create for the purposes of using | 143 // A dummy Extension object we create for the purposes of using |
144 // ExtensionInstallPrompt to prompt for confirmation of the install. | 144 // ExtensionInstallPrompt to prompt for confirmation of the install. |
145 scoped_refptr<extensions::Extension> dummy_extension_; | 145 scoped_refptr<extensions::Extension> dummy_extension_; |
146 | 146 |
147 // The class that displays the install prompt. | 147 // The class that displays the install prompt. |
148 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | 148 scoped_ptr<ExtensionInstallPrompt> install_prompt_; |
149 }; | 149 }; |
150 | 150 |
151 class CompleteInstallFunction | 151 class WebstorePrivateCompleteInstallFunction |
152 : public AsyncExtensionFunction, | 152 : public AsyncExtensionFunction, |
153 public WebstoreInstaller::Delegate { | 153 public WebstoreInstaller::Delegate { |
154 public: | 154 public: |
155 DECLARE_EXTENSION_FUNCTION("webstorePrivate.completeInstall", | 155 DECLARE_EXTENSION_FUNCTION("webstorePrivate.completeInstall", |
156 WEBSTOREPRIVATE_COMPLETEINSTALL) | 156 WEBSTOREPRIVATE_COMPLETEINSTALL) |
157 | 157 |
158 // WebstoreInstaller::Delegate: | 158 // WebstoreInstaller::Delegate: |
159 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | 159 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
160 virtual void OnExtensionInstallFailure( | 160 virtual void OnExtensionInstallFailure( |
161 const std::string& id, | 161 const std::string& id, |
162 const std::string& error, | 162 const std::string& error, |
163 WebstoreInstaller::FailureReason reason) OVERRIDE; | 163 WebstoreInstaller::FailureReason reason) OVERRIDE; |
164 protected: | 164 protected: |
165 virtual ~CompleteInstallFunction() {} | 165 virtual ~WebstorePrivateCompleteInstallFunction() {} |
166 | 166 |
167 // ExtensionFunction: | 167 // ExtensionFunction: |
168 virtual bool RunImpl() OVERRIDE; | 168 virtual bool RunImpl() OVERRIDE; |
169 }; | 169 }; |
170 | 170 |
171 class GetBrowserLoginFunction : public SyncExtensionFunction { | 171 class WebstorePrivateGetBrowserLoginFunction : public SyncExtensionFunction { |
172 public: | 172 public: |
173 DECLARE_EXTENSION_FUNCTION("webstorePrivate.getBrowserLogin", | 173 DECLARE_EXTENSION_FUNCTION("webstorePrivate.getBrowserLogin", |
174 WEBSTOREPRIVATE_GETBROWSERLOGIN) | 174 WEBSTOREPRIVATE_GETBROWSERLOGIN) |
175 | 175 |
176 protected: | 176 protected: |
177 virtual ~GetBrowserLoginFunction() {} | 177 virtual ~WebstorePrivateGetBrowserLoginFunction() {} |
178 | 178 |
179 // ExtensionFunction: | 179 // ExtensionFunction: |
180 virtual bool RunImpl() OVERRIDE; | 180 virtual bool RunImpl() OVERRIDE; |
181 }; | 181 }; |
182 | 182 |
183 class GetStoreLoginFunction : public SyncExtensionFunction { | 183 class WebstorePrivateGetStoreLoginFunction : public SyncExtensionFunction { |
184 public: | 184 public: |
185 DECLARE_EXTENSION_FUNCTION("webstorePrivate.getStoreLogin", | 185 DECLARE_EXTENSION_FUNCTION("webstorePrivate.getStoreLogin", |
186 WEBSTOREPRIVATE_GETSTORELOGIN) | 186 WEBSTOREPRIVATE_GETSTORELOGIN) |
187 | 187 |
188 protected: | 188 protected: |
189 virtual ~GetStoreLoginFunction() {} | 189 virtual ~WebstorePrivateGetStoreLoginFunction() {} |
190 | 190 |
191 // ExtensionFunction: | 191 // ExtensionFunction: |
192 virtual bool RunImpl() OVERRIDE; | 192 virtual bool RunImpl() OVERRIDE; |
193 }; | 193 }; |
194 | 194 |
195 class SetStoreLoginFunction : public SyncExtensionFunction { | 195 class WebstorePrivateSetStoreLoginFunction : public SyncExtensionFunction { |
196 public: | 196 public: |
197 DECLARE_EXTENSION_FUNCTION("webstorePrivate.setStoreLogin", | 197 DECLARE_EXTENSION_FUNCTION("webstorePrivate.setStoreLogin", |
198 WEBSTOREPRIVATE_SETSTORELOGIN) | 198 WEBSTOREPRIVATE_SETSTORELOGIN) |
199 | 199 |
200 protected: | 200 protected: |
201 virtual ~SetStoreLoginFunction() {} | 201 virtual ~WebstorePrivateSetStoreLoginFunction() {} |
202 | 202 |
203 // ExtensionFunction: | 203 // ExtensionFunction: |
204 virtual bool RunImpl() OVERRIDE; | 204 virtual bool RunImpl() OVERRIDE; |
205 }; | 205 }; |
206 | 206 |
207 class GetWebGLStatusFunction : public AsyncExtensionFunction { | 207 class WebstorePrivateGetWebGLStatusFunction : public AsyncExtensionFunction { |
208 public: | 208 public: |
209 DECLARE_EXTENSION_FUNCTION("webstorePrivate.getWebGLStatus", | 209 DECLARE_EXTENSION_FUNCTION("webstorePrivate.getWebGLStatus", |
210 WEBSTOREPRIVATE_GETWEBGLSTATUS) | 210 WEBSTOREPRIVATE_GETWEBGLSTATUS) |
211 | 211 |
212 GetWebGLStatusFunction(); | 212 WebstorePrivateGetWebGLStatusFunction(); |
213 | 213 |
214 protected: | 214 protected: |
215 virtual ~GetWebGLStatusFunction(); | 215 virtual ~WebstorePrivateGetWebGLStatusFunction(); |
216 | 216 |
217 void OnFeatureCheck(bool feature_allowed); | 217 void OnFeatureCheck(bool feature_allowed); |
218 | 218 |
219 // ExtensionFunction: | 219 // ExtensionFunction: |
220 virtual bool RunImpl() OVERRIDE; | 220 virtual bool RunImpl() OVERRIDE; |
221 | 221 |
222 private: | 222 private: |
223 void CreateResult(bool webgl_allowed); | 223 void CreateResult(bool webgl_allowed); |
224 | 224 |
225 scoped_refptr<GPUFeatureChecker> feature_checker_; | 225 scoped_refptr<GPUFeatureChecker> feature_checker_; |
226 }; | 226 }; |
227 | 227 |
228 } // namespace extensions | 228 } // namespace extensions |
229 | 229 |
230 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H
_ | 230 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H
_ |
OLD | NEW |