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

Side by Side 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 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/chromeos/display_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/display_options_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 result->SetBoolean("isBest", 175 result->SetBoolean("isBest",
176 is_internal ? (mode->ui_scale() == 1.0f) : mode->native()); 176 is_internal ? (mode->ui_scale() == 1.0f) : mode->native());
177 result->SetBoolean("isNative", mode->native()); 177 result->SetBoolean("isNative", mode->native());
178 result->SetBoolean( 178 result->SetBoolean(
179 "selected", 179 "selected",
180 mode->IsEquivalent( 180 mode->IsEquivalent(
181 GetDisplayManager()->GetActiveModeForDisplayId(display_id))); 181 GetDisplayManager()->GetActiveModeForDisplayId(display_id)));
182 return result; 182 return result;
183 } 183 }
184 184
185 base::DictionaryValue* ConvertBoundsToValue(const gfx::Rect& bounds) { 185 std::unique_ptr<base::DictionaryValue> ConvertBoundsToValue(
186 base::DictionaryValue* result = new base::DictionaryValue(); 186 const gfx::Rect& bounds) {
187 auto result = base::MakeUnique<base::DictionaryValue>();
187 result->SetInteger("left", bounds.x()); 188 result->SetInteger("left", bounds.x());
188 result->SetInteger("top", bounds.y()); 189 result->SetInteger("top", bounds.y());
189 result->SetInteger("width", bounds.width()); 190 result->SetInteger("width", bounds.width());
190 result->SetInteger("height", bounds.height()); 191 result->SetInteger("height", bounds.height());
191 return result; 192 return result;
192 } 193 }
193 194
194 } // namespace 195 } // namespace
195 196
196 DisplayOptionsHandler::DisplayOptionsHandler() { 197 DisplayOptionsHandler::DisplayOptionsHandler() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 323
323 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 324 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
324 std::unique_ptr<base::ListValue> js_displays(new base::ListValue); 325 std::unique_ptr<base::ListValue> js_displays(new base::ListValue);
325 for (const display::Display& display : displays) { 326 for (const display::Display& display : displays) {
326 const display::ManagedDisplayInfo& display_info = 327 const display::ManagedDisplayInfo& display_info =
327 display_manager->GetDisplayInfo(display.id()); 328 display_manager->GetDisplayInfo(display.id());
328 auto js_display = base::MakeUnique<base::DictionaryValue>(); 329 auto js_display = base::MakeUnique<base::DictionaryValue>();
329 js_display->SetString("id", base::Int64ToString(display.id())); 330 js_display->SetString("id", base::Int64ToString(display.id()));
330 js_display->SetString("name", 331 js_display->SetString("name",
331 display_manager->GetDisplayNameForId(display.id())); 332 display_manager->GetDisplayNameForId(display.id()));
332 base::DictionaryValue* display_bounds = 333 js_display->Set("bounds", ConvertBoundsToValue(display.bounds()));
333 ConvertBoundsToValue(display.bounds());
334 js_display->Set("bounds", display_bounds);
335 js_display->SetBoolean("isPrimary", display.id() == primary_id); 334 js_display->SetBoolean("isPrimary", display.id() == primary_id);
336 js_display->SetBoolean("isInternal", display.IsInternal()); 335 js_display->SetBoolean("isInternal", display.IsInternal());
337 js_display->SetInteger("rotation", display.RotationAsDegree()); 336 js_display->SetInteger("rotation", display.RotationAsDegree());
338 337
339 base::ListValue* js_resolutions = new base::ListValue(); 338 auto js_resolutions = base::MakeUnique<base::ListValue>();
340 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : 339 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode :
341 display_info.display_modes()) { 340 display_info.display_modes()) {
342 js_resolutions->Append( 341 js_resolutions->Append(
343 ConvertDisplayModeToValue(display.id(), display_mode)); 342 ConvertDisplayModeToValue(display.id(), display_mode));
344 } 343 }
345 js_display->Set("resolutions", js_resolutions); 344 js_display->Set("resolutions", std::move(js_resolutions));
346 345
347 js_display->SetInteger("colorProfileId", display_info.color_profile()); 346 js_display->SetInteger("colorProfileId", display_info.color_profile());
348 base::ListValue* available_color_profiles = new base::ListValue(); 347 auto available_color_profiles = base::MakeUnique<base::ListValue>();
349 for (const auto& color_profile : display_info.available_color_profiles()) { 348 for (const auto& color_profile : display_info.available_color_profiles()) {
350 const base::string16 profile_name = GetColorProfileName(color_profile); 349 const base::string16 profile_name = GetColorProfileName(color_profile);
351 if (profile_name.empty()) 350 if (profile_name.empty())
352 continue; 351 continue;
353 auto color_profile_dict = base::MakeUnique<base::DictionaryValue>(); 352 auto color_profile_dict = base::MakeUnique<base::DictionaryValue>();
354 color_profile_dict->SetInteger("profileId", color_profile); 353 color_profile_dict->SetInteger("profileId", color_profile);
355 color_profile_dict->SetString("name", profile_name); 354 color_profile_dict->SetString("name", profile_name);
356 available_color_profiles->Append(std::move(color_profile_dict)); 355 available_color_profiles->Append(std::move(color_profile_dict));
357 } 356 }
358 js_display->Set("availableColorProfiles", available_color_profiles); 357 js_display->Set("availableColorProfiles",
358 std::move(available_color_profiles));
359 359
360 if (display_manager->GetNumDisplays() > 1) { 360 if (display_manager->GetNumDisplays() > 1) {
361 // The settings UI must use the resolved display layout to show the 361 // The settings UI must use the resolved display layout to show the
362 // actual applied layout. 362 // actual applied layout.
363 const display::DisplayPlacement placement = 363 const display::DisplayPlacement placement =
364 display_manager->GetCurrentResolvedDisplayLayout().FindPlacementById( 364 display_manager->GetCurrentResolvedDisplayLayout().FindPlacementById(
365 display.id()); 365 display.id());
366 if (placement.display_id != display::kInvalidDisplayId) { 366 if (placement.display_id != display::kInvalidDisplayId) {
367 js_display->SetString( 367 js_display->SetString(
368 "parentId", base::Int64ToString(placement.parent_display_id)); 368 "parentId", base::Int64ToString(placement.parent_display_id));
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (!args->GetBoolean(0, &enable)) 569 if (!args->GetBoolean(0, &enable))
570 NOTREACHED(); 570 NOTREACHED();
571 571
572 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( 572 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays(
573 enable ? display::DisplayManager::UNIFIED 573 enable ? display::DisplayManager::UNIFIED
574 : display::DisplayManager::EXTENDED); 574 : display::DisplayManager::EXTENDED);
575 } 575 }
576 576
577 } // namespace options 577 } // namespace options
578 } // namespace chromeos 578 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698