[Sync] Clean up deprecated ProfileSyncService.get(context).
[chromium-blink-merge.git] / ui / display / chromeos / display_util.cc
bloba62e47cd6e4b023d3d0f874a36526291eb01e6e1
1 // Copyright 2014 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.
5 #include "ui/display/chromeos/display_util.h"
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h"
10 #include "ui/display/types/display_snapshot.h"
12 namespace ui {
14 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) {
15 switch (state) {
16 case chromeos::DISPLAY_POWER_ALL_ON:
17 return "ALL_ON";
18 case chromeos::DISPLAY_POWER_ALL_OFF:
19 return "ALL_OFF";
20 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON:
21 return "INTERNAL_OFF_EXTERNAL_ON";
22 case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF:
23 return "INTERNAL_ON_EXTERNAL_OFF";
24 default:
25 return "unknown (" + base::IntToString(state) + ")";
29 std::string MultipleDisplayStateToString(MultipleDisplayState state) {
30 switch (state) {
31 case MULTIPLE_DISPLAY_STATE_INVALID:
32 return "INVALID";
33 case MULTIPLE_DISPLAY_STATE_HEADLESS:
34 return "HEADLESS";
35 case MULTIPLE_DISPLAY_STATE_SINGLE:
36 return "SINGLE";
37 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR:
38 return "DUAL_MIRROR";
39 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED:
40 return "DUAL_EXTENDED";
41 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED:
42 return "MULTI_EXTENDED";
44 NOTREACHED() << "Unknown state " << state;
45 return "INVALID";
48 int GetDisplayPower(const std::vector<DisplaySnapshot*>& displays,
49 chromeos::DisplayPowerState state,
50 std::vector<bool>* display_power) {
51 int num_on_displays = 0;
52 if (display_power)
53 display_power->resize(displays.size());
55 for (size_t i = 0; i < displays.size(); ++i) {
56 bool internal = displays[i]->type() == DISPLAY_CONNECTION_TYPE_INTERNAL;
57 bool on =
58 state == chromeos::DISPLAY_POWER_ALL_ON ||
59 (state == chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON &&
60 !internal) ||
61 (state == chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal);
62 if (display_power)
63 (*display_power)[i] = on;
64 if (on)
65 num_on_displays++;
67 return num_on_displays;
70 } // namespace ui