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 <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search/hotword_audio_history_handler.h" | 16 #include "chrome/browser/search/hotword_audio_history_handler.h" |
16 #include "chrome/browser/search/hotword_client.h" | 17 #include "chrome/browser/search/hotword_client.h" |
17 #include "chrome/browser/search/hotword_service.h" | 18 #include "chrome/browser/search/hotword_service.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 136 } |
136 | 137 |
137 void HotwordPrivateEventService::SignalEvent( | 138 void HotwordPrivateEventService::SignalEvent( |
138 events::HistogramValue histogram_value, | 139 events::HistogramValue histogram_value, |
139 const std::string& event_name, | 140 const std::string& event_name, |
140 scoped_ptr<base::ListValue> args) { | 141 scoped_ptr<base::ListValue> args) { |
141 EventRouter* router = EventRouter::Get(profile_); | 142 EventRouter* router = EventRouter::Get(profile_); |
142 if (!router || !router->HasEventListener(event_name)) | 143 if (!router || !router->HasEventListener(event_name)) |
143 return; | 144 return; |
144 | 145 |
145 scoped_ptr<Event> event(new Event(histogram_value, event_name, args.Pass())); | 146 scoped_ptr<Event> event( |
146 router->BroadcastEvent(event.Pass()); | 147 new Event(histogram_value, event_name, std::move(args))); |
| 148 router->BroadcastEvent(std::move(event)); |
147 } | 149 } |
148 | 150 |
149 bool HotwordPrivateSetEnabledFunction::RunSync() { | 151 bool HotwordPrivateSetEnabledFunction::RunSync() { |
150 scoped_ptr<api::hotword_private::SetEnabled::Params> params( | 152 scoped_ptr<api::hotword_private::SetEnabled::Params> params( |
151 api::hotword_private::SetEnabled::Params::Create(*args_)); | 153 api::hotword_private::SetEnabled::Params::Create(*args_)); |
152 EXTENSION_FUNCTION_VALIDATE(params.get()); | 154 EXTENSION_FUNCTION_VALIDATE(params.get()); |
153 | 155 |
154 PrefService* prefs = GetProfile()->GetPrefs(); | 156 PrefService* prefs = GetProfile()->GetPrefs(); |
155 prefs->SetBoolean(prefs::kHotwordSearchEnabled, params->state); | 157 prefs->SetBoolean(prefs::kHotwordSearchEnabled, params->state); |
156 return true; | 158 return true; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 HotwordService* hotword_service = | 519 HotwordService* hotword_service = |
518 HotwordServiceFactory::GetForProfile(GetProfile()); | 520 HotwordServiceFactory::GetForProfile(GetProfile()); |
519 if (!hotword_service) | 521 if (!hotword_service) |
520 return false; | 522 return false; |
521 | 523 |
522 hotword_service->SpeakerModelExistsComplete(params->exists); | 524 hotword_service->SpeakerModelExistsComplete(params->exists); |
523 return true; | 525 return true; |
524 } | 526 } |
525 | 527 |
526 } // namespace extensions | 528 } // namespace extensions |
OLD | NEW |