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

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

Issue 11882009: Multi-monitor extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to 179043. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
(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 const float dpi = display->device_scale_factor() * kDpi96;
42 unit->id = base::Int64ToString(display->id());
43 unit->name = display_manager->GetDisplayNameFor(*display);
44 unit->is_primary = (display->id() == primary_id);
45 unit->is_internal = display_manager->IsInternalDisplayId(display->id());
46 unit->is_enabled = true;
47 unit->dpi_x = dpi;
48 unit->dpi_y = dpi;
49 unit->bounds.left = bounds.x();
50 unit->bounds.top = bounds.y();
51 unit->bounds.width = bounds.width();
52 unit->bounds.height = bounds.height();
53 unit->work_area.left = work_area.x();
54 unit->work_area.top = work_area.y();
55 unit->work_area.width = work_area.width();
56 unit->work_area.height = work_area.height();
57 info->push_back(unit);
58 }
59
60 return true;
61 }
62
63 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698