| 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 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Loads the extension from the directory |extension_path|; | 35 // Loads the extension from the directory |extension_path|; |
| 36 // for use with command line switch --load-extension=path. | 36 // for use with command line switch --load-extension=path. |
| 37 // This is equivalent to Load, except that it runs synchronously. | 37 // This is equivalent to Load, except that it runs synchronously. |
| 38 void LoadFromCommandLine(const FilePath& extension_path); | 38 void LoadFromCommandLine(const FilePath& extension_path); |
| 39 | 39 |
| 40 // Allows prompting for plugins to be disabled; intended for testing only. | 40 // Allows prompting for plugins to be disabled; intended for testing only. |
| 41 bool prompt_for_plugins() { return prompt_for_plugins_; } | 41 bool prompt_for_plugins() { return prompt_for_plugins_; } |
| 42 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } | 42 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } |
| 43 | 43 |
| 44 // Allows overriding of whether modern manifest versions are required; |
| 45 // intended for testing. |
| 46 bool require_modern_manifest_version() const { |
| 47 return require_modern_manifest_version_; |
| 48 } |
| 49 void set_require_modern_manifest_version(bool val) { |
| 50 require_modern_manifest_version_ = val; |
| 51 } |
| 52 |
| 44 private: | 53 private: |
| 45 friend class base::RefCountedThreadSafe<UnpackedInstaller>; | 54 friend class base::RefCountedThreadSafe<UnpackedInstaller>; |
| 46 | 55 |
| 47 explicit UnpackedInstaller(ExtensionService* extension_service); | 56 explicit UnpackedInstaller(ExtensionService* extension_service); |
| 48 virtual ~UnpackedInstaller(); | 57 virtual ~UnpackedInstaller(); |
| 49 | 58 |
| 50 // Verifies if loading unpacked extensions is allowed. | 59 // Verifies if loading unpacked extensions is allowed. |
| 51 bool IsLoadingUnpackedAllowed() const; | 60 bool IsLoadingUnpackedAllowed() const; |
| 52 | 61 |
| 53 // We change the input extension path to an absolute path, on the file thread. | 62 // We change the input extension path to an absolute path, on the file thread. |
| 54 // Then we need to check the file access preference, which needs | 63 // Then we need to check the file access preference, which needs |
| 55 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on | 64 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on |
| 56 // the UI thread. In turn, once that gets the pref, it goes back to the | 65 // the UI thread. In turn, once that gets the pref, it goes back to the |
| 57 // file thread with LoadWithFileAccess. | 66 // file thread with LoadWithFileAccess. |
| 58 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know | 67 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know |
| 59 // what file access flags to pass to extension_file_util::LoadExtension. | 68 // what file access flags to pass to extension_file_util::LoadExtension. |
| 60 void GetAbsolutePath(); | 69 void GetAbsolutePath(); |
| 61 void CheckExtensionFileAccess(); | 70 void CheckExtensionFileAccess(); |
| 62 void LoadWithFileAccess(bool allow_file_access); | 71 void LoadWithFileAccess(int flags); |
| 63 | 72 |
| 64 // Notify the frontend that there was an error loading an extension. | 73 // Notify the frontend that there was an error loading an extension. |
| 65 void ReportExtensionLoadError(const std::string& error); | 74 void ReportExtensionLoadError(const std::string& error); |
| 66 | 75 |
| 67 // Called when an unpacked extension has been loaded and installed. | 76 // Called when an unpacked extension has been loaded and installed. |
| 68 void OnLoaded(const scoped_refptr<const Extension>& extension); | 77 void OnLoaded(const scoped_refptr<const Extension>& extension); |
| 69 | 78 |
| 79 // Helper to get the Extension::CreateFlags for the installing extension. |
| 80 int GetFlags(); |
| 81 |
| 70 base::WeakPtr<ExtensionService> service_weak_; | 82 base::WeakPtr<ExtensionService> service_weak_; |
| 71 | 83 |
| 72 // The pathname of the directory to load from, which is an absolute path | 84 // The pathname of the directory to load from, which is an absolute path |
| 73 // after GetAbsolutePath has been called. | 85 // after GetAbsolutePath has been called. |
| 74 FilePath extension_path_; | 86 FilePath extension_path_; |
| 75 | 87 |
| 76 // If true and the extension contains plugins, we prompt the user before | 88 // If true and the extension contains plugins, we prompt the user before |
| 77 // loading. | 89 // loading. |
| 78 bool prompt_for_plugins_; | 90 bool prompt_for_plugins_; |
| 79 | 91 |
| 92 // Whether to require the extension installed to have a modern manifest |
| 93 // version. |
| 94 bool require_modern_manifest_version_; |
| 95 |
| 80 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); | 96 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
| 81 }; | 97 }; |
| 82 | 98 |
| 83 } // namespace extensions | 99 } // namespace extensions |
| 84 | 100 |
| 85 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 101 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| OLD | NEW |