| 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 ProfileKeyedAPIFactory<HotwordPrivateEventService> > g_factory = |
| 23 LAZY_INSTANCE_INITIALIZER; | 23 LAZY_INSTANCE_INITIALIZER; |
| 24 | 24 |
| 25 HotwordPrivateEventService::HotwordPrivateEventService(Profile* profile) | 25 HotwordPrivateEventService::HotwordPrivateEventService( |
| 26 : profile_(profile) { | 26 content::BrowserContext* context) |
| 27 pref_change_registrar_.Init(profile->GetPrefs()); | 27 : profile_(Profile::FromBrowserContext(context)) { |
| 28 pref_change_registrar_.Init(profile_->GetPrefs()); |
| 28 pref_change_registrar_.Add( | 29 pref_change_registrar_.Add( |
| 29 prefs::kHotwordSearchEnabled, | 30 prefs::kHotwordSearchEnabled, |
| 30 base::Bind(&HotwordPrivateEventService::OnEnabledChanged, | 31 base::Bind(&HotwordPrivateEventService::OnEnabledChanged, |
| 31 base::Unretained(this))); | 32 base::Unretained(this))); |
| 32 } | 33 } |
| 33 | 34 |
| 34 HotwordPrivateEventService::~HotwordPrivateEventService() { | 35 HotwordPrivateEventService::~HotwordPrivateEventService() { |
| 35 } | 36 } |
| 36 | 37 |
| 37 void HotwordPrivateEventService::Shutdown() { | 38 void HotwordPrivateEventService::Shutdown() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 88 |
| 88 PrefService* prefs = GetProfile()->GetPrefs(); | 89 PrefService* prefs = GetProfile()->GetPrefs(); |
| 89 result.enabled = | 90 result.enabled = |
| 90 prefs->GetBoolean(prefs::kHotwordSearchEnabled); | 91 prefs->GetBoolean(prefs::kHotwordSearchEnabled); |
| 91 | 92 |
| 92 SetResult(result.ToValue().release()); | 93 SetResult(result.ToValue().release()); |
| 93 return true; | 94 return true; |
| 94 } | 95 } |
| 95 | 96 |
| 96 } // namespace extensions | 97 } // namespace extensions |
| OLD | NEW |