Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1102)

Side by Side Diff: chrome/browser/extensions/external_pref_loader.h

Issue 10692168: Moved ExternalExtensionLoaders/Providers into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Even later master Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_EXTERNAL_PREF_EXTENSION_LOADER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_LOADER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_LOADER_H_
7 7
8 #include "chrome/browser/extensions/external_extension_loader.h" 8 #include "chrome/browser/extensions/external_loader.h"
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
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 namespace extensions {
17
18 // A specialization of the ExternalLoader that uses a json file to
17 // look up which external extensions are registered. 19 // look up which external extensions are registered.
18 // Instances of this class are expected to be created and destroyed on the UI 20 // 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. 21 // thread and they are expecting public method calls from the UI thread.
20 class ExternalPrefExtensionLoader : public ExternalExtensionLoader { 22 class ExternalPrefLoader : public ExternalLoader {
21 public: 23 public:
22 enum Options { 24 enum Options {
23 NONE = 0, 25 NONE = 0,
24 26
25 // Ensure that only root can force an external install by checking 27 // Ensure that only root can force an external install by checking
26 // that all components of the path to external extensions files are 28 // that all components of the path to external extensions files are
27 // owned by root and not writable by any non-root user. 29 // owned by root and not writable by any non-root user.
28 ENSURE_PATH_CONTROLLED_BY_ADMIN = 1 << 0 30 ENSURE_PATH_CONTROLLED_BY_ADMIN = 1 << 0
29 }; 31 };
30 32
31 // |base_path_id| is the directory containing the external_extensions.json 33 // |base_path_id| is the directory containing the external_extensions.json
32 // file or the standalone extension manifest files. Relative file paths to 34 // file or the standalone extension manifest files. Relative file paths to
33 // extension files are resolved relative to this path. 35 // extension files are resolved relative to this path.
34 explicit ExternalPrefExtensionLoader(int base_path_id, Options options); 36 ExternalPrefLoader(int base_path_id, Options options);
35 37
36 virtual const FilePath GetBaseCrxFilePath() OVERRIDE; 38 virtual const FilePath GetBaseCrxFilePath() OVERRIDE;
37 39
38 protected: 40 protected:
39 virtual void StartLoading() OVERRIDE; 41 virtual void StartLoading() OVERRIDE;
40 bool IsOptionSet(Options option) { 42 bool IsOptionSet(Options option) {
41 return (options_ & option) != 0; 43 return (options_ & option) != 0;
42 } 44 }
43 45
44 private: 46 private:
45 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; 47 friend class base::RefCountedThreadSafe<ExternalLoader>;
46 48
47 virtual ~ExternalPrefExtensionLoader() {} 49 virtual ~ExternalPrefLoader() {}
48 50
49 // Actually searches for and loads candidate standalone extension preference 51 // Actually searches for and loads candidate standalone extension preference
50 // files in the path corresponding to |base_path_id|. 52 // files in the path corresponding to |base_path_id|.
51 // Must be called on the file thread. 53 // Must be called on the file thread.
52 void LoadOnFileThread(); 54 void LoadOnFileThread();
53 55
54 // Extracts the information contained in an external_extension.json file 56 // Extracts the information contained in an external_extension.json file
55 // regarding which extensions to install. |prefs| will be modified to 57 // regarding which extensions to install. |prefs| will be modified to
56 // receive the extracted extension information. 58 // receive the extracted extension information.
57 // Must be called from the File thread. 59 // Must be called from the File thread.
58 void ReadExternalExtensionPrefFile(DictionaryValue * prefs); 60 void ReadExternalExtensionPrefFile(DictionaryValue * prefs);
59 61
60 // Extracts the information contained in standalone external extension 62 // Extracts the information contained in standalone external extension
61 // json files (<extension id>.json) regarding what external extensions 63 // json files (<extension id>.json) regarding what external extensions
62 // to install. |prefs| will be modified to receive the extracted extension 64 // to install. |prefs| will be modified to receive the extracted extension
63 // information. 65 // information.
64 // Must be called from the File thread. 66 // Must be called from the File thread.
65 void ReadStandaloneExtensionPrefFiles(DictionaryValue * prefs); 67 void ReadStandaloneExtensionPrefFiles(DictionaryValue * prefs);
66 68
67 // The resource id of the base path with the information about the json 69 // The resource id of the base path with the information about the json
68 // file containing which extensions to load. 70 // file containing which extensions to load.
69 int base_path_id_; 71 int base_path_id_;
70 72
71 Options options_; 73 Options options_;
72 74
73 // The path (coresponding to |base_path_id_| containing the json files 75 // The path (coresponding to |base_path_id_| containing the json files
74 // describing which extensions to load. 76 // describing which extensions to load.
75 FilePath base_path_; 77 FilePath base_path_;
76 78
77 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); 79 DISALLOW_COPY_AND_ASSIGN(ExternalPrefLoader);
78 }; 80 };
79 81
80 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary 82 // A simplified version of ExternalPrefLoader that loads the dictionary
81 // from json data specified in a string. 83 // from json data specified in a string.
82 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { 84 class ExternalTestingLoader : public ExternalLoader {
83 public: 85 public:
84 ExternalTestingExtensionLoader( 86 ExternalTestingLoader(const std::string& json_data,
85 const std::string& json_data, 87 const FilePath& fake_base_path);
86 const FilePath& fake_base_path);
87 88
88 virtual const FilePath GetBaseCrxFilePath() OVERRIDE; 89 virtual const FilePath GetBaseCrxFilePath() OVERRIDE;
89 90
90 protected: 91 protected:
91 virtual void StartLoading() OVERRIDE; 92 virtual void StartLoading() OVERRIDE;
92 93
93 private: 94 private:
94 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; 95 friend class base::RefCountedThreadSafe<ExternalLoader>;
95 96
96 virtual ~ExternalTestingExtensionLoader(); 97 virtual ~ExternalTestingLoader();
97 98
98 FilePath fake_base_path_; 99 FilePath fake_base_path_;
99 scoped_ptr<DictionaryValue> testing_prefs_; 100 scoped_ptr<DictionaryValue> testing_prefs_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); 102 DISALLOW_COPY_AND_ASSIGN(ExternalTestingLoader);
102 }; 103 };
103 104
104 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ 105 } // namespace extensions
106
107 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_pref_extension_loader.cc ('k') | chrome/browser/extensions/external_pref_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698