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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7c884b9d2ec3c4c9a916d38012bbd18605aefa11 |
--- /dev/null |
+++ b/chrome/browser/extensions/api/system_info_display/display_info_provider_chromeos.cc |
@@ -0,0 +1,62 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/extensions/api/system_info_display/display_info_provider.h" |
+ |
+#include "ash/display/display_manager.h" |
+#include "ash/shell.h" |
+#include "base/string_number_conversions.h" |
+#include "ui/gfx/display.h" |
+#include "ui/gfx/rect.h" |
+ |
+using ash::internal::DisplayManager; |
+ |
+namespace extensions { |
+ |
+namespace { |
+ |
+// TODO(hshi): determine the DPI of the screen. |
+const float kDpi96 = 96.0; |
+ |
+} // namespace |
+ |
+using api::system_info_display::Bounds; |
+using api::system_info_display::DisplayUnitInfo; |
+ |
+bool DisplayInfoProvider::QueryInfo(DisplayInfo* info) { |
+ DCHECK(info); |
+ info->clear(); |
+ |
+ DisplayManager* display_manager = |
+ ash::Shell::GetInstance()->display_manager(); |
+ DCHECK(display_manager); |
+ |
+ int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); |
+ for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
+ linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo()); |
+ const gfx::Display* display = display_manager->GetDisplayAt(i); |
+ const gfx::Rect& bounds = display->bounds(); |
+ const gfx::Rect& work_area = display->work_area(); |
+ unit->id = base::Int64ToString(display->id()); |
+ unit->name = display_manager->GetDisplayNameFor(*display); |
+ unit->is_primary = (display->id() == primary_id); |
+ unit->is_internal = display_manager->IsInternalDisplayId(display->id()); |
+ unit->is_enabled = true; |
+ unit->dpi_x = kDpi96; |
+ 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.
|
+ unit->bounds.left = bounds.x(); |
+ unit->bounds.top = bounds.y(); |
+ unit->bounds.width = bounds.width(); |
+ unit->bounds.height = bounds.height(); |
+ unit->work_area.left = work_area.x(); |
+ unit->work_area.top = work_area.y(); |
+ unit->work_area.width = work_area.width(); |
+ unit->work_area.height = work_area.height(); |
+ info->push_back(unit); |
+ } |
+ |
+ return true; |
+} |
+ |
+} // namespace extensions |