OLD | NEW |
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_CRX_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 public ExtensionInstallUI::Delegate { | 48 public ExtensionInstallUI::Delegate { |
49 public: | 49 public: |
50 // This is pretty lame, but given the difficulty of connecting a particular | 50 // This is pretty lame, but given the difficulty of connecting a particular |
51 // ExtensionFunction to a resulting download in the download manager, it's | 51 // ExtensionFunction to a resulting download in the download manager, it's |
52 // currently necessary. This is the |id| of an extension to be installed | 52 // currently necessary. This is the |id| of an extension to be installed |
53 // *by the web store only* which should not get the permissions install | 53 // *by the web store only* which should not get the permissions install |
54 // prompt. This should only be called on the UI thread. | 54 // prompt. This should only be called on the UI thread. |
55 // crbug.com/54916 | 55 // crbug.com/54916 |
56 static void SetWhitelistedInstallId(const std::string& id); | 56 static void SetWhitelistedInstallId(const std::string& id); |
57 | 57 |
| 58 struct WhitelistEntry { |
| 59 scoped_ptr<DictionaryValue> parsed_manifest; |
| 60 std::string localized_name; |
| 61 }; |
| 62 |
58 // Exempt the next extension install with |id| from displaying a confirmation | 63 // Exempt the next extension install with |id| from displaying a confirmation |
59 // prompt, since the user already agreed to the install via | 64 // prompt, since the user already agreed to the install via |
60 // beginInstallWithManifest. We require that the extension manifest matches | 65 // beginInstallWithManifest. We require that the extension manifest matches |
61 // |parsed_manifest| which is what was used to prompt with. Ownership of | 66 // the manifest in |entry|, which is what was used to prompt with. Ownership |
62 // |parsed_manifest| is transferred here. | 67 // of |entry| is transferred here. |
63 static void SetWhitelistedManifest(const std::string& id, | 68 static void SetWhitelistEntry(const std::string& id, WhitelistEntry* entry); |
64 DictionaryValue* parsed_manifest); | |
65 | 69 |
66 // Returns the previously stored manifest from a call to | 70 // Returns the previously stored manifest from a call to SetWhitelistEntry. |
67 // SetWhitelistedManifest. | 71 static const CrxInstaller::WhitelistEntry* GetWhitelistEntry( |
68 static const DictionaryValue* GetWhitelistedManifest(const std::string& id); | 72 const std::string& id); |
69 | 73 |
70 // Removes any whitelisted manifest for |id| and returns it. The caller owns | 74 // Removes any whitelist data for |id| and returns it. The caller owns |
71 // the return value and is responsible for deleting it. | 75 // the return value and is responsible for deleting it. |
72 static DictionaryValue* RemoveWhitelistedManifest(const std::string& id); | 76 static WhitelistEntry* RemoveWhitelistEntry(const std::string& id); |
73 | 77 |
74 // Returns whether |id| is whitelisted - only call this on the UI thread. | 78 // Returns whether |id| is whitelisted - only call this on the UI thread. |
75 static bool IsIdWhitelisted(const std::string& id); | 79 static bool IsIdWhitelisted(const std::string& id); |
76 | 80 |
77 // Returns whether |id| was found and removed (was whitelisted). This should | 81 // Returns whether |id| was found and removed (was whitelisted). This should |
78 // only be called on the UI thread. | 82 // only be called on the UI thread. |
79 static bool ClearWhitelistedInstallId(const std::string& id); | 83 static bool ClearWhitelistedInstallId(const std::string& id); |
80 | 84 |
81 // Constructor. Extensions will be installed into | 85 // Constructor. Extensions will be installed into |
82 // frontend_weak->install_directory() then registered with | 86 // frontend_weak->install_directory() then registered with |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); | 156 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); |
153 | 157 |
154 // Called after OnUnpackSuccess as a last check to see whether the install | 158 // Called after OnUnpackSuccess as a last check to see whether the install |
155 // should complete. | 159 // should complete. |
156 bool AllowInstall(const Extension* extension, std::string* error); | 160 bool AllowInstall(const Extension* extension, std::string* error); |
157 | 161 |
158 // SandboxedExtensionUnpackerClient | 162 // SandboxedExtensionUnpackerClient |
159 virtual void OnUnpackFailure(const std::string& error_message); | 163 virtual void OnUnpackFailure(const std::string& error_message); |
160 virtual void OnUnpackSuccess(const FilePath& temp_dir, | 164 virtual void OnUnpackSuccess(const FilePath& temp_dir, |
161 const FilePath& extension_dir, | 165 const FilePath& extension_dir, |
| 166 const DictionaryValue* original_manifest, |
162 const Extension* extension); | 167 const Extension* extension); |
163 | 168 |
164 // Returns true if we can skip confirmation because the install was | 169 // Returns true if we can skip confirmation because the install was |
165 // whitelisted. | 170 // whitelisted. |
166 bool CanSkipConfirmation(); | 171 bool CanSkipConfirmation(); |
167 | 172 |
168 // Runs on the UI thread. Confirms with the user (via ExtensionInstallUI) that | 173 // Runs on the UI thread. Confirms with the user (via ExtensionInstallUI) that |
169 // it is OK to install this extension. | 174 // it is OK to install this extension. |
170 void ConfirmInstall(); | 175 void ConfirmInstall(); |
171 | 176 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 223 |
219 // Whether to create an app shortcut after successful installation. This is | 224 // Whether to create an app shortcut after successful installation. This is |
220 // set based on the user's selection in the UI and can only ever be true for | 225 // set based on the user's selection in the UI and can only ever be true for |
221 // apps. | 226 // apps. |
222 bool create_app_shortcut_; | 227 bool create_app_shortcut_; |
223 | 228 |
224 // The extension we're installing. We own this and either pass it off to | 229 // The extension we're installing. We own this and either pass it off to |
225 // ExtensionService on success, or delete it on failure. | 230 // ExtensionService on success, or delete it on failure. |
226 scoped_refptr<const Extension> extension_; | 231 scoped_refptr<const Extension> extension_; |
227 | 232 |
| 233 // A parsed copy of the unmodified original manifest, before any |
| 234 // transformations like localization have taken place. |
| 235 scoped_ptr<DictionaryValue> original_manifest_; |
| 236 |
228 // If non-empty, contains the current version of the extension we're | 237 // If non-empty, contains the current version of the extension we're |
229 // installing (for upgrades). | 238 // installing (for upgrades). |
230 std::string current_version_; | 239 std::string current_version_; |
231 | 240 |
232 // The icon we will display in the installation UI, if any. | 241 // The icon we will display in the installation UI, if any. |
233 scoped_ptr<SkBitmap> install_icon_; | 242 scoped_ptr<SkBitmap> install_icon_; |
234 | 243 |
235 // The temp directory extension resources were unpacked to. We own this and | 244 // The temp directory extension resources were unpacked to. We own this and |
236 // must delete it when we are done with it. | 245 // must delete it when we are done with it. |
237 FilePath temp_dir_; | 246 FilePath temp_dir_; |
(...skipping 27 matching lines...) Expand all Loading... |
265 std::string original_mime_type_; | 274 std::string original_mime_type_; |
266 | 275 |
267 // What caused this install? Used only for histograms that report | 276 // What caused this install? Used only for histograms that report |
268 // on failure rates, broken down by the cause of the install. | 277 // on failure rates, broken down by the cause of the install. |
269 extension_misc::CrxInstallCause install_cause_; | 278 extension_misc::CrxInstallCause install_cause_; |
270 | 279 |
271 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 280 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
272 }; | 281 }; |
273 | 282 |
274 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 283 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |