| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   79   }; |   79   }; | 
|   80  |   80  | 
|   81   // Extensions will be installed into service->install_directory(), then |   81   // Extensions will be installed into service->install_directory(), then | 
|   82   // registered with |service|. This does a silent install - see below for |   82   // registered with |service|. This does a silent install - see below for | 
|   83   // other options. |   83   // other options. | 
|   84   static scoped_refptr<CrxInstaller> CreateSilent(ExtensionService* service); |   84   static scoped_refptr<CrxInstaller> CreateSilent(ExtensionService* service); | 
|   85  |   85  | 
|   86   // Same as above, but use |client| to generate a confirmation prompt. |   86   // Same as above, but use |client| to generate a confirmation prompt. | 
|   87   static scoped_refptr<CrxInstaller> Create( |   87   static scoped_refptr<CrxInstaller> Create( | 
|   88       ExtensionService* service, |   88       ExtensionService* service, | 
|   89       scoped_ptr<ExtensionInstallPrompt> client); |   89       std::unique_ptr<ExtensionInstallPrompt> client); | 
|   90  |   90  | 
|   91   // Same as the previous method, except use the |approval| to bypass the |   91   // Same as the previous method, except use the |approval| to bypass the | 
|   92   // prompt. Note that the caller retains ownership of |approval|. |   92   // prompt. Note that the caller retains ownership of |approval|. | 
|   93   static scoped_refptr<CrxInstaller> Create( |   93   static scoped_refptr<CrxInstaller> Create( | 
|   94       ExtensionService* service, |   94       ExtensionService* service, | 
|   95       scoped_ptr<ExtensionInstallPrompt> client, |   95       std::unique_ptr<ExtensionInstallPrompt> client, | 
|   96       const WebstoreInstaller::Approval* approval); |   96       const WebstoreInstaller::Approval* approval); | 
|   97  |   97  | 
|   98   // Install the crx in |source_file|. |   98   // Install the crx in |source_file|. | 
|   99   void InstallCrx(const base::FilePath& source_file); |   99   void InstallCrx(const base::FilePath& source_file); | 
|  100   void InstallCrxFile(const CRXFileInfo& source_file); |  100   void InstallCrxFile(const CRXFileInfo& source_file); | 
|  101  |  101  | 
|  102   // Convert the specified user script into an extension and install it. |  102   // Convert the specified user script into an extension and install it. | 
|  103   void InstallUserScript(const base::FilePath& source_file, |  103   void InstallUserScript(const base::FilePath& source_file, | 
|  104                          const GURL& download_url); |  104                          const GURL& download_url); | 
|  105  |  105  | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  208   // The currently installed version of the extension, for updates. Will be |  208   // The currently installed version of the extension, for updates. Will be | 
|  209   // invalid if this isn't an update. |  209   // invalid if this isn't an update. | 
|  210   const base::Version& current_version() const { return current_version_; } |  210   const base::Version& current_version() const { return current_version_; } | 
|  211  |  211  | 
|  212  private: |  212  private: | 
|  213   friend class ::ExtensionServiceTest; |  213   friend class ::ExtensionServiceTest; | 
|  214   friend class ExtensionUpdaterTest; |  214   friend class ExtensionUpdaterTest; | 
|  215   friend class ExtensionCrxInstallerTest; |  215   friend class ExtensionCrxInstallerTest; | 
|  216  |  216  | 
|  217   CrxInstaller(base::WeakPtr<ExtensionService> service_weak, |  217   CrxInstaller(base::WeakPtr<ExtensionService> service_weak, | 
|  218                scoped_ptr<ExtensionInstallPrompt> client, |  218                std::unique_ptr<ExtensionInstallPrompt> client, | 
|  219                const WebstoreInstaller::Approval* approval); |  219                const WebstoreInstaller::Approval* approval); | 
|  220   ~CrxInstaller() override; |  220   ~CrxInstaller() override; | 
|  221  |  221  | 
|  222   // Converts the source user script to an extension. |  222   // Converts the source user script to an extension. | 
|  223   void ConvertUserScriptOnFileThread(); |  223   void ConvertUserScriptOnFileThread(); | 
|  224  |  224  | 
|  225   // Converts the source web app to an extension. |  225   // Converts the source web app to an extension. | 
|  226   void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); |  226   void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); | 
|  227  |  227  | 
|  228   // Called after OnUnpackSuccess as a last check to see whether the install |  228   // Called after OnUnpackSuccess as a last check to see whether the install | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  314  |  314  | 
|  315   // An expected hash sum for the .crx file. |  315   // An expected hash sum for the .crx file. | 
|  316   std::string expected_hash_; |  316   std::string expected_hash_; | 
|  317  |  317  | 
|  318   // True if installation failed due to a hash sum mismatch. |  318   // True if installation failed due to a hash sum mismatch. | 
|  319   bool hash_check_failed_; |  319   bool hash_check_failed_; | 
|  320  |  320  | 
|  321   // A parsed copy of the expected manifest, before any transformations like |  321   // A parsed copy of the expected manifest, before any transformations like | 
|  322   // localization have taken place. If |approved_| is true, then the |  322   // localization have taken place. If |approved_| is true, then the | 
|  323   // extension's manifest must match this for the install to proceed. |  323   // extension's manifest must match this for the install to proceed. | 
|  324   scoped_ptr<Manifest> expected_manifest_; |  324   std::unique_ptr<Manifest> expected_manifest_; | 
|  325  |  325  | 
|  326   // The level of checking when comparing the actual manifest against |  326   // The level of checking when comparing the actual manifest against | 
|  327   // the |expected_manifest_|. |  327   // the |expected_manifest_|. | 
|  328   WebstoreInstaller::ManifestCheckLevel expected_manifest_check_level_; |  328   WebstoreInstaller::ManifestCheckLevel expected_manifest_check_level_; | 
|  329  |  329  | 
|  330   // If valid, specifies the minimum version we'll install. Installation will |  330   // If valid, specifies the minimum version we'll install. Installation will | 
|  331   // fail if the actual version is smaller. |  331   // fail if the actual version is smaller. | 
|  332   base::Version minimum_version_; |  332   base::Version minimum_version_; | 
|  333  |  333  | 
|  334   // If valid, contains the expected version of the extension we're installing. |  334   // If valid, contains the expected version of the extension we're installing. | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|  354   // Whether to create an app shortcut after successful installation. This is |  354   // Whether to create an app shortcut after successful installation. This is | 
|  355   // set based on the user's selection in the UI and can only ever be true for |  355   // set based on the user's selection in the UI and can only ever be true for | 
|  356   // apps. |  356   // apps. | 
|  357   bool create_app_shortcut_; |  357   bool create_app_shortcut_; | 
|  358  |  358  | 
|  359   // The ordinal of the NTP apps page |extension_| will be shown on. |  359   // The ordinal of the NTP apps page |extension_| will be shown on. | 
|  360   syncer::StringOrdinal page_ordinal_; |  360   syncer::StringOrdinal page_ordinal_; | 
|  361  |  361  | 
|  362   // A parsed copy of the unmodified original manifest, before any |  362   // A parsed copy of the unmodified original manifest, before any | 
|  363   // transformations like localization have taken place. |  363   // transformations like localization have taken place. | 
|  364   scoped_ptr<Manifest> original_manifest_; |  364   std::unique_ptr<Manifest> original_manifest_; | 
|  365  |  365  | 
|  366   // If valid, contains the current version of the extension we're |  366   // If valid, contains the current version of the extension we're | 
|  367   // installing (for upgrades). |  367   // installing (for upgrades). | 
|  368   base::Version current_version_; |  368   base::Version current_version_; | 
|  369  |  369  | 
|  370   // The icon we will display in the installation UI, if any. |  370   // The icon we will display in the installation UI, if any. | 
|  371   scoped_ptr<SkBitmap> install_icon_; |  371   std::unique_ptr<SkBitmap> install_icon_; | 
|  372  |  372  | 
|  373   // The temp directory extension resources were unpacked to. We own this and |  373   // The temp directory extension resources were unpacked to. We own this and | 
|  374   // must delete it when we are done with it. |  374   // must delete it when we are done with it. | 
|  375   base::FilePath temp_dir_; |  375   base::FilePath temp_dir_; | 
|  376  |  376  | 
|  377   // The frontend we will report results back to. |  377   // The frontend we will report results back to. | 
|  378   base::WeakPtr<ExtensionService> service_weak_; |  378   base::WeakPtr<ExtensionService> service_weak_; | 
|  379  |  379  | 
|  380   // The client we will work with to do the installation. This can be NULL, in |  380   // The client we will work with to do the installation. This can be NULL, in | 
|  381   // which case the install is silent. |  381   // which case the install is silent. | 
|  382   scoped_ptr<ExtensionInstallPrompt> client_; |  382   std::unique_ptr<ExtensionInstallPrompt> client_; | 
|  383  |  383  | 
|  384   // The root of the unpacked extension directory. This is a subdirectory of |  384   // The root of the unpacked extension directory. This is a subdirectory of | 
|  385   // temp_dir_, so we don't have to delete it explicitly. |  385   // temp_dir_, so we don't have to delete it explicitly. | 
|  386   base::FilePath unpacked_extension_root_; |  386   base::FilePath unpacked_extension_root_; | 
|  387  |  387  | 
|  388   // True when the CRX being installed was just downloaded. |  388   // True when the CRX being installed was just downloaded. | 
|  389   // Used to trigger extra checks before installing. |  389   // Used to trigger extra checks before installing. | 
|  390   bool apps_require_extension_mime_type_; |  390   bool apps_require_extension_mime_type_; | 
|  391  |  391  | 
|  392   // Allows for the possibility of a normal install (one in which a |client| |  392   // Allows for the possibility of a normal install (one in which a |client| | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  440  |  440  | 
|  441   // Performs requirements, policy and blacklist checks on the extension. |  441   // Performs requirements, policy and blacklist checks on the extension. | 
|  442   ExtensionInstallChecker install_checker_; |  442   ExtensionInstallChecker install_checker_; | 
|  443  |  443  | 
|  444   DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |  444   DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 
|  445 }; |  445 }; | 
|  446  |  446  | 
|  447 }  // namespace extensions |  447 }  // namespace extensions | 
|  448  |  448  | 
|  449 #endif  // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |  449 #endif  // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 
| OLD | NEW |