| Index: chrome/browser/extensions/api/system_info_display/display_info_provider_chromeos.cc
|
| diff --git a/chrome/browser/extensions/api/system_info_display/display_info_provider_chromeos.cc b/chrome/browser/extensions/api/system_info_display/display_info_provider_chromeos.cc
|
| index 653bb4c89543ce42c24e304dae20a29836ef0c6c..feb735dac512ee2a7282ec4999d242f378e9ead2 100644
|
| --- a/chrome/browser/extensions/api/system_info_display/display_info_provider_chromeos.cc
|
| +++ b/chrome/browser/extensions/api/system_info_display/display_info_provider_chromeos.cc
|
| @@ -6,7 +6,9 @@
|
|
|
| #include "ash/display/display_manager.h"
|
| #include "ash/shell.h"
|
| +#include "base/message_loop_proxy.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| #include "ui/gfx/display.h"
|
| #include "ui/gfx/rect.h"
|
|
|
| @@ -19,12 +21,37 @@ namespace {
|
| // TODO(hshi): determine the DPI of the screen.
|
| const float kDpi96 = 96.0;
|
|
|
| +// Converts Rotation enum to integer.
|
| +int RotationToDegrees(gfx::Display::Rotation rotation) {
|
| + switch (rotation) {
|
| + case gfx::Display::ROTATE_0:
|
| + return 0;
|
| + case gfx::Display::ROTATE_90:
|
| + return 90;
|
| + case gfx::Display::ROTATE_180:
|
| + return 180;
|
| + case gfx::Display::ROTATE_270:
|
| + return 270;
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| } // namespace
|
|
|
| using api::system_info_display::Bounds;
|
| using api::system_info_display::DisplayUnitInfo;
|
|
|
| +void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) {
|
| + DisplayInfo requested_info;
|
| + bool success = QueryInfo(&requested_info);
|
| +
|
| + base::MessageLoopProxy::current()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(callback, requested_info, success));
|
| +}
|
| +
|
| bool DisplayInfoProvider::QueryInfo(DisplayInfo* info) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| DCHECK(info);
|
| info->clear();
|
|
|
| @@ -39,17 +66,30 @@ bool DisplayInfoProvider::QueryInfo(DisplayInfo* info) {
|
| const gfx::Rect& bounds = display->bounds();
|
| const gfx::Rect& work_area = display->work_area();
|
| const float dpi = display->device_scale_factor() * kDpi96;
|
| + const gfx::Insets overscan_insets =
|
| + display_manager->GetOverscanInsets(display->id());
|
| +
|
| unit->id = base::Int64ToString(display->id());
|
| unit->name = display_manager->GetDisplayNameForId(display->id());
|
| unit->is_primary = (display->id() == primary_id);
|
| + if (display_manager->IsMirrored() &&
|
| + display_manager->mirrored_display().id() != display->id()) {
|
| + unit->mirroring_source_id =
|
| + base::Int64ToString(display_manager->mirrored_display().id());
|
| + }
|
| unit->is_internal = display->IsInternal();
|
| unit->is_enabled = true;
|
| unit->dpi_x = dpi;
|
| unit->dpi_y = dpi;
|
| + unit->rotation = RotationToDegrees(display->rotation());
|
| unit->bounds.left = bounds.x();
|
| unit->bounds.top = bounds.y();
|
| unit->bounds.width = bounds.width();
|
| unit->bounds.height = bounds.height();
|
| + unit->overscan.left = overscan_insets.left();
|
| + unit->overscan.top = overscan_insets.top();
|
| + unit->overscan.right = overscan_insets.right();
|
| + unit->overscan.bottom = overscan_insets.bottom();
|
| unit->work_area.left = work_area.x();
|
| unit->work_area.top = work_area.y();
|
| unit->work_area.width = work_area.width();
|
|
|