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

Unified Diff: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: No ListValue::SetDouble Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
index 4ea500a53eead1f346aacc8c8c58ca38cf170927..b411a9e039bd06db51243a27b1562e9b96aa529a 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
@@ -182,8 +182,9 @@ std::unique_ptr<base::DictionaryValue> ConvertDisplayModeToValue(
return result;
}
-base::DictionaryValue* ConvertBoundsToValue(const gfx::Rect& bounds) {
- base::DictionaryValue* result = new base::DictionaryValue();
+std::unique_ptr<base::DictionaryValue> ConvertBoundsToValue(
+ const gfx::Rect& bounds) {
+ auto result = base::MakeUnique<base::DictionaryValue>();
result->SetInteger("left", bounds.x());
result->SetInteger("top", bounds.y());
result->SetInteger("width", bounds.width());
@@ -329,23 +330,21 @@ void DisplayOptionsHandler::SendAllDisplayInfo() {
js_display->SetString("id", base::Int64ToString(display.id()));
js_display->SetString("name",
display_manager->GetDisplayNameForId(display.id()));
- base::DictionaryValue* display_bounds =
- ConvertBoundsToValue(display.bounds());
- js_display->Set("bounds", display_bounds);
+ js_display->Set("bounds", ConvertBoundsToValue(display.bounds()));
js_display->SetBoolean("isPrimary", display.id() == primary_id);
js_display->SetBoolean("isInternal", display.IsInternal());
js_display->SetInteger("rotation", display.RotationAsDegree());
- base::ListValue* js_resolutions = new base::ListValue();
+ auto js_resolutions = base::MakeUnique<base::ListValue>();
for (const scoped_refptr<display::ManagedDisplayMode>& display_mode :
display_info.display_modes()) {
js_resolutions->Append(
ConvertDisplayModeToValue(display.id(), display_mode));
}
- js_display->Set("resolutions", js_resolutions);
+ js_display->Set("resolutions", std::move(js_resolutions));
js_display->SetInteger("colorProfileId", display_info.color_profile());
- base::ListValue* available_color_profiles = new base::ListValue();
+ auto available_color_profiles = base::MakeUnique<base::ListValue>();
for (const auto& color_profile : display_info.available_color_profiles()) {
const base::string16 profile_name = GetColorProfileName(color_profile);
if (profile_name.empty())
@@ -355,7 +354,8 @@ void DisplayOptionsHandler::SendAllDisplayInfo() {
color_profile_dict->SetString("name", profile_name);
available_color_profiles->Append(std::move(color_profile_dict));
}
- js_display->Set("availableColorProfiles", available_color_profiles);
+ js_display->Set("availableColorProfiles",
+ std::move(available_color_profiles));
if (display_manager->GetNumDisplays() > 1) {
// The settings UI must use the resolved display layout to show the

Powered by Google App Engine
This is Rietveld 408576698