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

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos.cc

Issue 2270553002: Move ash::DisplayInfo to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build Created 4 years, 3 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 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"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 if ((info.overscan->top + info.overscan->bottom) * 2 > screen_height) { 312 if ((info.overscan->top + info.overscan->bottom) * 2 > screen_height) {
313 *error = "Vertical overscan is more than half of the screen height."; 313 *error = "Vertical overscan is more than half of the screen height.";
314 return false; 314 return false;
315 } 315 }
316 } 316 }
317 317
318 // Set the display mode. 318 // Set the display mode.
319 if (info.display_mode) { 319 if (info.display_mode) {
320 scoped_refptr<ash::ManagedDisplayMode> current_mode = 320 scoped_refptr<ui::ManagedDisplayMode> current_mode =
321 display_manager->GetActiveModeForDisplayId(id); 321 display_manager->GetActiveModeForDisplayId(id);
322 // Copy properties not set in the UI from the current mode. 322 // Copy properties not set in the UI from the current mode.
323 gfx::Size size(info.display_mode->width_in_native_pixels, 323 gfx::Size size(info.display_mode->width_in_native_pixels,
324 info.display_mode->height_in_native_pixels); 324 info.display_mode->height_in_native_pixels);
325 325
326 // NB: info.display_mode is neither an ash::DisplayMode or a 326 // NB: info.display_mode is neither an ash::DisplayMode or a
327 // ui::DisplayMode. 327 // ui::DisplayMode.
328 scoped_refptr<ash::ManagedDisplayMode> new_mode(new ash::ManagedDisplayMode( 328 scoped_refptr<ui::ManagedDisplayMode> new_mode(new ui::ManagedDisplayMode(
329 size, current_mode->refresh_rate(), current_mode->is_interlaced(), 329 size, current_mode->refresh_rate(), current_mode->is_interlaced(),
330 info.display_mode->is_native, info.display_mode->ui_scale, 330 info.display_mode->is_native, info.display_mode->ui_scale,
331 info.display_mode->device_scale_factor)); 331 info.display_mode->device_scale_factor));
332 332
333 if (new_mode->IsEquivalent(current_mode)) { 333 if (new_mode->IsEquivalent(current_mode)) {
334 *error = "Display mode matches current mode."; 334 *error = "Display mode matches current mode.";
335 return false; 335 return false;
336 } 336 }
337 337
338 if (!display_manager->SetDisplayMode(id, new_mode)) { 338 if (!display_manager->SetDisplayMode(id, new_mode)) {
339 *error = "Unable to set the display mode."; 339 *error = "Unable to set the display mode.";
340 return false; 340 return false;
341 } 341 }
342 342
343 if (!display::Display::IsInternalDisplayId(id)) { 343 if (!display::Display::IsInternalDisplayId(id)) {
344 // For external displays, show a notification confirming the resolution 344 // For external displays, show a notification confirming the resolution
345 // change. 345 // change.
346 ash::Shell::GetInstance() 346 ash::Shell::GetInstance()
347 ->resolution_notification_controller() 347 ->resolution_notification_controller()
348 ->PrepareNotification(id, current_mode, new_mode, 348 ->PrepareNotification(id, current_mode, new_mode,
349 base::Bind(&chromeos::StoreDisplayPrefs)); 349 base::Bind(&chromeos::StoreDisplayPrefs));
350 } 350 }
351 } 351 }
352 return true; 352 return true;
353 } 353 }
354 354
355 system_display::DisplayMode GetDisplayMode( 355 system_display::DisplayMode GetDisplayMode(
356 ash::DisplayManager* display_manager, 356 ash::DisplayManager* display_manager,
357 const ash::DisplayInfo& display_info, 357 const ui::ManagedDisplayInfo& display_info,
358 const scoped_refptr<ash::ManagedDisplayMode>& display_mode) { 358 const scoped_refptr<ui::ManagedDisplayMode>& display_mode) {
359 system_display::DisplayMode result; 359 system_display::DisplayMode result;
360 360
361 bool is_internal = display::Display::HasInternalDisplay() && 361 bool is_internal = display::Display::HasInternalDisplay() &&
362 display::Display::InternalDisplayId() == display_info.id(); 362 display::Display::InternalDisplayId() == display_info.id();
363 gfx::Size size_dip = display_mode->GetSizeInDIP(is_internal); 363 gfx::Size size_dip = display_mode->GetSizeInDIP(is_internal);
364 result.width = size_dip.width(); 364 result.width = size_dip.width();
365 result.height = size_dip.height(); 365 result.height = size_dip.height();
366 result.width_in_native_pixels = display_mode->size().width(); 366 result.width_in_native_pixels = display_mode->size().width();
367 result.height_in_native_pixels = display_mode->size().height(); 367 result.height_in_native_pixels = display_mode->size().height();
368 result.ui_scale = display_mode->ui_scale(); 368 result.ui_scale = display_mode->ui_scale();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 const display::Display& display, 494 const display::Display& display,
495 system_display::DisplayUnitInfo* unit) { 495 system_display::DisplayUnitInfo* unit) {
496 ash::DisplayManager* display_manager = 496 ash::DisplayManager* display_manager =
497 ash::Shell::GetInstance()->display_manager(); 497 ash::Shell::GetInstance()->display_manager();
498 unit->name = display_manager->GetDisplayNameForId(display.id()); 498 unit->name = display_manager->GetDisplayNameForId(display.id());
499 if (display_manager->IsInMirrorMode()) { 499 if (display_manager->IsInMirrorMode()) {
500 unit->mirroring_source_id = 500 unit->mirroring_source_id =
501 base::Int64ToString(display_manager->mirroring_display_id()); 501 base::Int64ToString(display_manager->mirroring_display_id());
502 } 502 }
503 503
504 const ash::DisplayInfo& display_info = 504 const ui::ManagedDisplayInfo& display_info =
505 display_manager->GetDisplayInfo(display.id()); 505 display_manager->GetDisplayInfo(display.id());
506 const float device_dpi = display_info.device_dpi(); 506 const float device_dpi = display_info.device_dpi();
507 unit->dpi_x = device_dpi * display.size().width() / 507 unit->dpi_x = device_dpi * display.size().width() /
508 display_info.bounds_in_native().width(); 508 display_info.bounds_in_native().width();
509 unit->dpi_y = device_dpi * display.size().height() / 509 unit->dpi_y = device_dpi * display.size().height() /
510 display_info.bounds_in_native().height(); 510 display_info.bounds_in_native().height();
511 511
512 const gfx::Insets overscan_insets = 512 const gfx::Insets overscan_insets =
513 display_manager->GetOverscanInsets(display.id()); 513 display_manager->GetOverscanInsets(display.id());
514 unit->overscan.left = overscan_insets.left(); 514 unit->overscan.left = overscan_insets.left();
515 unit->overscan.top = overscan_insets.top(); 515 unit->overscan.top = overscan_insets.top();
516 unit->overscan.right = overscan_insets.right(); 516 unit->overscan.right = overscan_insets.right();
517 unit->overscan.bottom = overscan_insets.bottom(); 517 unit->overscan.bottom = overscan_insets.bottom();
518 518
519 for (const scoped_refptr<ash::ManagedDisplayMode>& display_mode : 519 for (const scoped_refptr<ui::ManagedDisplayMode>& display_mode :
520 display_info.display_modes()) { 520 display_info.display_modes()) {
521 unit->modes.push_back( 521 unit->modes.push_back(
522 GetDisplayMode(display_manager, display_info, display_mode)); 522 GetDisplayMode(display_manager, display_info, display_mode));
523 } 523 }
524 } 524 }
525 525
526 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { 526 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) {
527 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( 527 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(
528 enable); 528 enable);
529 } 529 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 return nullptr; 634 return nullptr;
635 return iter->second.get(); 635 return iter->second.get();
636 } 636 }
637 637
638 // static 638 // static
639 DisplayInfoProvider* DisplayInfoProvider::Create() { 639 DisplayInfoProvider* DisplayInfoProvider::Create() {
640 return new DisplayInfoProviderChromeOS(); 640 return new DisplayInfoProviderChromeOS();
641 } 641 }
642 642
643 } // namespace extensions 643 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698