Chromium Code Reviews| 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, |
|
Matt Perry
2011/05/25 01:46:06
nit: can fit on 1 line looks like
asargent_no_longer_on_chrome
2011/05/25 04:42:00
Done.
| |
| 64 DictionaryValue* parsed_manifest); | 69 WhitelistEntry* entry); |
| 65 | 70 |
| 66 // Returns the previously stored manifest from a call to | 71 // Returns the previously stored manifest from a call to SetWhitelistEntry. |
| 67 // SetWhitelistedManifest. | 72 static const CrxInstaller::WhitelistEntry* GetWhitelistEntry( |
| 68 static const DictionaryValue* GetWhitelistedManifest(const std::string& id); | 73 const std::string& id); |
| 69 | 74 |
| 70 // Removes any whitelisted manifest for |id| and returns it. The caller owns | 75 // Removes any whitelist data for |id| and returns it. The caller owns |
| 71 // the return value and is responsible for deleting it. | 76 // the return value and is responsible for deleting it. |
| 72 static DictionaryValue* RemoveWhitelistedManifest(const std::string& id); | 77 static WhitelistEntry* RemoveWhitelistEntry(const std::string& id); |
| 73 | 78 |
| 74 // Returns whether |id| is whitelisted - only call this on the UI thread. | 79 // Returns whether |id| is whitelisted - only call this on the UI thread. |
| 75 static bool IsIdWhitelisted(const std::string& id); | 80 static bool IsIdWhitelisted(const std::string& id); |
| 76 | 81 |
| 77 // Returns whether |id| was found and removed (was whitelisted). This should | 82 // Returns whether |id| was found and removed (was whitelisted). This should |
| 78 // only be called on the UI thread. | 83 // only be called on the UI thread. |
| 79 static bool ClearWhitelistedInstallId(const std::string& id); | 84 static bool ClearWhitelistedInstallId(const std::string& id); |
| 80 | 85 |
| 81 // Constructor. Extensions will be installed into | 86 // Constructor. Extensions will be installed into |
| 82 // frontend_weak->install_directory() then registered with | 87 // 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); | 157 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); |
| 153 | 158 |
| 154 // Called after OnUnpackSuccess as a last check to see whether the install | 159 // Called after OnUnpackSuccess as a last check to see whether the install |
| 155 // should complete. | 160 // should complete. |
| 156 bool AllowInstall(const Extension* extension, std::string* error); | 161 bool AllowInstall(const Extension* extension, std::string* error); |
| 157 | 162 |
| 158 // SandboxedExtensionUnpackerClient | 163 // SandboxedExtensionUnpackerClient |
| 159 virtual void OnUnpackFailure(const std::string& error_message); | 164 virtual void OnUnpackFailure(const std::string& error_message); |
| 160 virtual void OnUnpackSuccess(const FilePath& temp_dir, | 165 virtual void OnUnpackSuccess(const FilePath& temp_dir, |
| 161 const FilePath& extension_dir, | 166 const FilePath& extension_dir, |
| 167 const DictionaryValue* original_manifest, | |
| 162 const Extension* extension); | 168 const Extension* extension); |
| 163 | 169 |
| 164 // Returns true if we can skip confirmation because the install was | 170 // Returns true if we can skip confirmation because the install was |
| 165 // whitelisted. | 171 // whitelisted. |
| 166 bool CanSkipConfirmation(); | 172 bool CanSkipConfirmation(); |
| 167 | 173 |
| 168 // Runs on the UI thread. Confirms with the user (via ExtensionInstallUI) that | 174 // Runs on the UI thread. Confirms with the user (via ExtensionInstallUI) that |
| 169 // it is OK to install this extension. | 175 // it is OK to install this extension. |
| 170 void ConfirmInstall(); | 176 void ConfirmInstall(); |
| 171 | 177 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 | 223 |
| 218 // Whether to create an app shortcut after successful installation. This is | 224 // Whether to create an app shortcut after successful installation. This is |
| 219 // 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 |
| 220 // apps. | 226 // apps. |
| 221 bool create_app_shortcut_; | 227 bool create_app_shortcut_; |
| 222 | 228 |
| 223 // 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 |
| 224 // ExtensionService on success, or delete it on failure. | 230 // ExtensionService on success, or delete it on failure. |
| 225 scoped_refptr<const Extension> extension_; | 231 scoped_refptr<const Extension> extension_; |
| 226 | 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 | |
| 227 // 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 |
| 228 // installing (for upgrades). | 238 // installing (for upgrades). |
| 229 std::string current_version_; | 239 std::string current_version_; |
| 230 | 240 |
| 231 // The icon we will display in the installation UI, if any. | 241 // The icon we will display in the installation UI, if any. |
| 232 scoped_ptr<SkBitmap> install_icon_; | 242 scoped_ptr<SkBitmap> install_icon_; |
| 233 | 243 |
| 234 // 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 |
| 235 // must delete it when we are done with it. | 245 // must delete it when we are done with it. |
| 236 FilePath temp_dir_; | 246 FilePath temp_dir_; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 264 std::string original_mime_type_; | 274 std::string original_mime_type_; |
| 265 | 275 |
| 266 // What caused this install? Used only for histograms that report | 276 // What caused this install? Used only for histograms that report |
| 267 // on failure rates, broken down by the cause of the install. | 277 // on failure rates, broken down by the cause of the install. |
| 268 extension_misc::CrxInstallCause install_cause_; | 278 extension_misc::CrxInstallCause install_cause_; |
| 269 | 279 |
| 270 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 280 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
| 271 }; | 281 }; |
| 272 | 282 |
| 273 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 283 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
| OLD | NEW |