Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: chrome/browser/extensions/extension_webstore_private_api.h

Issue 8430033: Adds a webstorePrivate method for silently installing extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_EXTENSION_WEBSTORE_PRIVATE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/extensions/extension_function.h" 11 #include "chrome/browser/extensions/extension_function.h"
12 #include "chrome/browser/extensions/extension_install_ui.h" 12 #include "chrome/browser/extensions/extension_install_ui.h"
13 #include "chrome/browser/extensions/webstore_install_helper.h" 13 #include "chrome/browser/extensions/webstore_install_helper.h"
14 #include "chrome/browser/extensions/webstore_installer.h" 14 #include "chrome/browser/extensions/webstore_installer.h"
15 #include "chrome/common/net/gaia/google_service_auth_error.h" 15 #include "chrome/common/net/gaia/google_service_auth_error.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 18
19 class ProfileSyncService; 19 class ProfileSyncService;
20 20
21 class WebstorePrivateApi { 21 class WebstorePrivateApi {
22 public: 22 public:
23 // Allows you to set the ProfileSyncService the function will use for 23 // Allows you to set the ProfileSyncService the function will use for
24 // testing purposes. 24 // testing purposes.
25 static void SetTestingProfileSyncService(ProfileSyncService* service); 25 static void SetTestingProfileSyncService(ProfileSyncService* service);
26 26
27 // Allows you to override the WebstoreInstaller delegate for testing. 27 // Allows you to override the WebstoreInstaller delegate for testing.
28 static void SetWebstoreInstallerDelegateForTesting( 28 static void SetWebstoreInstallerDelegateForTesting(
29 WebstoreInstaller::Delegate* delegate); 29 WebstoreInstaller::Delegate* delegate);
30
31 // Lets tests provide an extension ID that can be installed silently.
32 static void SetTrustedIDForTesting(const char* extension_id);
30 }; 33 };
31 34
32 class BeginInstallWithManifestFunction 35 class BeginInstallWithManifestFunction
33 : public AsyncExtensionFunction, 36 : public AsyncExtensionFunction,
34 public ExtensionInstallUI::Delegate, 37 public ExtensionInstallUI::Delegate,
35 public WebstoreInstallHelper::Delegate { 38 public WebstoreInstallHelper::Delegate {
36 public: 39 public:
37 BeginInstallWithManifestFunction(); 40 BeginInstallWithManifestFunction();
38 41
39 // Result codes for the return value. If you change this, make sure to 42 // Result codes for the return value. If you change this, make sure to
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 scoped_refptr<Extension> dummy_extension_; 105 scoped_refptr<Extension> dummy_extension_;
103 106
104 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.beginInstallWithManifest3"); 107 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.beginInstallWithManifest3");
105 }; 108 };
106 109
107 class CompleteInstallFunction : public SyncExtensionFunction { 110 class CompleteInstallFunction : public SyncExtensionFunction {
108 virtual bool RunImpl(); 111 virtual bool RunImpl();
109 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.completeInstall"); 112 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.completeInstall");
110 }; 113 };
111 114
115 class SilentlyInstallFunction : public AsyncExtensionFunction,
116 public WebstoreInstallHelper::Delegate,
117 public WebstoreInstaller::Delegate {
118 public:
119 SilentlyInstallFunction();
120
121 // Result codes for the return value. If you change this, make sure to
122 // update the description for the silentlyInstall callback in
123 // extension_api.json.
124 enum ResultCode {
125 ERROR_NONE = 0,
126
127 // An unspecified error occurred.
128 UNKNOWN_ERROR,
129
130 // The manifest failed to parse correctly.
131 MANIFEST_ERROR,
132
133 // The extension id was invalid.
134 INVALID_ID,
135
136 // The page does not have permission to call this function.
137 PERMISSION_DENIED,
138 };
139
140 // WebstoreInstallHelper::Delegate implementation.
141 virtual void OnWebstoreParseSuccess(
142 const std::string& id,
143 const SkBitmap& icon,
144 base::DictionaryValue* parsed_manifest) OVERRIDE;
145 virtual void OnWebstoreParseFailure(
146 const std::string& id,
147 InstallHelperResultCode result_code,
148 const std::string& error_message) OVERRIDE;
149
150 // WebstoreInstaller::Delegate implementation.
151 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
152 virtual void OnExtensionInstallFailure(const std::string& id,
153 const std::string& error) OVERRIDE;
154
155 protected:
156 virtual ~SilentlyInstallFunction();
157 virtual bool RunImpl() OVERRIDE;
158
159 // Sets the result_ as a string based on |code|.
160 void SetResult(ResultCode code);
161
162 private:
163 std::string id_;
164 std::string manifest_;
165 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.silentlyInstall");
166 };
167
112 class GetBrowserLoginFunction : public SyncExtensionFunction { 168 class GetBrowserLoginFunction : public SyncExtensionFunction {
113 virtual bool RunImpl(); 169 virtual bool RunImpl();
114 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin"); 170 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin");
115 }; 171 };
116 172
117 class GetStoreLoginFunction : public SyncExtensionFunction { 173 class GetStoreLoginFunction : public SyncExtensionFunction {
118 virtual bool RunImpl(); 174 virtual bool RunImpl();
119 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getStoreLogin"); 175 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getStoreLogin");
120 }; 176 };
121 177
122 class SetStoreLoginFunction : public SyncExtensionFunction { 178 class SetStoreLoginFunction : public SyncExtensionFunction {
123 virtual bool RunImpl(); 179 virtual bool RunImpl();
124 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.setStoreLogin"); 180 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.setStoreLogin");
125 }; 181 };
126 182
127 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698