Chromium Code Reviews| 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/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 | 16 |
| 17 // A specialization of the ExternalExtensionLoader that uses a json file to | 17 // A specialization of the ExternalExtensionLoader that uses a json file to |
|
Finnur
2012/04/27 10:50:28
update comment ("a json file")
| |
| 18 // look up which external extensions are registered. | 18 // look up which external extensions are registered. |
| 19 // Instances of this class are expected to be created and destroyed on the UI | 19 // Instances of this class are expected to be created and destroyed on the UI |
| 20 // thread and they are expecting public method calls from the UI thread. | 20 // thread and they are expecting public method calls from the UI thread. |
| 21 class ExternalPrefExtensionLoader : public ExternalExtensionLoader { | 21 class ExternalPrefExtensionLoader : public ExternalExtensionLoader { |
| 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 dispatched/called on the file thread. | |
|
Finnur
2012/04/27 10:50:28
nit: Drop the word dispatched.
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 51 void LoadOnFileThread(); | 53 void LoadOnFileThread(); |
| 52 | 54 |
| 53 int base_path_key_; | 55 // Tries to read and extract the information contained in a |
|
Finnur
2012/04/27 10:50:28
Suggest: s/Tries to read and extract/Extracts/.
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 56 // external_extension.json file. | |
|
Finnur
2012/04/27 10:50:28
Add: ... regarding what external extensions to ins
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 57 // |prefs| will be modified to receive the extracted extension | |
|
Finnur
2012/04/27 10:50:28
Nit: Merge this with line 56 (don't add a linebrea
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 58 // information. | |
| 59 // Must be called from the File thread. | |
| 60 void ReadExternalExtensionPrefFile(DictionaryValue * prefs); | |
| 61 | |
| 62 // Tries to read and extract the information contained in | |
|
Finnur
2012/04/27 10:50:28
Suggest: s/Tries to read and extract/Extracts/.
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 63 // standalone external extension json files whose name follow the | |
| 64 // following pattern: | |
| 65 // <extension id>.json | |
|
Finnur
2012/04/27 10:50:28
Suggest: ... contained in standalone external exte
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 66 // |prefs| will be modified to receive the extracted extension | |
| 67 // information. | |
| 68 // Must be called from the File thread. | |
| 69 void ReadStandaloneExtensionPrefFiles(DictionaryValue * prefs); | |
| 70 | |
| 71 // The resource id of the base path containing the json file containing | |
|
Finnur
2012/04/27 10:50:28
Second 'containing' should be 'with the informatio
Alexandre Abreu
2012/04/27 14:05:40
Done.
| |
| 72 // which extensions to load. | |
| 73 int base_path_id_; | |
| 74 | |
| 54 Options options_; | 75 Options options_; |
| 76 | |
| 77 // The path (coresponding to |base_path_id_| containing the json files | |
| 78 // describing which extensions to load. | |
| 55 FilePath base_path_; | 79 FilePath base_path_; |
| 56 | 80 |
| 57 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); | 81 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); |
| 58 }; | 82 }; |
| 59 | 83 |
| 60 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary | 84 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary |
| 61 // from json data specified in a string. | 85 // from json data specified in a string. |
| 62 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { | 86 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { |
| 63 public: | 87 public: |
| 64 ExternalTestingExtensionLoader( | 88 ExternalTestingExtensionLoader( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 75 | 99 |
| 76 virtual ~ExternalTestingExtensionLoader(); | 100 virtual ~ExternalTestingExtensionLoader(); |
| 77 | 101 |
| 78 FilePath fake_base_path_; | 102 FilePath fake_base_path_; |
| 79 scoped_ptr<DictionaryValue> testing_prefs_; | 103 scoped_ptr<DictionaryValue> testing_prefs_; |
| 80 | 104 |
| 81 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); | 105 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); |
| 82 }; | 106 }; |
| 83 | 107 |
| 84 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ | 108 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ |
| OLD | NEW |