Chromium Code Reviews| 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..80cd99f8405173eae4c20845c416c3b9b8e7b789 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" |
| @@ -18,13 +20,24 @@ namespace { |
| // TODO(hshi): determine the DPI of the screen. |
| const float kDpi96 = 96.0; |
| +const int kBaseRotation = 90; |
| } // 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 +52,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 = static_cast<int>(display->rotation()) * kBaseRotation; |
|
Greg Spencer (Chromium)
2013/06/10 19:17:42
Should this be "% 360"? Just to prevent invalid v
tbarzic
2013/06/10 19:53:51
I think it is safe to assume rotation returned fro
|
| unit->bounds.left = bounds.x(); |
| unit->bounds.top = bounds.y(); |
| unit->bounds.width = bounds.width(); |
| unit->bounds.height = bounds.height(); |
| + unit->visible_area.left = overscan_insets.left(); |
| + unit->visible_area.top = overscan_insets.top(); |
| + unit->visible_area.width = bounds.width(); |
| + unit->visible_area.height = bounds.height(); |
| unit->work_area.left = work_area.x(); |
| unit->work_area.top = work_area.y(); |
| unit->work_area.width = work_area.width(); |