| 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" | |
| 15 | 14 |
| 16 namespace extensions { | 15 namespace extensions { |
| 17 | 16 |
| 18 namespace OnEnabledChanged = | 17 namespace OnEnabledChanged = |
| 19 api::hotword_private::OnEnabledChanged; | 18 api::hotword_private::OnEnabledChanged; |
| 20 | 19 |
| 21 static base::LazyInstance< | 20 static base::LazyInstance< |
| 22 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = | 21 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = |
| 23 LAZY_INSTANCE_INITIALIZER; | 22 LAZY_INSTANCE_INITIALIZER; |
| 24 | 23 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 51 | 50 |
| 52 void HotwordPrivateEventService::OnEnabledChanged( | 51 void HotwordPrivateEventService::OnEnabledChanged( |
| 53 const std::string& pref_name) { | 52 const std::string& pref_name) { |
| 54 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); | 53 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); |
| 55 SignalEvent(); | 54 SignalEvent(); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void HotwordPrivateEventService::SignalEvent() { | 57 void HotwordPrivateEventService::SignalEvent() { |
| 59 using OnEnabledChanged::kEventName; | 58 using OnEnabledChanged::kEventName; |
| 60 | 59 |
| 61 EventRouter* router = ExtensionSystem::Get(profile_)->event_router(); | 60 EventRouter* router = EventRouter::Get(profile_); |
| 62 if (!router || !router->HasEventListener(kEventName)) | 61 if (!router || !router->HasEventListener(kEventName)) |
| 63 return; | 62 return; |
| 64 scoped_ptr<base::ListValue> args(new base::ListValue()); | 63 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 65 scoped_ptr<Event> event(new Event(kEventName, args.Pass())); | 64 scoped_ptr<Event> event(new Event(kEventName, args.Pass())); |
| 66 router->BroadcastEvent(event.Pass()); | 65 router->BroadcastEvent(event.Pass()); |
| 67 } | 66 } |
| 68 | 67 |
| 69 bool HotwordPrivateSetEnabledFunction::RunImpl() { | 68 bool HotwordPrivateSetEnabledFunction::RunImpl() { |
| 70 scoped_ptr<api::hotword_private::SetEnabled::Params> params( | 69 scoped_ptr<api::hotword_private::SetEnabled::Params> params( |
| 71 api::hotword_private::SetEnabled::Params::Create(*args_)); | 70 api::hotword_private::SetEnabled::Params::Create(*args_)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled); | 100 result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled); |
| 102 result.audio_logging_enabled = false; | 101 result.audio_logging_enabled = false; |
| 103 if (hotword_service) | 102 if (hotword_service) |
| 104 result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging(); | 103 result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging(); |
| 105 | 104 |
| 106 SetResult(result.ToValue().release()); | 105 SetResult(result.ToValue().release()); |
| 107 return true; | 106 return true; |
| 108 } | 107 } |
| 109 | 108 |
| 110 } // namespace extensions | 109 } // namespace extensions |
| OLD | NEW |