| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/settings/search_engines_handler.h" | 5 #include "chrome/browser/ui/webui/settings/search_engines_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 search_engines_info->Set("defaults", base::WrapUnique(defaults.release())); | 188 search_engines_info->Set("defaults", base::WrapUnique(defaults.release())); |
| 189 search_engines_info->Set("others", base::WrapUnique(others.release())); | 189 search_engines_info->Set("others", base::WrapUnique(others.release())); |
| 190 search_engines_info->Set("extensions", | 190 search_engines_info->Set("extensions", |
| 191 base::WrapUnique(extensions.release())); | 191 base::WrapUnique(extensions.release())); |
| 192 return search_engines_info; | 192 return search_engines_info; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SearchEnginesHandler::OnModelChanged() { | 195 void SearchEnginesHandler::OnModelChanged() { |
| 196 AllowJavascript(); | 196 AllowJavascript(); |
| 197 CallJavascriptFunction("cr.webUIListenerCallback", | 197 CallJavascriptFunction("cr.webUIListenerCallback", |
| 198 base::StringValue("search-engines-changed"), | 198 base::Value("search-engines-changed"), |
| 199 *GetSearchEnginesList()); | 199 *GetSearchEnginesList()); |
| 200 // Google Now availability may have changed. | 200 // Google Now availability may have changed. |
| 201 CallJavascriptFunction("cr.webUIListenerCallback", | 201 CallJavascriptFunction("cr.webUIListenerCallback", |
| 202 base::StringValue("google-now-availability-changed"), | 202 base::Value("google-now-availability-changed"), |
| 203 base::Value(IsGoogleNowAvailable(profile_))); | 203 base::Value(IsGoogleNowAvailable(profile_))); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SearchEnginesHandler::OnItemsChanged(int start, int length) { | 206 void SearchEnginesHandler::OnItemsChanged(int start, int length) { |
| 207 OnModelChanged(); | 207 OnModelChanged(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void SearchEnginesHandler::OnItemsAdded(int start, int length) { | 210 void SearchEnginesHandler::OnItemsAdded(int start, int length) { |
| 211 OnModelChanged(); | 211 OnModelChanged(); |
| 212 } | 212 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 HotwordInfoComplete(callback_id.get(), *status); | 511 HotwordInfoComplete(callback_id.get(), *status); |
| 512 } | 512 } |
| 513 | 513 |
| 514 void SearchEnginesHandler::HotwordInfoComplete( | 514 void SearchEnginesHandler::HotwordInfoComplete( |
| 515 const base::Value* callback_id, | 515 const base::Value* callback_id, |
| 516 const base::DictionaryValue& status) { | 516 const base::DictionaryValue& status) { |
| 517 if (callback_id) { | 517 if (callback_id) { |
| 518 ResolveJavascriptCallback(*callback_id, status); | 518 ResolveJavascriptCallback(*callback_id, status); |
| 519 } else { | 519 } else { |
| 520 CallJavascriptFunction("cr.webUIListenerCallback", | 520 CallJavascriptFunction("cr.webUIListenerCallback", |
| 521 base::StringValue("hotword-info-update"), status); | 521 base::Value("hotword-info-update"), status); |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 void SearchEnginesHandler::SendHotwordInfo() { | 525 void SearchEnginesHandler::SendHotwordInfo() { |
| 526 HandleGetHotwordInfo(nullptr); | 526 HandleGetHotwordInfo(nullptr); |
| 527 } | 527 } |
| 528 | 528 |
| 529 void SearchEnginesHandler::HandleSetHotwordSearchEnabled( | 529 void SearchEnginesHandler::HandleSetHotwordSearchEnabled( |
| 530 const base::ListValue* args) { | 530 const base::ListValue* args) { |
| 531 CHECK_EQ(1U, args->GetSize()); | 531 CHECK_EQ(1U, args->GetSize()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 555 bool logging_enabled = | 555 bool logging_enabled = |
| 556 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled); | 556 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled); |
| 557 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY | 557 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY |
| 558 : HotwordService::HOTWORD_AND_AUDIO_HISTORY; | 558 : HotwordService::HOTWORD_AND_AUDIO_HISTORY; |
| 559 } | 559 } |
| 560 hotword_service->OptIntoHotwording(launch_mode); | 560 hotword_service->OptIntoHotwording(launch_mode); |
| 561 SendHotwordInfo(); | 561 SendHotwordInfo(); |
| 562 } | 562 } |
| 563 | 563 |
| 564 } // namespace settings | 564 } // namespace settings |
| OLD | NEW |