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

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

Powered by Google App Engine
This is Rietveld 408576698