| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/search/hotword_client.h" | 11 #include "chrome/browser/search/hotword_client.h" |
| 12 #include "chrome/browser/search/hotword_service.h" | 12 #include "chrome/browser/search/hotword_service.h" |
| 13 #include "chrome/browser/search/hotword_service_factory.h" | 13 #include "chrome/browser/search/hotword_service_factory.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 namespace hotword_private_constants { |
| 21 const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable."; |
| 22 } // hotword_private_constants |
| 23 |
| 20 namespace OnEnabledChanged = | 24 namespace OnEnabledChanged = |
| 21 api::hotword_private::OnEnabledChanged; | 25 api::hotword_private::OnEnabledChanged; |
| 22 | 26 |
| 23 static base::LazyInstance< | 27 static base::LazyInstance< |
| 24 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = | 28 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = |
| 25 LAZY_INSTANCE_INITIALIZER; | 29 LAZY_INSTANCE_INITIALIZER; |
| 26 | 30 |
| 27 HotwordPrivateEventService::HotwordPrivateEventService( | 31 HotwordPrivateEventService::HotwordPrivateEventService( |
| 28 content::BrowserContext* context) | 32 content::BrowserContext* context) |
| 29 : profile_(Profile::FromBrowserContext(context)) { | 33 : profile_(Profile::FromBrowserContext(context)) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 142 } |
| 139 | 143 |
| 140 bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() { | 144 bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() { |
| 141 HotwordService* hotword_service = | 145 HotwordService* hotword_service = |
| 142 HotwordServiceFactory::GetForProfile(GetProfile()); | 146 HotwordServiceFactory::GetForProfile(GetProfile()); |
| 143 if (hotword_service && hotword_service->client()) | 147 if (hotword_service && hotword_service->client()) |
| 144 hotword_service->client()->OnHotwordRecognized(); | 148 hotword_service->client()->OnHotwordRecognized(); |
| 145 return true; | 149 return true; |
| 146 } | 150 } |
| 147 | 151 |
| 152 bool HotwordPrivateGetLaunchStateFunction::RunSync() { |
| 153 api::hotword_private::LaunchState result; |
| 154 |
| 155 HotwordService* hotword_service = |
| 156 HotwordServiceFactory::GetForProfile(GetProfile()); |
| 157 if (!hotword_service) { |
| 158 error_ = hotword_private_constants::kHotwordServiceUnavailable; |
| 159 return false; |
| 160 } else { |
| 161 result.launch_mode = |
| 162 hotword_service->GetHotwordAudioVerificationLaunchMode(); |
| 163 } |
| 164 |
| 165 SetResult(result.ToValue().release()); |
| 166 return true; |
| 167 } |
| 168 |
| 148 } // namespace extensions | 169 } // namespace extensions |
| OLD | NEW |