OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" | 5 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/search/hotword_service.h" | 10 #include "chrome/browser/search/hotword_service.h" |
11 #include "chrome/browser/search/hotword_service_factory.h" | 11 #include "chrome/browser/search/hotword_service_factory.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "extensions/browser/event_router.h" | 13 #include "extensions/browser/event_router.h" |
14 #include "extensions/browser/extension_system.h" | 14 #include "extensions/browser/extension_system.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 namespace OnEnabledChanged = | 18 namespace OnEnabledChanged = |
19 api::hotword_private::OnEnabledChanged; | 19 api::hotword_private::OnEnabledChanged; |
20 | 20 |
21 static base::LazyInstance< | 21 static base::LazyInstance< |
22 ProfileKeyedAPIFactory<HotwordPrivateEventService> > g_factory = | 22 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = |
23 LAZY_INSTANCE_INITIALIZER; | 23 LAZY_INSTANCE_INITIALIZER; |
24 | 24 |
25 HotwordPrivateEventService::HotwordPrivateEventService( | 25 HotwordPrivateEventService::HotwordPrivateEventService( |
26 content::BrowserContext* context) | 26 content::BrowserContext* context) |
27 : profile_(Profile::FromBrowserContext(context)) { | 27 : profile_(Profile::FromBrowserContext(context)) { |
28 pref_change_registrar_.Init(profile_->GetPrefs()); | 28 pref_change_registrar_.Init(profile_->GetPrefs()); |
29 pref_change_registrar_.Add( | 29 pref_change_registrar_.Add( |
30 prefs::kHotwordSearchEnabled, | 30 prefs::kHotwordSearchEnabled, |
31 base::Bind(&HotwordPrivateEventService::OnEnabledChanged, | 31 base::Bind(&HotwordPrivateEventService::OnEnabledChanged, |
32 base::Unretained(this))); | 32 base::Unretained(this))); |
33 } | 33 } |
34 | 34 |
35 HotwordPrivateEventService::~HotwordPrivateEventService() { | 35 HotwordPrivateEventService::~HotwordPrivateEventService() { |
36 } | 36 } |
37 | 37 |
38 void HotwordPrivateEventService::Shutdown() { | 38 void HotwordPrivateEventService::Shutdown() { |
39 } | 39 } |
40 | 40 |
41 // static | 41 // static |
42 ProfileKeyedAPIFactory<HotwordPrivateEventService>* | 42 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>* |
43 HotwordPrivateEventService::GetFactoryInstance() { | 43 HotwordPrivateEventService::GetFactoryInstance() { |
44 return g_factory.Pointer(); | 44 return g_factory.Pointer(); |
45 } | 45 } |
46 | 46 |
47 // static | 47 // static |
48 const char* HotwordPrivateEventService::service_name() { | 48 const char* HotwordPrivateEventService::service_name() { |
49 return "HotwordPrivateEventService"; | 49 return "HotwordPrivateEventService"; |
50 } | 50 } |
51 | 51 |
52 void HotwordPrivateEventService::OnEnabledChanged( | 52 void HotwordPrivateEventService::OnEnabledChanged( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 PrefService* prefs = GetProfile()->GetPrefs(); | 89 PrefService* prefs = GetProfile()->GetPrefs(); |
90 result.enabled_set = prefs->HasPrefPath(prefs::kHotwordSearchEnabled); | 90 result.enabled_set = prefs->HasPrefPath(prefs::kHotwordSearchEnabled); |
91 result.enabled = | 91 result.enabled = |
92 prefs->GetBoolean(prefs::kHotwordSearchEnabled); | 92 prefs->GetBoolean(prefs::kHotwordSearchEnabled); |
93 | 93 |
94 SetResult(result.ToValue().release()); | 94 SetResult(result.ToValue().release()); |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 } // namespace extensions | 98 } // namespace extensions |
OLD | NEW |