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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 (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 <stddef.h> 7 #include <stddef.h>
8
9 #include <memory>
8 #include <utility> 10 #include <utility>
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
12 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_util.h" 23 #include "chrome/browser/extensions/extension_util.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 CHECK(value->GetAsBoolean(&bool_value)); 338 CHECK(value->GetAsBoolean(&bool_value));
338 metric_string += bool_value ? "_Enable" : "_Disable"; 339 metric_string += bool_value ? "_Enable" : "_Disable";
339 } 340 }
340 341
341 content::RecordComputedAction(metric_string); 342 content::RecordComputedAction(metric_string);
342 } 343 }
343 344
344 void CoreOptionsHandler::NotifyPrefChanged( 345 void CoreOptionsHandler::NotifyPrefChanged(
345 const std::string& pref_name, 346 const std::string& pref_name,
346 const std::string& controlling_pref_name) { 347 const std::string& controlling_pref_name) {
347 scoped_ptr<base::Value> value( 348 std::unique_ptr<base::Value> value(
348 CreateValueForPref(pref_name, controlling_pref_name)); 349 CreateValueForPref(pref_name, controlling_pref_name));
349 DispatchPrefChangeNotification(pref_name, std::move(value)); 350 DispatchPrefChangeNotification(pref_name, std::move(value));
350 } 351 }
351 352
352 void CoreOptionsHandler::DispatchPrefChangeNotification( 353 void CoreOptionsHandler::DispatchPrefChangeNotification(
353 const std::string& name, 354 const std::string& name,
354 scoped_ptr<base::Value> value) { 355 std::unique_ptr<base::Value> value) {
355 std::pair<PreferenceCallbackMap::const_iterator, 356 std::pair<PreferenceCallbackMap::const_iterator,
356 PreferenceCallbackMap::const_iterator> range = 357 PreferenceCallbackMap::const_iterator> range =
357 pref_callback_map_.equal_range(name); 358 pref_callback_map_.equal_range(name);
358 base::ListValue result_value; 359 base::ListValue result_value;
359 result_value.Append(new base::StringValue(name)); 360 result_value.Append(new base::StringValue(name));
360 result_value.Append(value.release()); 361 result_value.Append(value.release());
361 for (PreferenceCallbackMap::const_iterator iter = range.first; 362 for (PreferenceCallbackMap::const_iterator iter = range.first;
362 iter != range.second; ++iter) { 363 iter != range.second; ++iter) {
363 const std::string& callback_function = iter->second; 364 const std::string& callback_function = iter->second;
364 web_ui()->CallJavascriptFunction(callback_function, result_value); 365 web_ui()->CallJavascriptFunction(callback_function, result_value);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 DCHECK_GT(static_cast<int>(args->GetSize()), 1); 534 DCHECK_GT(static_cast<int>(args->GetSize()), 1);
534 535
535 std::string pref_name; 536 std::string pref_name;
536 if (!args->GetString(0, &pref_name)) 537 if (!args->GetString(0, &pref_name))
537 return; 538 return;
538 539
539 const base::Value* value; 540 const base::Value* value;
540 if (!args->Get(1, &value)) 541 if (!args->Get(1, &value))
541 return; 542 return;
542 543
543 scoped_ptr<base::Value> temp_value; 544 std::unique_ptr<base::Value> temp_value;
544 545
545 switch (type) { 546 switch (type) {
546 case TYPE_BOOLEAN: 547 case TYPE_BOOLEAN:
547 if (!value->IsType(base::Value::TYPE_BOOLEAN)) { 548 if (!value->IsType(base::Value::TYPE_BOOLEAN)) {
548 NOTREACHED(); 549 NOTREACHED();
549 return; 550 return;
550 } 551 }
551 break; 552 break;
552 case TYPE_INTEGER: { 553 case TYPE_INTEGER: {
553 // In JS all numbers are doubles. 554 // In JS all numbers are doubles.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled()); 657 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled());
657 web_ui()->CallJavascriptFunction( 658 web_ui()->CallJavascriptFunction(
658 "options.OptionsPage.setPepperFlashSettingsEnabled", enabled); 659 "options.OptionsPage.setPepperFlashSettingsEnabled", enabled);
659 } 660 }
660 661
661 bool CoreOptionsHandler::IsUserUnsupervised(const base::Value* to_value) { 662 bool CoreOptionsHandler::IsUserUnsupervised(const base::Value* to_value) {
662 return !Profile::FromWebUI(web_ui())->IsSupervised(); 663 return !Profile::FromWebUI(web_ui())->IsSupervised();
663 } 664 }
664 665
665 } // namespace options 666 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/core_options_handler.h ('k') | chrome/browser/ui/webui/options/create_profile_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698