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

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

Issue 7718021: Add external extensions json source in proper mac location. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: p Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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
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 {
24 NONE = 0,
25
26 // Ensure that only root can force an external install by checking
27 // that all components of the path to external extensions files are
28 // owned by root and not writable by any non-root user.
29 ENSURE_PATH_CONTROLLED_BY_ADMIN = 1 << 0
30 };
31
23 // |base_path_key| is the directory containing the external_extensions.json 32 // |base_path_key| is the directory containing the external_extensions.json
24 // file. Relative file paths to extension files are resolved relative 33 // file. Relative file paths to extension files are resolved relative
25 // to this path. 34 // to this path.
26 explicit ExternalPrefExtensionLoader(int base_path_key); 35 explicit ExternalPrefExtensionLoader(int base_path_key, Options options);
27 36
28 virtual const FilePath GetBaseCrxFilePath() OVERRIDE; 37 virtual const FilePath GetBaseCrxFilePath() OVERRIDE;
29 38
30 protected: 39 protected:
31 virtual void StartLoading() OVERRIDE; 40 virtual void StartLoading() OVERRIDE;
41 bool IsOptionSet(Options option) {
42 return (options_ & option) != 0;
43 }
32 44
33 private: 45 private:
34 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; 46 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>;
35 47
36 virtual ~ExternalPrefExtensionLoader() {} 48 virtual ~ExternalPrefExtensionLoader() {}
37 49
50 DictionaryValue* ReadJsonPrefsFile();
38 void LoadOnFileThread(); 51 void LoadOnFileThread();
39 52
40 int base_path_key_; 53 int base_path_key_;
54 Options options_;
41 FilePath base_path_; 55 FilePath base_path_;
42 56
43 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); 57 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader);
44 }; 58 };
45 59
46 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary 60 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary
47 // from json data specified in a string. 61 // from json data specified in a string.
48 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { 62 class ExternalTestingExtensionLoader : public ExternalExtensionLoader {
49 public: 63 public:
50 ExternalTestingExtensionLoader( 64 ExternalTestingExtensionLoader(
(...skipping 10 matching lines...) Expand all
61 75
62 virtual ~ExternalTestingExtensionLoader(); 76 virtual ~ExternalTestingExtensionLoader();
63 77
64 FilePath fake_base_path_; 78 FilePath fake_base_path_;
65 scoped_ptr<DictionaryValue> testing_prefs_; 79 scoped_ptr<DictionaryValue> testing_prefs_;
66 80
67 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); 81 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader);
68 }; 82 };
69 83
70 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ 84 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698