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

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

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 "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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::StringValue("search-engines-changed"),
199 *GetSearchEnginesList()); 199 *GetSearchEnginesList());
200 // Google Now availability may have changed. 200 // Google Now availability may have changed.
201 CallJavascriptFunction( 201 CallJavascriptFunction("cr.webUIListenerCallback",
202 "cr.webUIListenerCallback", 202 base::StringValue("google-now-availability-changed"),
203 base::StringValue("google-now-availability-changed"), 203 base::Value(IsGoogleNowAvailable(profile_)));
204 base::FundamentalValue(IsGoogleNowAvailable(profile_)));
205 } 204 }
206 205
207 void SearchEnginesHandler::OnItemsChanged(int start, int length) { 206 void SearchEnginesHandler::OnItemsChanged(int start, int length) {
208 OnModelChanged(); 207 OnModelChanged();
209 } 208 }
210 209
211 void SearchEnginesHandler::OnItemsAdded(int start, int length) { 210 void SearchEnginesHandler::OnItemsAdded(int start, int length) {
212 OnModelChanged(); 211 OnModelChanged();
213 } 212 }
214 213
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 const base::ListValue* args) { 359 const base::ListValue* args) {
361 CHECK_EQ(3U, args->GetSize()); 360 CHECK_EQ(3U, args->GetSize());
362 361
363 const base::Value* callback_id; 362 const base::Value* callback_id;
364 std::string field_name; 363 std::string field_name;
365 std::string field_value; 364 std::string field_value;
366 CHECK(args->Get(0, &callback_id)); 365 CHECK(args->Get(0, &callback_id));
367 CHECK(args->GetString(1, &field_name)); 366 CHECK(args->GetString(1, &field_name));
368 CHECK(args->GetString(2, &field_value)); 367 CHECK(args->GetString(2, &field_value));
369 ResolveJavascriptCallback( 368 ResolveJavascriptCallback(
370 *callback_id, 369 *callback_id, base::Value(CheckFieldValidity(field_name, field_value)));
371 base::FundamentalValue(CheckFieldValidity(field_name, field_value)));
372 } 370 }
373 371
374 bool SearchEnginesHandler::CheckFieldValidity(const std::string& field_name, 372 bool SearchEnginesHandler::CheckFieldValidity(const std::string& field_name,
375 const std::string& field_value) { 373 const std::string& field_value) {
376 if (!edit_controller_.get()) 374 if (!edit_controller_.get())
377 return false; 375 return false;
378 376
379 bool is_valid = false; 377 bool is_valid = false;
380 if (field_name.compare(kSearchEngineField) == 0) 378 if (field_name.compare(kSearchEngineField) == 0)
381 is_valid = edit_controller_->IsTitleValid(base::UTF8ToUTF16(field_value)); 379 is_valid = edit_controller_->IsTitleValid(base::UTF8ToUTF16(field_value));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 weak_ptr_factory_.GetWeakPtr(), base::Passed(&callback_id), 445 weak_ptr_factory_.GetWeakPtr(), base::Passed(&callback_id),
448 base::Passed(&status))); 446 base::Passed(&status)));
449 } 447 }
450 448
451 void SearchEnginesHandler::HandleGetGoogleNowAvailability( 449 void SearchEnginesHandler::HandleGetGoogleNowAvailability(
452 const base::ListValue* args) { 450 const base::ListValue* args) {
453 CHECK_EQ(1U, args->GetSize()); 451 CHECK_EQ(1U, args->GetSize());
454 const base::Value* callback_id; 452 const base::Value* callback_id;
455 CHECK(args->Get(0, &callback_id)); 453 CHECK(args->Get(0, &callback_id));
456 AllowJavascript(); 454 AllowJavascript();
457 ResolveJavascriptCallback( 455 ResolveJavascriptCallback(*callback_id,
458 *callback_id, base::FundamentalValue(IsGoogleNowAvailable(profile_))); 456 base::Value(IsGoogleNowAvailable(profile_)));
459 } 457 }
460 458
461 std::unique_ptr<base::DictionaryValue> SearchEnginesHandler::GetHotwordInfo() { 459 std::unique_ptr<base::DictionaryValue> SearchEnginesHandler::GetHotwordInfo() {
462 auto status = base::MakeUnique<base::DictionaryValue>(); 460 auto status = base::MakeUnique<base::DictionaryValue>();
463 if (!IsGoogleDefaultSearch(profile_)) { 461 if (!IsGoogleDefaultSearch(profile_)) {
464 status->SetBoolean(kHotwordSatusAllowed, false); 462 status->SetBoolean(kHotwordSatusAllowed, false);
465 return status; 463 return status;
466 } 464 }
467 465
468 status->SetBoolean(kHotwordSatusAllowed, 466 status->SetBoolean(kHotwordSatusAllowed,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 bool logging_enabled = 555 bool logging_enabled =
558 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled); 556 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled);
559 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY 557 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY
560 : HotwordService::HOTWORD_AND_AUDIO_HISTORY; 558 : HotwordService::HOTWORD_AND_AUDIO_HISTORY;
561 } 559 }
562 hotword_service->OptIntoHotwording(launch_mode); 560 hotword_service->OptIntoHotwording(launch_mode);
563 SendHotwordInfo(); 561 SendHotwordInfo();
564 } 562 }
565 563
566 } // namespace settings 564 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698