| OLD | NEW |
| 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 Loading... |
| 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 std::unique_ptr<base::DictionaryValue> ConvertBoundsToValue( | 185 base::DictionaryValue* ConvertBoundsToValue(const gfx::Rect& bounds) { |
| 186 const gfx::Rect& bounds) { | 186 base::DictionaryValue* result = new base::DictionaryValue(); |
| 187 auto result = base::MakeUnique<base::DictionaryValue>(); | |
| 188 result->SetInteger("left", bounds.x()); | 187 result->SetInteger("left", bounds.x()); |
| 189 result->SetInteger("top", bounds.y()); | 188 result->SetInteger("top", bounds.y()); |
| 190 result->SetInteger("width", bounds.width()); | 189 result->SetInteger("width", bounds.width()); |
| 191 result->SetInteger("height", bounds.height()); | 190 result->SetInteger("height", bounds.height()); |
| 192 return result; | 191 return result; |
| 193 } | 192 } |
| 194 | 193 |
| 195 } // namespace | 194 } // namespace |
| 196 | 195 |
| 197 DisplayOptionsHandler::DisplayOptionsHandler() { | 196 DisplayOptionsHandler::DisplayOptionsHandler() { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 322 |
| 324 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 323 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 325 std::unique_ptr<base::ListValue> js_displays(new base::ListValue); | 324 std::unique_ptr<base::ListValue> js_displays(new base::ListValue); |
| 326 for (const display::Display& display : displays) { | 325 for (const display::Display& display : displays) { |
| 327 const display::ManagedDisplayInfo& display_info = | 326 const display::ManagedDisplayInfo& display_info = |
| 328 display_manager->GetDisplayInfo(display.id()); | 327 display_manager->GetDisplayInfo(display.id()); |
| 329 auto js_display = base::MakeUnique<base::DictionaryValue>(); | 328 auto js_display = base::MakeUnique<base::DictionaryValue>(); |
| 330 js_display->SetString("id", base::Int64ToString(display.id())); | 329 js_display->SetString("id", base::Int64ToString(display.id())); |
| 331 js_display->SetString("name", | 330 js_display->SetString("name", |
| 332 display_manager->GetDisplayNameForId(display.id())); | 331 display_manager->GetDisplayNameForId(display.id())); |
| 333 js_display->Set("bounds", ConvertBoundsToValue(display.bounds())); | 332 base::DictionaryValue* display_bounds = |
| 333 ConvertBoundsToValue(display.bounds()); |
| 334 js_display->Set("bounds", display_bounds); |
| 334 js_display->SetBoolean("isPrimary", display.id() == primary_id); | 335 js_display->SetBoolean("isPrimary", display.id() == primary_id); |
| 335 js_display->SetBoolean("isInternal", display.IsInternal()); | 336 js_display->SetBoolean("isInternal", display.IsInternal()); |
| 336 js_display->SetInteger("rotation", display.RotationAsDegree()); | 337 js_display->SetInteger("rotation", display.RotationAsDegree()); |
| 337 | 338 |
| 338 auto js_resolutions = base::MakeUnique<base::ListValue>(); | 339 base::ListValue* js_resolutions = new base::ListValue(); |
| 339 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : | 340 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : |
| 340 display_info.display_modes()) { | 341 display_info.display_modes()) { |
| 341 js_resolutions->Append( | 342 js_resolutions->Append( |
| 342 ConvertDisplayModeToValue(display.id(), display_mode)); | 343 ConvertDisplayModeToValue(display.id(), display_mode)); |
| 343 } | 344 } |
| 344 js_display->Set("resolutions", std::move(js_resolutions)); | 345 js_display->Set("resolutions", js_resolutions); |
| 345 | 346 |
| 346 js_display->SetInteger("colorProfileId", display_info.color_profile()); | 347 js_display->SetInteger("colorProfileId", display_info.color_profile()); |
| 347 auto available_color_profiles = base::MakeUnique<base::ListValue>(); | 348 base::ListValue* available_color_profiles = new base::ListValue(); |
| 348 for (const auto& color_profile : display_info.available_color_profiles()) { | 349 for (const auto& color_profile : display_info.available_color_profiles()) { |
| 349 const base::string16 profile_name = GetColorProfileName(color_profile); | 350 const base::string16 profile_name = GetColorProfileName(color_profile); |
| 350 if (profile_name.empty()) | 351 if (profile_name.empty()) |
| 351 continue; | 352 continue; |
| 352 auto color_profile_dict = base::MakeUnique<base::DictionaryValue>(); | 353 auto color_profile_dict = base::MakeUnique<base::DictionaryValue>(); |
| 353 color_profile_dict->SetInteger("profileId", color_profile); | 354 color_profile_dict->SetInteger("profileId", color_profile); |
| 354 color_profile_dict->SetString("name", profile_name); | 355 color_profile_dict->SetString("name", profile_name); |
| 355 available_color_profiles->Append(std::move(color_profile_dict)); | 356 available_color_profiles->Append(std::move(color_profile_dict)); |
| 356 } | 357 } |
| 357 js_display->Set("availableColorProfiles", | 358 js_display->Set("availableColorProfiles", available_color_profiles); |
| 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 Loading... |
| 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 |
| OLD | NEW |