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

Unified Diff: chrome/browser/extensions/api/system_display/display_info_provider.cc

Issue 389633002: Move system.* family of APIs to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better comments Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/system_display/display_info_provider.cc
diff --git a/chrome/browser/extensions/api/system_display/display_info_provider.cc b/chrome/browser/extensions/api/system_display/display_info_provider.cc
deleted file mode 100644
index d57bd15ce0a477cb723337ed4af2b47f92c87ccf..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/api/system_display/display_info_provider.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 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_display/display_info_provider.h"
-
-#include "base/strings/string_number_conversions.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/screen.h"
-
-namespace extensions {
-
-namespace {
-
-// 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;
-}
-
-// Creates new DisplayUnitInfo struct for |display|.
-extensions::api::system_display::DisplayUnitInfo*
-CreateDisplayUnitInfo(const gfx::Display& display, int64 primary_display_id) {
- extensions::api::system_display::DisplayUnitInfo* unit =
- new extensions::api::system_display::DisplayUnitInfo();
- const gfx::Rect& bounds = display.bounds();
- const gfx::Rect& work_area = display.work_area();
- unit->id = base::Int64ToString(display.id());
- unit->is_primary = (display.id() == primary_display_id);
- unit->is_internal = display.IsInternal();
- unit->is_enabled = true;
- 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->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();
- return unit;
-}
-
-DisplayInfoProvider* g_display_info_provider = NULL;
-
-} // namespace
-
-
-DisplayInfoProvider::DisplayInfoProvider() {}
-
-DisplayInfoProvider::~DisplayInfoProvider() {}
-
-DisplayInfoProvider* DisplayInfoProvider::Get() {
- if (g_display_info_provider == NULL)
- g_display_info_provider = new DisplayInfoProvider();
- return g_display_info_provider;
-}
-
-void DisplayInfoProvider::InitializeForTesting(
- DisplayInfoProvider* display_info_provider) {
- DCHECK(display_info_provider);
- g_display_info_provider = display_info_provider;
-}
-
-DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() {
- // TODO(scottmg): Native is wrong http://crbug.com/133312
- gfx::Screen* screen = gfx::Screen::GetNativeScreen();
- int64 primary_id = screen->GetPrimaryDisplay().id();
- std::vector<gfx::Display> displays = screen->GetAllDisplays();
- DisplayInfo all_displays;
- for (int i = 0; i < screen->GetNumDisplays(); ++i) {
- linked_ptr<extensions::api::system_display::DisplayUnitInfo> unit(
- CreateDisplayUnitInfo(displays[i], primary_id));
- UpdateDisplayUnitInfoForPlatform(displays[i], unit.get());
- all_displays.push_back(unit);
- }
- return all_displays;
-}
-
-} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698