| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/display_info_provider_chromeos.h" | 5 #include "chrome/browser/extensions/display_info_provider_chromeos.h" | 
| 6 | 6 | 
| 7 #include <stdint.h> | 7 #include <stdint.h> | 
| 8 | 8 | 
| 9 #include "ash/display/display_configuration_controller.h" | 9 #include "ash/display/display_configuration_controller.h" | 
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" | 
| 11 #include "ash/display/resolution_notification_controller.h" | 11 #include "ash/display/resolution_notification_controller.h" | 
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" | 
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" | 
| 14 #include "chrome/browser/chromeos/display/display_preferences.h" | 14 #include "chrome/browser/chromeos/display/display_preferences.h" | 
| 15 #include "chrome/browser/chromeos/display/overscan_calibrator.h" | 15 #include "chrome/browser/chromeos/display/overscan_calibrator.h" | 
| 16 #include "extensions/common/api/system_display.h" | 16 #include "extensions/common/api/system_display.h" | 
| 17 #include "ui/display/display.h" | 17 #include "ui/display/display.h" | 
| 18 #include "ui/display/manager/display_layout.h" | 18 #include "ui/display/manager/display_layout.h" | 
|  | 19 #include "ui/display/manager/display_layout_builder.h" | 
| 19 #include "ui/gfx/geometry/point.h" | 20 #include "ui/gfx/geometry/point.h" | 
| 20 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" | 
| 21 | 22 | 
| 22 namespace extensions { | 23 namespace extensions { | 
| 23 | 24 | 
| 24 using api::system_display::Bounds; | 25 namespace system_display = api::system_display; | 
| 25 using api::system_display::DisplayUnitInfo; |  | 
| 26 using api::system_display::DisplayProperties; |  | 
| 27 using api::system_display::Insets; |  | 
| 28 | 26 | 
| 29 namespace { | 27 namespace { | 
| 30 | 28 | 
| 31 // Maximum allowed bounds origin absolute value. | 29 // Maximum allowed bounds origin absolute value. | 
| 32 const int kMaxBoundsOrigin = 200 * 1000; | 30 const int kMaxBoundsOrigin = 200 * 1000; | 
| 33 | 31 | 
| 34 // Gets the display with the provided string id. | 32 // Gets the display with the provided string id. | 
| 35 display::Display GetDisplay(const std::string& display_id_str) { | 33 display::Display GetDisplay(const std::string& display_id_str) { | 
| 36   int64_t display_id; | 34   int64_t display_id; | 
| 37   if (!base::StringToInt64(display_id_str, &display_id)) | 35   if (!base::StringToInt64(display_id_str, &display_id)) | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 55       return display::Display::ROTATE_90; | 53       return display::Display::ROTATE_90; | 
| 56     case 180: | 54     case 180: | 
| 57       return display::Display::ROTATE_180; | 55       return display::Display::ROTATE_180; | 
| 58     case 270: | 56     case 270: | 
| 59       return display::Display::ROTATE_270; | 57       return display::Display::ROTATE_270; | 
| 60     default: | 58     default: | 
| 61       return display::Display::ROTATE_0; | 59       return display::Display::ROTATE_0; | 
| 62   } | 60   } | 
| 63 } | 61 } | 
| 64 | 62 | 
|  | 63 // Converts system_display::LayoutPosition to | 
|  | 64 // display::DisplayPlacement::Position. | 
|  | 65 display::DisplayPlacement::Position GetDisplayPlacementPosition( | 
|  | 66     system_display::LayoutPosition position) { | 
|  | 67   switch (position) { | 
|  | 68     case system_display::LAYOUT_POSITION_TOP: | 
|  | 69       return display::DisplayPlacement::TOP; | 
|  | 70     case system_display::LAYOUT_POSITION_BOTTOM: | 
|  | 71       return display::DisplayPlacement::BOTTOM; | 
|  | 72     case system_display::LAYOUT_POSITION_LEFT: | 
|  | 73       return display::DisplayPlacement::LEFT; | 
|  | 74     case system_display::LAYOUT_POSITION_RIGHT: | 
|  | 75     default: | 
|  | 76       // Default: layout to the right. | 
|  | 77       return display::DisplayPlacement::RIGHT; | 
|  | 78   } | 
|  | 79 } | 
|  | 80 | 
|  | 81 // Converts display::DisplayPlacement::Position to | 
|  | 82 // system_display::LayoutPosition. | 
|  | 83 system_display::LayoutPosition GetLayoutPosition( | 
|  | 84     display::DisplayPlacement::Position position) { | 
|  | 85   switch (position) { | 
|  | 86     case display::DisplayPlacement::TOP: | 
|  | 87       return system_display::LayoutPosition::LAYOUT_POSITION_TOP; | 
|  | 88     case display::DisplayPlacement::RIGHT: | 
|  | 89       return system_display::LayoutPosition::LAYOUT_POSITION_RIGHT; | 
|  | 90     case display::DisplayPlacement::BOTTOM: | 
|  | 91       return system_display::LayoutPosition::LAYOUT_POSITION_BOTTOM; | 
|  | 92     case display::DisplayPlacement::LEFT: | 
|  | 93       return system_display::LayoutPosition::LAYOUT_POSITION_LEFT; | 
|  | 94   } | 
|  | 95   return system_display::LayoutPosition::LAYOUT_POSITION_NONE; | 
|  | 96 } | 
|  | 97 | 
| 65 // Checks if the given point is over the radius vector described by it's end | 98 // Checks if the given point is over the radius vector described by it's end | 
| 66 // point |vector|. The point is over a vector if it's on its positive (left) | 99 // point |vector|. The point is over a vector if it's on its positive (left) | 
| 67 // side. The method sees a point on the same line as the vector as being over | 100 // side. The method sees a point on the same line as the vector as being over | 
| 68 // the vector. | 101 // the vector. | 
| 69 bool PointIsOverRadiusVector(const gfx::Point& point, | 102 bool PointIsOverRadiusVector(const gfx::Point& point, | 
| 70                              const gfx::Point& vector) { | 103                              const gfx::Point& vector) { | 
| 71   // |point| is left of |vector| if its radius vector's scalar product with a | 104   // |point| is left of |vector| if its radius vector's scalar product with a | 
| 72   // vector orthogonal (and facing the positive side) to |vector| is positive. | 105   // vector orthogonal (and facing the positive side) to |vector| is positive. | 
| 73   // | 106   // | 
| 74   // An orthogonal vector of (a, b) is (b, -a), as the scalar product of these | 107   // An orthogonal vector of (a, b) is (b, -a), as the scalar product of these | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 186 | 219 | 
| 187   ash::Shell::GetInstance() | 220   ash::Shell::GetInstance() | 
| 188       ->display_configuration_controller() | 221       ->display_configuration_controller() | 
| 189       ->SetDisplayLayout(std::move(layout), true /* user_action */); | 222       ->SetDisplayLayout(std::move(layout), true /* user_action */); | 
| 190 } | 223 } | 
| 191 | 224 | 
| 192 // Validates that parameters passed to the SetInfo function are valid for the | 225 // Validates that parameters passed to the SetInfo function are valid for the | 
| 193 // desired display and the current display manager state. | 226 // desired display and the current display manager state. | 
| 194 // Returns whether the parameters are valid. On failure |error| is set to the | 227 // Returns whether the parameters are valid. On failure |error| is set to the | 
| 195 // error message. | 228 // error message. | 
| 196 bool ValidateParamsForDisplay(const DisplayProperties& info, | 229 bool ValidateParamsForDisplay(const system_display::DisplayProperties& info, | 
| 197                               const display::Display& display, | 230                               const display::Display& display, | 
| 198                               ash::DisplayManager* display_manager, | 231                               ash::DisplayManager* display_manager, | 
| 199                               int64_t primary_display_id, | 232                               int64_t primary_display_id, | 
| 200                               std::string* error) { | 233                               std::string* error) { | 
| 201   int64_t id = display.id(); | 234   int64_t id = display.id(); | 
| 202   bool is_primary = | 235   bool is_primary = | 
| 203       id == primary_display_id || (info.is_primary && *info.is_primary); | 236       id == primary_display_id || (info.is_primary && *info.is_primary); | 
| 204 | 237 | 
| 205   // If mirroring source id is set, a display with the given id should exist, | 238   // If mirroring source id is set, a display with the given id should exist, | 
| 206   // and if should not be the same as the target display's id. | 239   // and if should not be the same as the target display's id. | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 312       // change. | 345       // change. | 
| 313       ash::Shell::GetInstance() | 346       ash::Shell::GetInstance() | 
| 314           ->resolution_notification_controller() | 347           ->resolution_notification_controller() | 
| 315           ->PrepareNotification(id, current_mode, new_mode, | 348           ->PrepareNotification(id, current_mode, new_mode, | 
| 316                                 base::Bind(&chromeos::StoreDisplayPrefs)); | 349                                 base::Bind(&chromeos::StoreDisplayPrefs)); | 
| 317     } | 350     } | 
| 318   } | 351   } | 
| 319   return true; | 352   return true; | 
| 320 } | 353 } | 
| 321 | 354 | 
| 322 extensions::api::system_display::DisplayMode GetDisplayMode( | 355 system_display::DisplayMode GetDisplayMode( | 
| 323     ash::DisplayManager* display_manager, | 356     ash::DisplayManager* display_manager, | 
| 324     const ash::DisplayInfo& display_info, | 357     const ash::DisplayInfo& display_info, | 
| 325     const ash::DisplayMode& display_mode) { | 358     const ash::DisplayMode& display_mode) { | 
| 326   extensions::api::system_display::DisplayMode result; | 359   system_display::DisplayMode result; | 
| 327 | 360 | 
| 328   bool is_internal = display::Display::HasInternalDisplay() && | 361   bool is_internal = display::Display::HasInternalDisplay() && | 
| 329                      display::Display::InternalDisplayId() == display_info.id(); | 362                      display::Display::InternalDisplayId() == display_info.id(); | 
| 330   gfx::Size size_dip = display_mode.GetSizeInDIP(is_internal); | 363   gfx::Size size_dip = display_mode.GetSizeInDIP(is_internal); | 
| 331   result.width = size_dip.width(); | 364   result.width = size_dip.width(); | 
| 332   result.height = size_dip.height(); | 365   result.height = size_dip.height(); | 
| 333   result.width_in_native_pixels = display_mode.size.width(); | 366   result.width_in_native_pixels = display_mode.size.width(); | 
| 334   result.height_in_native_pixels = display_mode.size.height(); | 367   result.height_in_native_pixels = display_mode.size.height(); | 
| 335   result.ui_scale = display_mode.ui_scale; | 368   result.ui_scale = display_mode.ui_scale; | 
| 336   result.device_scale_factor = display_mode.device_scale_factor; | 369   result.device_scale_factor = display_mode.device_scale_factor; | 
| 337   result.is_native = display_mode.native; | 370   result.is_native = display_mode.native; | 
| 338   result.is_selected = display_mode.IsEquivalent( | 371   result.is_selected = display_mode.IsEquivalent( | 
| 339       display_manager->GetActiveModeForDisplayId(display_info.id())); | 372       display_manager->GetActiveModeForDisplayId(display_info.id())); | 
| 340   return result; | 373   return result; | 
| 341 } | 374 } | 
| 342 | 375 | 
| 343 }  // namespace | 376 }  // namespace | 
| 344 | 377 | 
| 345 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() { | 378 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} | 
| 346 } |  | 
| 347 | 379 | 
| 348 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() { | 380 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} | 
| 349 } |  | 
| 350 | 381 | 
| 351 bool DisplayInfoProviderChromeOS::SetInfo(const std::string& display_id_str, | 382 bool DisplayInfoProviderChromeOS::SetInfo( | 
| 352                                           const DisplayProperties& info, | 383     const std::string& display_id_str, | 
| 353                                           std::string* error) { | 384     const system_display::DisplayProperties& info, | 
|  | 385     std::string* error) { | 
| 354   ash::DisplayManager* display_manager = | 386   ash::DisplayManager* display_manager = | 
| 355       ash::Shell::GetInstance()->display_manager(); | 387       ash::Shell::GetInstance()->display_manager(); | 
| 356   ash::DisplayConfigurationController* display_configuration_controller = | 388   ash::DisplayConfigurationController* display_configuration_controller = | 
| 357       ash::Shell::GetInstance()->display_configuration_controller(); | 389       ash::Shell::GetInstance()->display_configuration_controller(); | 
| 358 | 390 | 
| 359   const display::Display target = GetDisplay(display_id_str); | 391   const display::Display target = GetDisplay(display_id_str); | 
| 360 | 392 | 
| 361   if (target.id() == display::Display::kInvalidDisplayID) { | 393   if (target.id() == display::Display::kInvalidDisplayID) { | 
| 362     *error = "Display not found."; | 394     *error = "Display not found."; | 
| 363     return false; | 395     return false; | 
| 364   } | 396   } | 
| 365 | 397 | 
| 366   int64_t display_id = target.id(); | 398   int64_t display_id = target.id(); | 
| 367   const display::Display& primary = | 399   const display::Display& primary = | 
| 368       display::Screen::GetScreen()->GetPrimaryDisplay(); | 400       display::Screen::GetScreen()->GetPrimaryDisplay(); | 
| 369 | 401 | 
| 370   if (!ValidateParamsForDisplay( | 402   if (!ValidateParamsForDisplay(info, target, display_manager, primary.id(), | 
| 371           info, target, display_manager, primary.id(), error)) { | 403                                 error)) { | 
| 372     return false; | 404     return false; | 
| 373   } | 405   } | 
| 374 | 406 | 
| 375   // Process 'isPrimary' parameter. | 407   // Process 'isPrimary' parameter. | 
| 376   if (info.is_primary && *info.is_primary && target.id() != primary.id()) { | 408   if (info.is_primary && *info.is_primary && target.id() != primary.id()) { | 
| 377     display_configuration_controller->SetPrimaryDisplayId( | 409     display_configuration_controller->SetPrimaryDisplayId( | 
| 378         display_id, true /* user_action */); | 410         display_id, true /* user_action */); | 
| 379   } | 411   } | 
| 380 | 412 | 
| 381   // Process 'mirroringSourceId' parameter. | 413   // Process 'mirroringSourceId' parameter. | 
| 382   if (info.mirroring_source_id) { | 414   if (info.mirroring_source_id) { | 
| 383     bool mirror = !info.mirroring_source_id->empty(); | 415     bool mirror = !info.mirroring_source_id->empty(); | 
| 384     display_configuration_controller->SetMirrorMode(mirror, | 416     display_configuration_controller->SetMirrorMode(mirror, | 
| 385                                                     true /* user_action */); | 417                                                     true /* user_action */); | 
| 386   } | 418   } | 
| 387 | 419 | 
| 388   // Process 'overscan' parameter. | 420   // Process 'overscan' parameter. | 
| 389   if (info.overscan) { | 421   if (info.overscan) { | 
| 390     display_manager->SetOverscanInsets(display_id, | 422     display_manager->SetOverscanInsets( | 
| 391                                        gfx::Insets(info.overscan->top, | 423         display_id, gfx::Insets(info.overscan->top, info.overscan->left, | 
| 392                                                    info.overscan->left, | 424                                 info.overscan->bottom, info.overscan->right)); | 
| 393                                                    info.overscan->bottom, |  | 
| 394                                                    info.overscan->right)); |  | 
| 395   } | 425   } | 
| 396 | 426 | 
| 397   // Process 'rotation' parameter. | 427   // Process 'rotation' parameter. | 
| 398   if (info.rotation) { | 428   if (info.rotation) { | 
| 399     display_configuration_controller->SetDisplayRotation( | 429     display_configuration_controller->SetDisplayRotation( | 
| 400         display_id, DegreesToRotation(*info.rotation), | 430         display_id, DegreesToRotation(*info.rotation), | 
| 401         display::Display::ROTATION_SOURCE_ACTIVE, true /* user_action */); | 431         display::Display::ROTATION_SOURCE_ACTIVE, true /* user_action */); | 
| 402   } | 432   } | 
| 403 | 433 | 
| 404   // Process new display origin parameters. | 434   // Process new display origin parameters. | 
| 405   gfx::Point new_bounds_origin = target.bounds().origin(); | 435   gfx::Point new_bounds_origin = target.bounds().origin(); | 
| 406   if (info.bounds_origin_x) | 436   if (info.bounds_origin_x) | 
| 407     new_bounds_origin.set_x(*info.bounds_origin_x); | 437     new_bounds_origin.set_x(*info.bounds_origin_x); | 
| 408   if (info.bounds_origin_y) | 438   if (info.bounds_origin_y) | 
| 409     new_bounds_origin.set_y(*info.bounds_origin_y); | 439     new_bounds_origin.set_y(*info.bounds_origin_y); | 
| 410 | 440 | 
| 411   if (new_bounds_origin != target.bounds().origin()) { | 441   if (new_bounds_origin != target.bounds().origin()) { | 
| 412     gfx::Rect target_bounds = target.bounds(); | 442     gfx::Rect target_bounds = target.bounds(); | 
| 413     target_bounds.Offset(new_bounds_origin.x() - target.bounds().x(), | 443     target_bounds.Offset(new_bounds_origin.x() - target.bounds().x(), | 
| 414                          new_bounds_origin.y() - target.bounds().y()); | 444                          new_bounds_origin.y() - target.bounds().y()); | 
| 415     UpdateDisplayLayout( | 445     UpdateDisplayLayout(primary.bounds(), primary.id(), target_bounds, | 
| 416         primary.bounds(), primary.id(), target_bounds, target.id()); | 446                         target.id()); | 
| 417   } | 447   } | 
| 418 | 448 | 
| 419   return true; | 449   return true; | 
| 420 } | 450 } | 
| 421 | 451 | 
|  | 452 bool DisplayInfoProviderChromeOS::SetDisplayLayout( | 
|  | 453     const DisplayLayoutList& layouts) { | 
|  | 454   ash::DisplayManager* display_manager = | 
|  | 455       ash::Shell::GetInstance()->display_manager(); | 
|  | 456   display::DisplayLayoutBuilder builder( | 
|  | 457       display_manager->GetCurrentDisplayLayout()); | 
|  | 458 | 
|  | 459   bool have_root = false; | 
|  | 460   builder.ClearPlacements(); | 
|  | 461   for (const system_display::DisplayLayout& layout : layouts) { | 
|  | 462     display::Display display = GetDisplay(layout.id); | 
|  | 463     if (display.id() == display::Display::kInvalidDisplayID) { | 
|  | 464       LOG(ERROR) << "Invalid layout: display id not found: " << layout.id; | 
|  | 465       return false; | 
|  | 466     } | 
|  | 467     display::Display parent = GetDisplay(layout.parent_id); | 
|  | 468     if (parent.id() == display::Display::kInvalidDisplayID) { | 
|  | 469       if (have_root) { | 
|  | 470         LOG(ERROR) << "Invalid layout: multople roots."; | 
|  | 471         return false; | 
|  | 472       } | 
|  | 473       have_root = true; | 
|  | 474       continue;  // No placement for root (primary) display. | 
|  | 475     } | 
|  | 476     display::DisplayPlacement::Position position = | 
|  | 477         GetDisplayPlacementPosition(layout.position); | 
|  | 478     builder.AddDisplayPlacement(display.id(), parent.id(), position, | 
|  | 479                                 layout.offset); | 
|  | 480   } | 
|  | 481   std::unique_ptr<display::DisplayLayout> layout = builder.Build(); | 
|  | 482   if (!display::DisplayLayout::Validate( | 
|  | 483           display_manager->GetCurrentDisplayIdList(), *layout)) { | 
|  | 484     LOG(ERROR) << "Invalid layout: Validate failed."; | 
|  | 485     return false; | 
|  | 486   } | 
|  | 487   ash::Shell::GetInstance() | 
|  | 488       ->display_configuration_controller() | 
|  | 489       ->SetDisplayLayout(std::move(layout), true /* user_action */); | 
|  | 490   return true; | 
|  | 491 } | 
|  | 492 | 
| 422 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( | 493 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( | 
| 423     const display::Display& display, | 494     const display::Display& display, | 
| 424     extensions::api::system_display::DisplayUnitInfo* unit) { | 495     system_display::DisplayUnitInfo* unit) { | 
| 425   ash::DisplayManager* display_manager = | 496   ash::DisplayManager* display_manager = | 
| 426       ash::Shell::GetInstance()->display_manager(); | 497       ash::Shell::GetInstance()->display_manager(); | 
| 427   unit->name = display_manager->GetDisplayNameForId(display.id()); | 498   unit->name = display_manager->GetDisplayNameForId(display.id()); | 
| 428   if (display_manager->IsInMirrorMode()) { | 499   if (display_manager->IsInMirrorMode()) { | 
| 429     unit->mirroring_source_id = | 500     unit->mirroring_source_id = | 
| 430         base::Int64ToString(display_manager->mirroring_display_id()); | 501         base::Int64ToString(display_manager->mirroring_display_id()); | 
| 431   } | 502   } | 
| 432 | 503 | 
| 433   const ash::DisplayInfo& display_info = | 504   const ash::DisplayInfo& display_info = | 
| 434       display_manager->GetDisplayInfo(display.id()); | 505       display_manager->GetDisplayInfo(display.id()); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 449     unit->modes.push_back( | 520     unit->modes.push_back( | 
| 450         GetDisplayMode(display_manager, display_info, display_mode)); | 521         GetDisplayMode(display_manager, display_info, display_mode)); | 
| 451   } | 522   } | 
| 452 } | 523 } | 
| 453 | 524 | 
| 454 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { | 525 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { | 
| 455   ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 526   ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 
| 456       enable); | 527       enable); | 
| 457 } | 528 } | 
| 458 | 529 | 
| 459 DisplayUnitInfoList DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { | 530 DisplayInfoProvider::DisplayUnitInfoList | 
|  | 531 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { | 
| 460   ash::DisplayManager* display_manager = | 532   ash::DisplayManager* display_manager = | 
| 461       ash::Shell::GetInstance()->display_manager(); | 533       ash::Shell::GetInstance()->display_manager(); | 
| 462   if (!display_manager->IsInUnifiedMode()) | 534   if (!display_manager->IsInUnifiedMode()) | 
| 463     return DisplayInfoProvider::GetAllDisplaysInfo(); | 535     return DisplayInfoProvider::GetAllDisplaysInfo(); | 
| 464 | 536 | 
| 465   std::vector<display::Display> displays = | 537   std::vector<display::Display> displays = | 
| 466       display_manager->software_mirroring_display_list(); | 538       display_manager->software_mirroring_display_list(); | 
| 467   CHECK_GT(displays.size(), 0u); | 539   CHECK_GT(displays.size(), 0u); | 
| 468 | 540 | 
| 469   // Use first display as primary. | 541   // Use first display as primary. | 
| 470   int64_t primary_id = displays[0].id(); | 542   int64_t primary_id = displays[0].id(); | 
| 471   DisplayUnitInfoList all_displays; | 543   DisplayUnitInfoList all_displays; | 
| 472   for (const display::Display& display : displays) { | 544   for (const display::Display& display : displays) { | 
| 473     api::system_display::DisplayUnitInfo unit = | 545     system_display::DisplayUnitInfo unit = | 
| 474         CreateDisplayUnitInfo(display, primary_id); | 546         CreateDisplayUnitInfo(display, primary_id); | 
| 475     UpdateDisplayUnitInfoForPlatform(display, &unit); | 547     UpdateDisplayUnitInfoForPlatform(display, &unit); | 
| 476     all_displays.push_back(std::move(unit)); | 548     all_displays.push_back(std::move(unit)); | 
| 477   } | 549   } | 
| 478   return all_displays; | 550   return all_displays; | 
| 479 } | 551 } | 
| 480 | 552 | 
|  | 553 DisplayInfoProvider::DisplayLayoutList | 
|  | 554 DisplayInfoProviderChromeOS::GetDisplayLayout() { | 
|  | 555   ash::DisplayManager* display_manager = | 
|  | 556       ash::Shell::GetInstance()->display_manager(); | 
|  | 557 | 
|  | 558   display::Screen* screen = display::Screen::GetScreen(); | 
|  | 559   std::vector<display::Display> displays = screen->GetAllDisplays(); | 
|  | 560 | 
|  | 561   DisplayLayoutList result; | 
|  | 562   for (const display::Display& display : displays) { | 
|  | 563     const display::DisplayPlacement placement = | 
|  | 564         display_manager->GetCurrentDisplayLayout().FindPlacementById( | 
|  | 565             display.id()); | 
|  | 566     if (placement.display_id == display::Display::kInvalidDisplayID) | 
|  | 567       continue; | 
|  | 568     system_display::DisplayLayout display_layout; | 
|  | 569     display_layout.id = base::Int64ToString(placement.display_id); | 
|  | 570     display_layout.parent_id = base::Int64ToString(placement.parent_display_id); | 
|  | 571     display_layout.position = GetLayoutPosition(placement.position); | 
|  | 572     display_layout.offset = placement.offset; | 
|  | 573     result.push_back(std::move(display_layout)); | 
|  | 574   } | 
|  | 575   return result; | 
|  | 576 } | 
|  | 577 | 
| 481 bool DisplayInfoProviderChromeOS::OverscanCalibrationStart( | 578 bool DisplayInfoProviderChromeOS::OverscanCalibrationStart( | 
| 482     const std::string& id) { | 579     const std::string& id) { | 
| 483   VLOG(1) << "OverscanCalibrationStart: " << id; | 580   VLOG(1) << "OverscanCalibrationStart: " << id; | 
| 484   const display::Display display = GetDisplay(id); | 581   const display::Display display = GetDisplay(id); | 
| 485   if (display.id() == display::Display::kInvalidDisplayID) | 582   if (display.id() == display::Display::kInvalidDisplayID) | 
| 486     return false; | 583     return false; | 
| 487   auto insets = | 584   auto insets = | 
| 488       ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets( | 585       ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets( | 
| 489           display.id()); | 586           display.id()); | 
| 490   overscan_calibrators_[id].reset( | 587   overscan_calibrators_[id].reset( | 
| 491       new chromeos::OverscanCalibrator(display, insets)); | 588       new chromeos::OverscanCalibrator(display, insets)); | 
| 492   return true; | 589   return true; | 
| 493 } | 590 } | 
| 494 | 591 | 
| 495 bool DisplayInfoProviderChromeOS::OverscanCalibrationAdjust( | 592 bool DisplayInfoProviderChromeOS::OverscanCalibrationAdjust( | 
| 496     const std::string& id, | 593     const std::string& id, | 
| 497     const api::system_display::Insets& delta) { | 594     const system_display::Insets& delta) { | 
| 498   VLOG(1) << "OverscanCalibrationAdjust: " << id; | 595   VLOG(1) << "OverscanCalibrationAdjust: " << id; | 
| 499   chromeos::OverscanCalibrator* calibrator = GetCalibrator(id); | 596   chromeos::OverscanCalibrator* calibrator = GetCalibrator(id); | 
| 500   if (!calibrator) | 597   if (!calibrator) | 
| 501     return false; | 598     return false; | 
| 502   gfx::Insets insets = calibrator->insets(); | 599   gfx::Insets insets = calibrator->insets(); | 
| 503   insets += gfx::Insets(delta.top, delta.left, delta.bottom, delta.right); | 600   insets += gfx::Insets(delta.top, delta.left, delta.bottom, delta.right); | 
| 504   calibrator->UpdateInsets(insets); | 601   calibrator->UpdateInsets(insets); | 
| 505   return true; | 602   return true; | 
| 506 } | 603 } | 
| 507 | 604 | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 533     return nullptr; | 630     return nullptr; | 
| 534   return iter->second.get(); | 631   return iter->second.get(); | 
| 535 } | 632 } | 
| 536 | 633 | 
| 537 // static | 634 // static | 
| 538 DisplayInfoProvider* DisplayInfoProvider::Create() { | 635 DisplayInfoProvider* DisplayInfoProvider::Create() { | 
| 539   return new DisplayInfoProviderChromeOS(); | 636   return new DisplayInfoProviderChromeOS(); | 
| 540 } | 637 } | 
| 541 | 638 | 
| 542 }  // namespace extensions | 639 }  // namespace extensions | 
| OLD | NEW | 
|---|