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

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

Issue 6293006: Allow relative paths to external extension files for some providers, error out for others. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Rebase for commit. Created 9 years, 11 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/scoped_ptr.h" 13 #include "base/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 ExternalPrefExtensionLoader(); 22 // |base_path_key| is the directory containing the external_extensions.json
23 // file. Relative file paths to extension files are resolved relative
24 // to this path.
25 explicit ExternalPrefExtensionLoader(int base_path_key);
26
27 virtual const FilePath GetBaseCrxFilePath();
23 28
24 protected: 29 protected:
25 virtual void StartLoading(); 30 virtual void StartLoading();
26 31
27 private: 32 private:
28 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; 33 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>;
29 34
30 virtual ~ExternalPrefExtensionLoader() {} 35 virtual ~ExternalPrefExtensionLoader() {}
31 36
32 void LoadOnFileThread(); 37 void LoadOnFileThread();
33 38
39 int base_path_key_;
40 FilePath base_path_;
41
34 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader); 42 DISALLOW_COPY_AND_ASSIGN(ExternalPrefExtensionLoader);
35 }; 43 };
36 44
37 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary 45 // A simplified version of ExternalPrefExtensionLoader that loads the dictionary
38 // from json data specified in a string. 46 // from json data specified in a string.
39 class ExternalTestingExtensionLoader : public ExternalExtensionLoader { 47 class ExternalTestingExtensionLoader : public ExternalExtensionLoader {
40 public: 48 public:
41 explicit ExternalTestingExtensionLoader(const std::string& json_data); 49 ExternalTestingExtensionLoader(
50 const std::string& json_data,
51 const FilePath& fake_base_path);
52
53 virtual const FilePath GetBaseCrxFilePath();
42 54
43 protected: 55 protected:
44 virtual void StartLoading(); 56 virtual void StartLoading();
45 57
46 private: 58 private:
47 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; 59 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>;
48 60
49 virtual ~ExternalTestingExtensionLoader() {} 61 virtual ~ExternalTestingExtensionLoader() {}
50 62
63 FilePath fake_base_path_;
51 scoped_ptr<DictionaryValue> testing_prefs_; 64 scoped_ptr<DictionaryValue> testing_prefs_;
52 65
53 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader); 66 DISALLOW_COPY_AND_ASSIGN(ExternalTestingExtensionLoader);
54 }; 67 };
55 68
56 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_ 69 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PREF_EXTENSION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698