| 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_UNPACKED_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class Extension; | 22 class Extension; |
| 23 | 23 |
| 24 // Installs and loads an unpacked extension. Because internal state needs to be | 24 // Installs and loads an unpacked extension. Because internal state needs to be |
| 25 // held about the instalation process, only one call to Load*() should be made | 25 // held about the instalation process, only one call to Load*() should be made |
| 26 // per UnpackedInstaller. | 26 // per UnpackedInstaller. |
| 27 // TODO(erikkay): It might be useful to be able to load a packed extension | 27 // TODO(erikkay): It might be useful to be able to load a packed extension |
| 28 // (presumably into memory) without installing it. | 28 // (presumably into memory) without installing it. |
| 29 class UnpackedInstaller | 29 class UnpackedInstaller |
| 30 : public base::RefCountedThreadSafe<UnpackedInstaller> { | 30 : public base::RefCountedThreadSafe<UnpackedInstaller> { |
| 31 public: | 31 public: |
| 32 typedef base::Callback<void(const base::FilePath&, const std::string&)> | 32 using CompletionCallback = base::Callback<void(const Extension* extension, |
| 33 OnFailureCallback; | 33 const base::FilePath&, |
| 34 const std::string&)>; |
| 34 | 35 |
| 35 static scoped_refptr<UnpackedInstaller> Create( | 36 static scoped_refptr<UnpackedInstaller> Create( |
| 36 ExtensionService* extension_service); | 37 ExtensionService* extension_service); |
| 37 | 38 |
| 38 // Loads the extension from the directory |extension_path|, which is | 39 // Loads the extension from the directory |extension_path|, which is |
| 39 // the top directory of a specific extension where its manifest file lives. | 40 // the top directory of a specific extension where its manifest file lives. |
| 40 // Errors are reported through ExtensionErrorReporter. On success, | 41 // Errors are reported through ExtensionErrorReporter. On success, |
| 41 // ExtensionService::AddExtension() is called. | 42 // ExtensionService::AddExtension() is called. |
| 42 void Load(const base::FilePath& extension_path); | 43 void Load(const base::FilePath& extension_path); |
| 43 | 44 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 61 return require_modern_manifest_version_; | 62 return require_modern_manifest_version_; |
| 62 } | 63 } |
| 63 void set_require_modern_manifest_version(bool val) { | 64 void set_require_modern_manifest_version(bool val) { |
| 64 require_modern_manifest_version_ = val; | 65 require_modern_manifest_version_ = val; |
| 65 } | 66 } |
| 66 | 67 |
| 67 void set_be_noisy_on_failure(bool be_noisy_on_failure) { | 68 void set_be_noisy_on_failure(bool be_noisy_on_failure) { |
| 68 be_noisy_on_failure_ = be_noisy_on_failure; | 69 be_noisy_on_failure_ = be_noisy_on_failure; |
| 69 } | 70 } |
| 70 | 71 |
| 72 void set_completion_callback(const CompletionCallback& callback) { |
| 73 callback_ = callback; |
| 74 } |
| 75 |
| 71 private: | 76 private: |
| 72 friend class base::RefCountedThreadSafe<UnpackedInstaller>; | 77 friend class base::RefCountedThreadSafe<UnpackedInstaller>; |
| 73 | 78 |
| 74 explicit UnpackedInstaller(ExtensionService* extension_service); | 79 explicit UnpackedInstaller(ExtensionService* extension_service); |
| 75 virtual ~UnpackedInstaller(); | 80 virtual ~UnpackedInstaller(); |
| 76 | 81 |
| 77 // Must be called from the UI thread. | 82 // Must be called from the UI thread. |
| 78 void ShowInstallPrompt(); | 83 void ShowInstallPrompt(); |
| 79 | 84 |
| 80 // Begin management policy and requirements checks. | 85 // Begin management policy and requirements checks. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // version. | 131 // version. |
| 127 bool require_modern_manifest_version_; | 132 bool require_modern_manifest_version_; |
| 128 | 133 |
| 129 // Whether or not to be noisy (show a dialog) on failure. Defaults to true. | 134 // Whether or not to be noisy (show a dialog) on failure. Defaults to true. |
| 130 bool be_noisy_on_failure_; | 135 bool be_noisy_on_failure_; |
| 131 | 136 |
| 132 // Checks management policies and requirements before the extension can be | 137 // Checks management policies and requirements before the extension can be |
| 133 // installed. | 138 // installed. |
| 134 ExtensionInstallChecker install_checker_; | 139 ExtensionInstallChecker install_checker_; |
| 135 | 140 |
| 141 CompletionCallback callback_; |
| 142 |
| 136 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); | 143 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
| 137 }; | 144 }; |
| 138 | 145 |
| 139 } // namespace extensions | 146 } // namespace extensions |
| 140 | 147 |
| 141 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 148 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| OLD | NEW |