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

Side by Side Diff: chrome/browser/ui/webui/options/core_options_handler.cc

Issue 11415226: webui/options: Do not use Value::CreateStringValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/options/core_options_handler.h" 5 #include "chrome/browser/ui/webui/options/core_options_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 DispatchPrefChangeNotification(pref_name, value.Pass()); 278 DispatchPrefChangeNotification(pref_name, value.Pass());
279 } 279 }
280 280
281 void CoreOptionsHandler::DispatchPrefChangeNotification( 281 void CoreOptionsHandler::DispatchPrefChangeNotification(
282 const std::string& name, 282 const std::string& name,
283 scoped_ptr<base::Value> value) { 283 scoped_ptr<base::Value> value) {
284 std::pair<PreferenceCallbackMap::const_iterator, 284 std::pair<PreferenceCallbackMap::const_iterator,
285 PreferenceCallbackMap::const_iterator> range = 285 PreferenceCallbackMap::const_iterator> range =
286 pref_callback_map_.equal_range(name); 286 pref_callback_map_.equal_range(name);
287 ListValue result_value; 287 ListValue result_value;
288 result_value.Append(base::Value::CreateStringValue(name.c_str())); 288 result_value.Append(new base::StringValue(name.c_str()));
289 result_value.Append(value.release()); 289 result_value.Append(value.release());
290 for (PreferenceCallbackMap::const_iterator iter = range.first; 290 for (PreferenceCallbackMap::const_iterator iter = range.first;
291 iter != range.second; ++iter) { 291 iter != range.second; ++iter) {
292 const std::string& callback_function = iter->second; 292 const std::string& callback_function = iter->second;
293 web_ui()->CallJavascriptFunction(callback_function, result_value); 293 web_ui()->CallJavascriptFunction(callback_function, result_value);
294 } 294 }
295 } 295 }
296 296
297 base::Value* CoreOptionsHandler::CreateValueForPref( 297 base::Value* CoreOptionsHandler::CreateValueForPref(
298 const std::string& pref_name, 298 const std::string& pref_name,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 case TYPE_DOUBLE: 470 case TYPE_DOUBLE:
471 CHECK_EQ(base::Value::TYPE_DOUBLE, value->GetType()); 471 CHECK_EQ(base::Value::TYPE_DOUBLE, value->GetType());
472 break; 472 break;
473 case TYPE_STRING: 473 case TYPE_STRING:
474 CHECK_EQ(base::Value::TYPE_STRING, value->GetType()); 474 CHECK_EQ(base::Value::TYPE_STRING, value->GetType());
475 break; 475 break;
476 case TYPE_URL: { 476 case TYPE_URL: {
477 std::string original; 477 std::string original;
478 CHECK(value->GetAsString(&original)); 478 CHECK(value->GetAsString(&original));
479 GURL fixed = URLFixerUpper::FixupURL(original, std::string()); 479 GURL fixed = URLFixerUpper::FixupURL(original, std::string());
480 temp_value.reset(base::Value::CreateStringValue(fixed.spec())); 480 temp_value.reset(new base::StringValue(fixed.spec()));
481 value = temp_value.get(); 481 value = temp_value.get();
482 break; 482 break;
483 } 483 }
484 case TYPE_LIST: { 484 case TYPE_LIST: {
485 // In case we have a List pref we got a JSON string. 485 // In case we have a List pref we got a JSON string.
486 std::string json_string; 486 std::string json_string;
487 CHECK(value->GetAsString(&json_string)); 487 CHECK(value->GetAsString(&json_string));
488 temp_value.reset( 488 temp_value.reset(
489 base::JSONReader::Read(json_string)); 489 base::JSONReader::Read(json_string));
490 value = temp_value.get(); 490 value = temp_value.get();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { 534 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() {
535 scoped_ptr<base::Value> enabled( 535 scoped_ptr<base::Value> enabled(
536 base::Value::CreateBooleanValue( 536 base::Value::CreateBooleanValue(
537 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled())); 537 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled()));
538 web_ui()->CallJavascriptFunction( 538 web_ui()->CallJavascriptFunction(
539 "OptionsPage.setPepperFlashSettingsEnabled", *enabled); 539 "OptionsPage.setPepperFlashSettingsEnabled", *enabled);
540 } 540 }
541 541
542 } // namespace options 542 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698