| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_EXTERNAL_PREF_EXTENSION_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/external_extension_loader.h" | 9 #include "chrome/browser/extensions/external_extension_loader.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 public: | 22 public: |
| 23 enum Options { | 23 enum Options { |
| 24 NONE = 0, | 24 NONE = 0, |
| 25 | 25 |
| 26 // Ensure that only root can force an external install by checking | 26 // Ensure that only root can force an external install by checking |
| 27 // that all components of the path to external extensions files are | 27 // that all components of the path to external extensions files are |
| 28 // owned by root and not writable by any non-root user. | 28 // owned by root and not writable by any non-root user. |
| 29 ENSURE_PATH_CONTROLLED_BY_ADMIN = 1 << 0 | 29 ENSURE_PATH_CONTROLLED_BY_ADMIN = 1 << 0 |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // |base_path_key| is the directory containing the external_extensions.json | 32 // |base_path_id| is the directory containing the external_extensions.json |
| 33 // file. Relative file paths to extension files are resolved relative | 33 // file or the standalone extension manifest files. Relative file paths to |
| 34 // to this path. | 34 // extension files are resolved relative to this path. |
| 35 explicit ExternalPrefExtensionLoader(int base_path_key, Options options); | 35 explicit ExternalPrefExtensionLoader(int base_path_id, Options options); |
| 36 | 36 |
| 37 virtual const FilePath GetBaseCrxFilePath() OVERRIDE; | 37 virtual const FilePath GetBaseCrxFilePath() OVERRIDE; |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 virtual void StartLoading() OVERRIDE; | 40 virtual void StartLoading() OVERRIDE; |
| 41 bool IsOptionSet(Options option) { | 41 bool IsOptionSet(Options option) { |
| 42 return (options_ & option) != 0; | 42 return (options_ & option) != 0; |
| 43 } | 43 } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; | 46 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; |
| 47 | 47 |
| 48 virtual ~ExternalPrefExtensionLoader() {} | 48 virtual ~ExternalPrefExtensionLoader() {} |
| 49 | 49 |
| 50 DictionaryValue* ReadJsonPrefsFile(); | 50 // Actually searches for and loads candidate standalone extension preference |
| 51 // files in the path corresponding to |base_path_id|. |
| 52 // Must be called on the file thread. |
| 51 void LoadOnFileThread(); | 53 void LoadOnFileThread(); |
| 52 | 54 |
| 53 int base_path_key_; | 55 // Extracts the information contained in an external_extension.json file |
| 56 // regarding which extensions to install. |prefs| will be modified to |
| 57 // receive the extracted extension information. |
| 58 // Must be called from the File thread. |
| 59 void ReadExternalExtensionPrefFile(DictionaryValue * prefs); |
| 60 |
| 61 // Extracts the information contained in standalone external extension |
| 62 // json files (<extension id>.json) regarding what external extensions |
| 63 // to install. |prefs| will be modified to receive the extracted extension |
| 64 // information. |
| 65 // Must be called from the File thread. |
| 66 void ReadStandaloneExtensionPrefFiles(DictionaryValue * prefs); |
| 67 |
| 68 // The resource id of the base path with the information about the json |
| 69 // file containing which extensions to load. |
| 70 int base_path_id_; |
| 71 |
| 54 Options options_; | 72 Options options_; |
| 73 |
| 74 // The path (coresponding to |base_path_id_| containing the json files |
| 75 // describing which extensions to load. |
| 55 FilePath base_path_; | 76 FilePath base_path_; |
| 56 | 77 |
| 57 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); | 78 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); |
| 58 }; | 79 }; |
| 59 | 80 |
| 60 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary | 81 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary |
| 61 // from json data specified in a string. | 82 // from json data specified in a string. |
| 62 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { | 83 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { |
| 63 public: | 84 public: |
| 64 ExternalTestingExtensionLoader( | 85 ExternalTestingExtensionLoader( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 | 96 |
| 76 virtual ~ExternalTestingExtensionLoader(); | 97 virtual ~ExternalTestingExtensionLoader(); |
| 77 | 98 |
| 78 FilePath fake_base_path_; | 99 FilePath fake_base_path_; |
| 79 scoped_ptr<DictionaryValue> testing_prefs_; | 100 scoped_ptr<DictionaryValue> testing_prefs_; |
| 80 | 101 |
| 81 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); | 102 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); |
| 82 }; | 103 }; |
| 83 | 104 |
| 84 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ | 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ |
| OLD | NEW |