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

Side by Side Diff: chrome/browser/chromeos/display/display_preferences.cc

Issue 2765363004: Stop passing raw pointers to DictionaryValue::Set, part 2 (Closed)
Patch Set: Fix comments 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 (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/chromeos/display/display_preferences.h" 5 #include "chrome/browser/chromeos/display/display_preferences.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 PrefService* local_state = g_browser_process->local_state(); 308 PrefService* local_state = g_browser_process->local_state();
309 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); 309 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays);
310 base::DictionaryValue* pref_data = update.Get(); 310 base::DictionaryValue* pref_data = update.Get();
311 std::unique_ptr<base::Value> layout_value(new base::DictionaryValue()); 311 std::unique_ptr<base::Value> layout_value(new base::DictionaryValue());
312 if (pref_data->HasKey(name)) { 312 if (pref_data->HasKey(name)) {
313 base::Value* value = nullptr; 313 base::Value* value = nullptr;
314 if (pref_data->Get(name, &value) && value != nullptr) 314 if (pref_data->Get(name, &value) && value != nullptr)
315 layout_value.reset(value->DeepCopy()); 315 layout_value.reset(value->DeepCopy());
316 } 316 }
317 if (display::DisplayLayoutToJson(display_layout, layout_value.get())) 317 if (display::DisplayLayoutToJson(display_layout, layout_value.get()))
318 pref_data->Set(name, layout_value.release()); 318 pref_data->Set(name, std::move(layout_value));
319 } 319 }
320 320
321 void StoreCurrentDisplayLayoutPrefs() { 321 void StoreCurrentDisplayLayoutPrefs() {
322 display::DisplayManager* display_manager = GetDisplayManager(); 322 display::DisplayManager* display_manager = GetDisplayManager();
323 if (!UserCanSaveDisplayPreference() || 323 if (!UserCanSaveDisplayPreference() ||
324 display_manager->num_connected_displays() < 2) { 324 display_manager->num_connected_displays() < 2) {
325 return; 325 return;
326 } 326 }
327 327
328 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); 328 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 static_cast<int>(mode->device_scale_factor() * 1000)); 366 static_cast<int>(mode->device_scale_factor() * 1000));
367 } 367 }
368 if (!info.overscan_insets_in_dip().IsEmpty()) 368 if (!info.overscan_insets_in_dip().IsEmpty())
369 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); 369 InsetsToValue(info.overscan_insets_in_dip(), property_value.get());
370 if (info.color_profile() != display::COLOR_PROFILE_STANDARD) { 370 if (info.color_profile() != display::COLOR_PROFILE_STANDARD) {
371 property_value->SetString( 371 property_value->SetString(
372 "color_profile_name", ColorProfileToString(info.color_profile())); 372 "color_profile_name", ColorProfileToString(info.color_profile()));
373 } 373 }
374 if (info.has_touch_calibration_data()) 374 if (info.has_touch_calibration_data())
375 TouchDataToValue(info.GetTouchCalibrationData(), property_value.get()); 375 TouchDataToValue(info.GetTouchCalibrationData(), property_value.get());
376 pref_data->Set(base::Int64ToString(id), property_value.release()); 376 pref_data->Set(base::Int64ToString(id), std::move(property_value));
377 } 377 }
378 } 378 }
379 379
380 typedef std::map<chromeos::DisplayPowerState, std::string> 380 typedef std::map<chromeos::DisplayPowerState, std::string>
381 DisplayPowerStateToStringMap; 381 DisplayPowerStateToStringMap;
382 382
383 const DisplayPowerStateToStringMap* GetDisplayPowerStateToStringMap() { 383 const DisplayPowerStateToStringMap* GetDisplayPowerStateToStringMap() {
384 // Don't save or retore ALL_OFF state. crbug.com/318456. 384 // Don't save or retore ALL_OFF state. crbug.com/318456.
385 static const DisplayPowerStateToStringMap* map = display::CreateToStringMap( 385 static const DisplayPowerStateToStringMap* map = display::CreateToStringMap(
386 chromeos::DISPLAY_POWER_ALL_ON, "all_on", 386 chromeos::DISPLAY_POWER_ALL_ON, "all_on",
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 StoreDisplayPowerState(power_state); 491 StoreDisplayPowerState(power_state);
492 } 492 }
493 493
494 bool ParseTouchCalibrationStringForTest( 494 bool ParseTouchCalibrationStringForTest(
495 const std::string& str, 495 const std::string& str,
496 display::TouchCalibrationData::CalibrationPointPairQuad* point_pair_quad) { 496 display::TouchCalibrationData::CalibrationPointPairQuad* point_pair_quad) {
497 return ParseTouchCalibrationStringValue(str, point_pair_quad); 497 return ParseTouchCalibrationStringValue(str, point_pair_quad);
498 } 498 }
499 499
500 } // namespace chromeos 500 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698