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

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: Address comment. 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
« no previous file with comments | « no previous file | content/public/browser/web_ui_message_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 bool success, 505 bool success,
508 bool logging_enabled) { 506 bool logging_enabled) {
509 if (success) 507 if (success)
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 }
523 } 519 }
524 520
525 void SearchEnginesHandler::SendHotwordInfo() { 521 void SearchEnginesHandler::SendHotwordInfo() {
526 HandleGetHotwordInfo(nullptr); 522 HandleGetHotwordInfo(nullptr);
527 } 523 }
528 524
529 void SearchEnginesHandler::HandleSetHotwordSearchEnabled( 525 void SearchEnginesHandler::HandleSetHotwordSearchEnabled(
530 const base::ListValue* args) { 526 const base::ListValue* args) {
531 CHECK_EQ(1U, args->GetSize()); 527 CHECK_EQ(1U, args->GetSize());
532 bool enabled; 528 bool enabled;
(...skipping 22 matching lines...) Expand all
555 bool logging_enabled = 551 bool logging_enabled =
556 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled); 552 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled);
557 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY 553 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY
558 : HotwordService::HOTWORD_AND_AUDIO_HISTORY; 554 : HotwordService::HOTWORD_AND_AUDIO_HISTORY;
559 } 555 }
560 hotword_service->OptIntoHotwording(launch_mode); 556 hotword_service->OptIntoHotwording(launch_mode);
561 SendHotwordInfo(); 557 SendHotwordInfo();
562 } 558 }
563 559
564 } // namespace settings 560 } // namespace settings
OLDNEW
« no previous file with comments | « no previous file | content/public/browser/web_ui_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698