Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/browser/ui/webui/settings/search_engines_handler.cc

Issue 2890523003: WebUI: Add helper FireWebUIListener method on WebUIMessageHandler. (Closed)
Patch Set: Rename Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 new base::DictionaryValue); 189 new base::DictionaryValue);
190 search_engines_info->Set("defaults", base::WrapUnique(defaults.release())); 190 search_engines_info->Set("defaults", base::WrapUnique(defaults.release()));
191 search_engines_info->Set("others", base::WrapUnique(others.release())); 191 search_engines_info->Set("others", base::WrapUnique(others.release()));
192 search_engines_info->Set("extensions", 192 search_engines_info->Set("extensions",
193 base::WrapUnique(extensions.release())); 193 base::WrapUnique(extensions.release()));
194 return search_engines_info; 194 return search_engines_info;
195 } 195 }
196 196
197 void SearchEnginesHandler::OnModelChanged() { 197 void SearchEnginesHandler::OnModelChanged() {
198 AllowJavascript(); 198 AllowJavascript();
199 CallJavascriptFunction("cr.webUIListenerCallback", 199 FireWebUIListener("search-engines-changed", *GetSearchEnginesList());
200 base::Value("search-engines-changed"), 200
201 *GetSearchEnginesList());
202 // Google Now availability may have changed. 201 // Google Now availability may have changed.
203 CallJavascriptFunction("cr.webUIListenerCallback", 202 FireWebUIListener("google-now-availability-changed",
204 base::Value("google-now-availability-changed"), 203 base::Value(IsGoogleNowAvailable(profile_)));
205 base::Value(IsGoogleNowAvailable(profile_)));
206 } 204 }
207 205
208 void SearchEnginesHandler::OnItemsChanged(int start, int length) { 206 void SearchEnginesHandler::OnItemsChanged(int start, int length) {
209 OnModelChanged(); 207 OnModelChanged();
210 } 208 }
211 209
212 void SearchEnginesHandler::OnItemsAdded(int start, int length) { 210 void SearchEnginesHandler::OnItemsAdded(int start, int length) {
213 OnModelChanged(); 211 OnModelChanged();
214 } 212 }
215 213
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 status->SetBoolean(kHotwordSatusHistoryEnabled, logging_enabled); 508 status->SetBoolean(kHotwordSatusHistoryEnabled, logging_enabled);
511 HotwordInfoComplete(callback_id.get(), *status); 509 HotwordInfoComplete(callback_id.get(), *status);
512 } 510 }
513 511
514 void SearchEnginesHandler::HotwordInfoComplete( 512 void SearchEnginesHandler::HotwordInfoComplete(
515 const base::Value* callback_id, 513 const base::Value* callback_id,
516 const base::DictionaryValue& status) { 514 const base::DictionaryValue& status) {
517 if (callback_id) { 515 if (callback_id) {
518 ResolveJavascriptCallback(*callback_id, status); 516 ResolveJavascriptCallback(*callback_id, status);
519 } else { 517 } else {
520 CallJavascriptFunction("cr.webUIListenerCallback", 518 FireWebUIListener("hotword-info-update", status);
521 base::Value("hotword-info-update"), status);
522 } 519 }
Dan Beam 2017/05/18 00:08:44 no curlies
dpapad 2017/05/18 00:41:32 Done.
523 } 520 }
524 521
525 void SearchEnginesHandler::SendHotwordInfo() { 522 void SearchEnginesHandler::SendHotwordInfo() {
526 HandleGetHotwordInfo(nullptr); 523 HandleGetHotwordInfo(nullptr);
527 } 524 }
528 525
529 void SearchEnginesHandler::HandleSetHotwordSearchEnabled( 526 void SearchEnginesHandler::HandleSetHotwordSearchEnabled(
530 const base::ListValue* args) { 527 const base::ListValue* args) {
531 CHECK_EQ(1U, args->GetSize()); 528 CHECK_EQ(1U, args->GetSize());
532 bool enabled; 529 bool enabled;
(...skipping 22 matching lines...) Expand all
555 bool logging_enabled = 552 bool logging_enabled =
556 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled); 553 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled);
557 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY 554 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY
558 : HotwordService::HOTWORD_AND_AUDIO_HISTORY; 555 : HotwordService::HOTWORD_AND_AUDIO_HISTORY;
559 } 556 }
560 hotword_service->OptIntoHotwording(launch_mode); 557 hotword_service->OptIntoHotwording(launch_mode);
561 SendHotwordInfo(); 558 SendHotwordInfo();
562 } 559 }
563 560
564 } // namespace settings 561 } // namespace settings
OLDNEW
« no previous file with comments | « no previous file | content/public/browser/web_ui_message_handler.h » ('j') | content/public/browser/web_ui_message_handler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698