| 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 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 | 15 |
| 16 // A specialization of the ExternalExtensionLoader that uses a json file to | 16 // A specialization of the ExternalExtensionLoader that uses a json file to |
| 17 // look up which external extensions are registered. | 17 // look up which external extensions are registered. |
| 18 // Instances of this class are expected to be created and destroyed on the UI | 18 // Instances of this class are expected to be created and destroyed on the UI |
| 19 // thread and they are expecting public method calls from the UI thread. | 19 // thread and they are expecting public method calls from the UI thread. |
| 20 class ExternalPrefExtensionLoader : public ExternalExtensionLoader { | 20 class ExternalPrefExtensionLoader : public ExternalExtensionLoader { |
| 21 public: | 21 public: |
| 22 enum Options { |
| 23 NONE = 0, |
| 24 |
| 25 // Ensure that only root can force an external install by checking |
| 26 // that all components of the path to external extensions files are |
| 27 // owned by root and not writable by any non-root user. |
| 28 ENSURE_PATH_CONTROLLED_BY_ADMIN = 1 << 0 |
| 29 }; |
| 30 |
| 22 // |base_path_key| is the directory containing the external_extensions.json | 31 // |base_path_key| is the directory containing the external_extensions.json |
| 23 // file. Relative file paths to extension files are resolved relative | 32 // file. Relative file paths to extension files are resolved relative |
| 24 // to this path. | 33 // to this path. |
| 25 explicit ExternalPrefExtensionLoader(int base_path_key); | 34 explicit ExternalPrefExtensionLoader(int base_path_key, Options options); |
| 26 | 35 |
| 27 virtual const FilePath GetBaseCrxFilePath(); | 36 virtual const FilePath GetBaseCrxFilePath(); |
| 28 | 37 |
| 29 protected: | 38 protected: |
| 30 virtual void StartLoading(); | 39 virtual void StartLoading(); |
| 40 bool IsOptionSet(Options opt) { |
| 41 return (options_ & opt); |
| 42 } |
| 31 | 43 |
| 32 private: | 44 private: |
| 33 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; | 45 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; |
| 34 | 46 |
| 35 virtual ~ExternalPrefExtensionLoader() {} | 47 virtual ~ExternalPrefExtensionLoader() {} |
| 36 | 48 |
| 49 DictionaryValue* ReadJsonPrefsFile(); |
| 37 void LoadOnFileThread(); | 50 void LoadOnFileThread(); |
| 38 | 51 |
| 39 int base_path_key_; | 52 int base_path_key_; |
| 53 Options options_; |
| 40 FilePath base_path_; | 54 FilePath base_path_; |
| 41 | 55 |
| 42 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); | 56 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); |
| 43 }; | 57 }; |
| 44 | 58 |
| 45 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary | 59 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary |
| 46 // from json data specified in a string. | 60 // from json data specified in a string. |
| 47 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { | 61 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { |
| 48 public: | 62 public: |
| 49 ExternalTestingExtensionLoader( | 63 ExternalTestingExtensionLoader( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 | 74 |
| 61 virtual ~ExternalTestingExtensionLoader(); | 75 virtual ~ExternalTestingExtensionLoader(); |
| 62 | 76 |
| 63 FilePath fake_base_path_; | 77 FilePath fake_base_path_; |
| 64 scoped_ptr<DictionaryValue> testing_prefs_; | 78 scoped_ptr<DictionaryValue> testing_prefs_; |
| 65 | 79 |
| 66 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); | 80 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); |
| 67 }; | 81 }; |
| 68 | 82 |
| 69 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ | 83 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ |
| OLD | NEW |