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/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h"
9 #include "ui/display/types/display_snapshot.h"
13 std::string
DisplayPowerStateToString(chromeos::DisplayPowerState state
) {
15 case chromeos::DISPLAY_POWER_ALL_ON
:
17 case chromeos::DISPLAY_POWER_ALL_OFF
:
19 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON
:
20 return "INTERNAL_OFF_EXTERNAL_ON";
21 case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF
:
22 return "INTERNAL_ON_EXTERNAL_OFF";
24 return "unknown (" + base::IntToString(state
) + ")";
28 std::string
MultipleDisplayStateToString(MultipleDisplayState state
) {
30 case MULTIPLE_DISPLAY_STATE_INVALID
:
32 case MULTIPLE_DISPLAY_STATE_HEADLESS
:
34 case MULTIPLE_DISPLAY_STATE_SINGLE
:
36 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
:
38 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED
:
39 return "DUAL_EXTENDED";
40 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED
:
41 return "MULTI_EXTENDED";
43 NOTREACHED() << "Unknown state " << state
;
48 const std::vector
<DisplayConfigurator::DisplayState
>& display_states
,
49 chromeos::DisplayPowerState state
,
50 std::vector
<bool>* display_power
) {
51 int num_on_displays
= 0;
53 display_power
->resize(display_states
.size());
55 for (size_t i
= 0; i
< display_states
.size(); ++i
) {
57 display_states
[i
].display
->type() == DISPLAY_CONNECTION_TYPE_INTERNAL
;
59 state
== chromeos::DISPLAY_POWER_ALL_ON
||
60 (state
== chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON
&&
62 (state
== chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF
&& internal
);
64 (*display_power
)[i
] = on
;
68 return num_on_displays
;