Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/api/system_info_display/display_info_provide r.h" | |
| 6 | |
| 7 #include "ash/display/display_manager.h" | |
| 8 #include "ash/shell.h" | |
| 9 #include "base/string_number_conversions.h" | |
| 10 #include "ui/gfx/display.h" | |
| 11 #include "ui/gfx/rect.h" | |
| 12 | |
| 13 using ash::internal::DisplayManager; | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 // TODO(hshi): determine the DPI of the screen. | |
| 20 const float kDpi96 = 96.0; | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 using api::system_info_display::Bounds; | |
| 25 using api::system_info_display::DisplayUnitInfo; | |
| 26 | |
| 27 bool DisplayInfoProvider::QueryInfo(DisplayInfo* info) { | |
| 28 DCHECK(info); | |
| 29 info->clear(); | |
| 30 | |
| 31 DisplayManager* display_manager = | |
| 32 ash::Shell::GetInstance()->display_manager(); | |
| 33 DCHECK(display_manager); | |
| 34 | |
| 35 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); | |
| 36 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | |
| 37 linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo()); | |
| 38 const gfx::Display* display = display_manager->GetDisplayAt(i); | |
| 39 const gfx::Rect& bounds = display->bounds(); | |
| 40 const gfx::Rect& work_area = display->work_area(); | |
| 41 unit->id = base::Int64ToString(display->id()); | |
| 42 unit->name = display_manager->GetDisplayNameFor(*display); | |
| 43 unit->is_primary = (display->id() == primary_id); | |
| 44 unit->is_internal = display_manager->IsInternalDisplayId(display->id()); | |
| 45 unit->is_enabled = true; | |
| 46 unit->dpi_x = kDpi96; | |
| 47 unit->dpi_y = kDpi96; | |
|
oshima
2013/01/25 23:21:53
sorry i didn't catch it first time. You probably s
hshi1
2013/01/25 23:46:07
Done.
| |
| 48 unit->bounds.left = bounds.x(); | |
| 49 unit->bounds.top = bounds.y(); | |
| 50 unit->bounds.width = bounds.width(); | |
| 51 unit->bounds.height = bounds.height(); | |
| 52 unit->work_area.left = work_area.x(); | |
| 53 unit->work_area.top = work_area.y(); | |
| 54 unit->work_area.width = work_area.width(); | |
| 55 unit->work_area.height = work_area.height(); | |
| 56 info->push_back(unit); | |
| 57 } | |
| 58 | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 } // namespace extensions | |
| OLD | NEW |