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"
14 std::string
DisplayPowerStateToString(chromeos::DisplayPowerState state
) {
16 case chromeos::DISPLAY_POWER_ALL_ON
:
18 case chromeos::DISPLAY_POWER_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";
25 return "unknown (" + base::IntToString(state
) + ")";
29 std::string
MultipleDisplayStateToString(MultipleDisplayState state
) {
31 case MULTIPLE_DISPLAY_STATE_INVALID
:
33 case MULTIPLE_DISPLAY_STATE_HEADLESS
:
35 case MULTIPLE_DISPLAY_STATE_SINGLE
:
37 case MULTIPLE_DISPLAY_STATE_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
;
48 int GetDisplayPower(const std::vector
<DisplaySnapshot
*>& displays
,
49 chromeos::DisplayPowerState state
,
50 std::vector
<bool>* display_power
) {
51 int num_on_displays
= 0;
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
;
58 state
== chromeos::DISPLAY_POWER_ALL_ON
||
59 (state
== chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON
&&
61 (state
== chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF
&& internal
);
63 (*display_power
)[i
] = on
;
67 return num_on_displays
;