| 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_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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 void set_page_ordinal(const syncer::StringOrdinal& page_ordinal) { | 178 void set_page_ordinal(const syncer::StringOrdinal& page_ordinal) { |
| 179 page_ordinal_ = page_ordinal; | 179 page_ordinal_ = page_ordinal; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void set_error_on_unsupported_requirements(bool val) { | 182 void set_error_on_unsupported_requirements(bool val) { |
| 183 error_on_unsupported_requirements_ = val; | 183 error_on_unsupported_requirements_ = val; |
| 184 } | 184 } |
| 185 | 185 |
| 186 void set_install_immediately(bool val) { | 186 void set_install_immediately(bool val) { |
| 187 if (val) | 187 set_install_flag(kInstallFlagInstallImmediately, val); |
| 188 install_flags_ |= kInstallFlagInstallImmediately; | |
| 189 else | |
| 190 install_flags_ &= ~kInstallFlagInstallImmediately; | |
| 191 } | 188 } |
| 192 | |
| 193 void set_is_ephemeral(bool val) { | 189 void set_is_ephemeral(bool val) { |
| 194 if (val) | 190 set_install_flag(kInstallFlagIsEphemeral, val); |
| 195 install_flags_ |= kInstallFlagIsEphemeral; | |
| 196 else | |
| 197 install_flags_ &= ~kInstallFlagIsEphemeral; | |
| 198 } | 191 } |
| 199 | 192 void set_do_not_sync(bool val) { |
| 200 void set_install_flag(int flag, bool val) { | 193 set_install_flag(kInstallFlagDoNotSync, val); |
| 201 if (val) | |
| 202 install_flags_ |= flag; | |
| 203 else | |
| 204 install_flags_ &= ~flag; | |
| 205 } | 194 } |
| 206 | 195 |
| 207 bool did_handle_successfully() const { return did_handle_successfully_; } | 196 bool did_handle_successfully() const { return did_handle_successfully_; } |
| 208 | 197 |
| 209 Profile* profile() { return installer_.profile(); } | 198 Profile* profile() { return installer_.profile(); } |
| 210 | 199 |
| 211 const Extension* extension() { return installer_.extension().get(); } | 200 const Extension* extension() { return installer_.extension().get(); } |
| 212 | 201 |
| 202 const std::string& current_version() const { return current_version_; } |
| 203 |
| 213 private: | 204 private: |
| 214 friend class ::ExtensionServiceTest; | 205 friend class ::ExtensionServiceTest; |
| 215 friend class ExtensionUpdaterTest; | 206 friend class ExtensionUpdaterTest; |
| 216 friend class ExtensionCrxInstallerTest; | 207 friend class ExtensionCrxInstallerTest; |
| 217 | 208 |
| 218 CrxInstaller(base::WeakPtr<ExtensionService> service_weak, | 209 CrxInstaller(base::WeakPtr<ExtensionService> service_weak, |
| 219 scoped_ptr<ExtensionInstallPrompt> client, | 210 scoped_ptr<ExtensionInstallPrompt> client, |
| 220 const WebstoreInstaller::Approval* approval); | 211 const WebstoreInstaller::Approval* approval); |
| 221 virtual ~CrxInstaller(); | 212 virtual ~CrxInstaller(); |
| 222 | 213 |
| 223 // Converts the source user script to an extension. | 214 // Converts the source user script to an extension. |
| 224 void ConvertUserScriptOnFileThread(); | 215 void ConvertUserScriptOnFileThread(); |
| 225 | 216 |
| 226 // Converts the source web app to an extension. | 217 // Converts the source web app to an extension. |
| 227 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app, | 218 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); |
| 228 const base::FilePath& install_directory); | |
| 229 | 219 |
| 230 // Called after OnUnpackSuccess as a last check to see whether the install | 220 // Called after OnUnpackSuccess as a last check to see whether the install |
| 231 // should complete. | 221 // should complete. |
| 232 CrxInstallerError AllowInstall(const Extension* extension); | 222 CrxInstallerError AllowInstall(const Extension* extension); |
| 233 | 223 |
| 234 // SandboxedUnpackerClient | 224 // SandboxedUnpackerClient |
| 235 virtual void OnUnpackFailure(const base::string16& error_message) OVERRIDE; | 225 virtual void OnUnpackFailure(const base::string16& error_message) OVERRIDE; |
| 236 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, | 226 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, |
| 237 const base::FilePath& extension_dir, | 227 const base::FilePath& extension_dir, |
| 238 const base::DictionaryValue* original_manifest, | 228 const base::DictionaryValue* original_manifest, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 void CleanupTempFiles(); | 262 void CleanupTempFiles(); |
| 273 | 263 |
| 274 // Checks whether the current installation is initiated by the user from | 264 // Checks whether the current installation is initiated by the user from |
| 275 // the extension settings page to update an existing extension or app. | 265 // the extension settings page to update an existing extension or app. |
| 276 void CheckUpdateFromSettingsPage(); | 266 void CheckUpdateFromSettingsPage(); |
| 277 | 267 |
| 278 // Show re-enable prompt if the update is initiated from the settings page | 268 // Show re-enable prompt if the update is initiated from the settings page |
| 279 // and needs additional permissions. | 269 // and needs additional permissions. |
| 280 void ConfirmReEnable(); | 270 void ConfirmReEnable(); |
| 281 | 271 |
| 272 void set_install_flag(int flag, bool val) { |
| 273 if (val) |
| 274 install_flags_ |= flag; |
| 275 else |
| 276 install_flags_ &= ~flag; |
| 277 } |
| 278 |
| 282 // The file we're installing. | 279 // The file we're installing. |
| 283 base::FilePath source_file_; | 280 base::FilePath source_file_; |
| 284 | 281 |
| 285 // The URL the file was downloaded from. | 282 // The URL the file was downloaded from. |
| 286 GURL download_url_; | 283 GURL download_url_; |
| 287 | 284 |
| 288 // The directory extensions are installed to. | 285 // The directory extensions are installed to. |
| 289 base::FilePath install_directory_; | 286 const base::FilePath install_directory_; |
| 290 | 287 |
| 291 // The location the installation came from (bundled with Chromium, registry, | 288 // The location the installation came from (bundled with Chromium, registry, |
| 292 // manual install, etc). This metadata is saved with the installation if | 289 // manual install, etc). This metadata is saved with the installation if |
| 293 // successful. Defaults to INTERNAL. | 290 // successful. Defaults to INTERNAL. |
| 294 Manifest::Location install_source_; | 291 Manifest::Location install_source_; |
| 295 | 292 |
| 296 // Indicates whether the user has already approved the extension to be | 293 // Indicates whether the user has already approved the extension to be |
| 297 // installed. If true, |expected_manifest_| and |expected_id_| must match | 294 // installed. If true, |expected_manifest_| and |expected_id_| must match |
| 298 // those of the CRX. | 295 // those of the CRX. |
| 299 bool approved_; | 296 bool approved_; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 419 |
| 423 // Gives access to common methods and data of an extension installer. | 420 // Gives access to common methods and data of an extension installer. |
| 424 ExtensionInstaller installer_; | 421 ExtensionInstaller installer_; |
| 425 | 422 |
| 426 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 423 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
| 427 }; | 424 }; |
| 428 | 425 |
| 429 } // namespace extensions | 426 } // namespace extensions |
| 430 | 427 |
| 431 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 428 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
| OLD | NEW |