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

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

Issue 1758013002: WebUI: Allow rejecting a promise that is returned from cr.sendWithPromise(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-rename Created 4 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/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 } 193 }
194 return dict; 194 return dict;
195 } 195 }
196 196
197 void SearchEnginesHandler::HandleGetSearchEnginesList( 197 void SearchEnginesHandler::HandleGetSearchEnginesList(
198 const base::ListValue* args) { 198 const base::ListValue* args) {
199 CHECK_EQ(1U, args->GetSize()); 199 CHECK_EQ(1U, args->GetSize());
200 const base::Value* callback_id; 200 const base::Value* callback_id;
201 CHECK(args->Get(0, &callback_id)); 201 CHECK(args->Get(0, &callback_id));
202 CallJavascriptCallback(*callback_id, *GetSearchEnginesList()); 202 ResolveJavascriptCallback(*callback_id, *GetSearchEnginesList());
203 } 203 }
204 204
205 void SearchEnginesHandler::HandleSetDefaultSearchEngine( 205 void SearchEnginesHandler::HandleSetDefaultSearchEngine(
206 const base::ListValue* args) { 206 const base::ListValue* args) {
207 int index; 207 int index;
208 if (!ExtractIntegerValue(args, &index)) { 208 if (!ExtractIntegerValue(args, &index)) {
209 NOTREACHED(); 209 NOTREACHED();
210 return; 210 return;
211 } 211 }
212 if (index < 0 || index >= list_controller_->table_model()->RowCount()) 212 if (index < 0 || index >= list_controller_->table_model()->RowCount())
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 void SearchEnginesHandler::HandleValidateSearchEngineInput( 271 void SearchEnginesHandler::HandleValidateSearchEngineInput(
272 const base::ListValue* args) { 272 const base::ListValue* args) {
273 CHECK_EQ(3U, args->GetSize()); 273 CHECK_EQ(3U, args->GetSize());
274 274
275 const base::Value* callback_id; 275 const base::Value* callback_id;
276 std::string field_name; 276 std::string field_name;
277 std::string field_value; 277 std::string field_value;
278 CHECK(args->Get(0, &callback_id)); 278 CHECK(args->Get(0, &callback_id));
279 CHECK(args->GetString(1, &field_name)); 279 CHECK(args->GetString(1, &field_name));
280 CHECK(args->GetString(2, &field_value)); 280 CHECK(args->GetString(2, &field_value));
281 CallJavascriptCallback( 281 ResolveJavascriptCallback(
282 *callback_id, 282 *callback_id,
283 base::FundamentalValue(CheckFieldValidity(field_name, field_value))); 283 base::FundamentalValue(CheckFieldValidity(field_name, field_value)));
284 } 284 }
285 285
286 bool SearchEnginesHandler::CheckFieldValidity(const std::string& field_name, 286 bool SearchEnginesHandler::CheckFieldValidity(const std::string& field_name,
287 const std::string& field_value) { 287 const std::string& field_value) {
288 if (!edit_controller_.get()) 288 if (!edit_controller_.get())
289 return false; 289 return false;
290 290
291 bool is_valid = false; 291 bool is_valid = false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 std::string extension_id; 335 std::string extension_id;
336 CHECK(args->GetString(0, &extension_id)); 336 CHECK(args->GetString(0, &extension_id));
337 ExtensionService* extension_service = 337 ExtensionService* extension_service =
338 extensions::ExtensionSystem::Get(profile_)->extension_service(); 338 extensions::ExtensionSystem::Get(profile_)->extension_service();
339 DCHECK(extension_service); 339 DCHECK(extension_service);
340 extension_service->DisableExtension( 340 extension_service->DisableExtension(
341 extension_id, extensions::Extension::DISABLE_USER_ACTION); 341 extension_id, extensions::Extension::DISABLE_USER_ACTION);
342 } 342 }
343 343
344 } // namespace settings 344 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_ui.cc ('k') | chrome/browser/ui/webui/settings/site_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698