OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_COMPONENT_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_COMPONENT_LOADER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_COMPONENT_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_COMPONENT_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/containers/hash_tables.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "chrome/browser/extensions/external_loader.h" | 11 #include "chrome/browser/extensions/external_loader.h" |
14 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
15 | 13 |
16 class PrefChangeRegistrar; | |
17 | |
18 namespace extensions { | 14 namespace extensions { |
19 | 15 |
20 // A specialization of the ExternalLoader that loads a hard-coded list of | 16 // A specialization of the ExternalLoader that loads a hard-coded list of |
21 // external extensions, that should be considered components of chrome (but | 17 // external extensions, that should be considered components of chrome (but |
22 // unlike Component extensions, these extensions are installed from the webstore | 18 // unlike Component extensions, these extensions are installed from the webstore |
23 // and don't get access to component only APIs. | 19 // and don't get access to component only APIs. |
24 // 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 |
25 // 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. |
26 class ExternalComponentLoader | 22 class ExternalComponentLoader : public ExternalLoader { |
27 : public ExternalLoader, | |
28 public base::SupportsWeakPtr<ExternalComponentLoader> { | |
29 public: | 23 public: |
30 explicit ExternalComponentLoader(Profile* profile); | 24 explicit ExternalComponentLoader(Profile* profile); |
31 | 25 |
32 static bool IsEnhancedBookmarksExperimentEnabled(); | 26 static bool IsEnhancedBookmarksExperimentEnabled(); |
33 | 27 |
34 // Register speech synthesis prefs for a profile. | |
35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
36 | |
37 protected: | 28 protected: |
38 virtual void StartLoading() OVERRIDE; | 29 virtual void StartLoading() OVERRIDE; |
39 | 30 |
40 private: | 31 private: |
41 friend class base::RefCountedThreadSafe<ExternalLoader>; | 32 friend class base::RefCountedThreadSafe<ExternalLoader>; |
42 virtual ~ExternalComponentLoader(); | 33 virtual ~ExternalComponentLoader(); |
43 | 34 |
44 // The profile that this loader is associated with. It listens for | 35 // The profile that this loader is associated with. It listens for |
45 // preference changes for that profile. | 36 // preference changes for that profile. |
46 Profile* profile_; | 37 Profile* profile_; |
47 | |
48 #if defined(OS_CHROMEOS) | |
49 // The pref change registrar, so we can watch for pref changes. | |
50 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | |
51 | |
52 // A map from language code to the extension id of the high-quality | |
53 // extension for that language in the web store, if any - for loading | |
54 // speech synthesis component extensions. | |
55 base::hash_map<std::string, std::string> lang_to_extension_id_map_; | |
56 #endif | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(ExternalComponentLoader); | 38 DISALLOW_COPY_AND_ASSIGN(ExternalComponentLoader); |
59 }; | 39 }; |
60 | 40 |
61 } // namespace extensions | 41 } // namespace extensions |
62 | 42 |
63 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_COMPONENT_LOADER_H_ | 43 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_COMPONENT_LOADER_H_ |
OLD | NEW |