| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 |
| 14 class Extension; |
| 15 class ExtensionService; |
| 16 class FilePath; |
| 17 |
| 18 namespace extensions { |
| 19 |
| 20 // Installs and loads an unpacked extension. |
| 21 // TODO(erikkay): It might be useful to be able to load a packed extension |
| 22 // (presumably into memory) without installing it. |
| 23 class UnpackedInstaller |
| 24 : public base::RefCountedThreadSafe<UnpackedInstaller> { |
| 25 public: |
| 26 explicit UnpackedInstaller(base::WeakPtr<ExtensionService> extension_service); |
| 27 |
| 28 // Loads the extension from the directory |extension_path|. |
| 29 void Load(const FilePath& extension_path); |
| 30 |
| 31 // Loads the extension from the directory |extension_path|; |
| 32 // for use with command line switch --load-extension=path. |
| 33 // This is equivalent to Load, except that it runs synchronously. |
| 34 void LoadFromCommandLine(const FilePath& extension_path); |
| 35 |
| 36 // Allows prompting for plugins to be disabled; intended for testing only. |
| 37 bool prompt_for_plugins() { return prompt_for_plugins_; } |
| 38 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } |
| 39 |
| 40 private: |
| 41 friend class base::RefCountedThreadSafe<UnpackedInstaller>; |
| 42 |
| 43 virtual ~UnpackedInstaller(); |
| 44 |
| 45 // Loads a single extension from |path| where |path| is the top directory of |
| 46 // a specific extension where its manifest file lives. |
| 47 // Errors are reported through ExtensionErrorReporter. On success, |
| 48 // ExtensionService::AddExtension() is called. |
| 49 void LoadSingleExtension(const FilePath &extension_path); |
| 50 |
| 51 // LoadSingleExtension needs to check the file access preference, which needs |
| 52 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on |
| 53 // the UI thread. In turn, once that gets the pref, it goes back to the |
| 54 // file thread with LoadSingleExtensionWithFileAccess. |
| 55 void CheckExtensionFileAccess(const FilePath& extension_path); |
| 56 void LoadSingleExtensionWithFileAccess( |
| 57 const FilePath &path, bool allow_file_access); |
| 58 |
| 59 // Notify the frontend that there was an error loading an extension. |
| 60 void ReportExtensionLoadError(const FilePath& extension_path, |
| 61 const std::string& error); |
| 62 |
| 63 // Called when an unpacked extension has been loaded and installed. |
| 64 void OnLoadSingleExtension(const scoped_refptr<const Extension>& extension); |
| 65 |
| 66 base::WeakPtr<ExtensionService> service_weak_; |
| 67 |
| 68 // If true and the extension contains plugins, we prompt the user before |
| 69 // loading. |
| 70 bool prompt_for_plugins_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
| 73 }; |
| 74 |
| 75 } // namespace extensions |
| 76 |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| OLD | NEW |