OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/display/display_layout.h" | 5 #include "ash/display/display_layout.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_manager.h" |
8 #include "ash/display/display_pref_util.h" | 9 #include "ash/display/display_pref_util.h" |
| 10 #include "ash/shell.h" |
9 #include "base/json/json_value_converter.h" | 11 #include "base/json/json_value_converter.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
14 #include "base/values.h" | 16 #include "base/values.h" |
15 #include "ui/gfx/display.h" | 17 #include "ui/gfx/display.h" |
16 | 18 |
17 namespace ash { | 19 namespace ash { |
18 namespace { | 20 namespace { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // static | 67 // static |
66 DisplayLayout DisplayLayout::FromInts(int position, int offsets) { | 68 DisplayLayout DisplayLayout::FromInts(int position, int offsets) { |
67 return DisplayLayout(static_cast<Position>(position), offsets); | 69 return DisplayLayout(static_cast<Position>(position), offsets); |
68 } | 70 } |
69 | 71 |
70 DisplayLayout::DisplayLayout() | 72 DisplayLayout::DisplayLayout() |
71 : position(RIGHT), | 73 : position(RIGHT), |
72 offset(0), | 74 offset(0), |
73 mirrored(false), | 75 mirrored(false), |
74 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
75 default_unified(switches::UnifiedDesktopEnabled()), | 77 default_unified(true), |
76 #else | 78 #else |
77 default_unified(false), | 79 default_unified(false), |
78 #endif | 80 #endif |
79 primary_id(gfx::Display::kInvalidDisplayID) { | 81 primary_id(gfx::Display::kInvalidDisplayID) { |
80 } | 82 } |
81 | 83 |
82 DisplayLayout::DisplayLayout(DisplayLayout::Position position, int offset) | 84 DisplayLayout::DisplayLayout(DisplayLayout::Position position, int offset) |
83 : position(position), | 85 : position(position), |
84 offset(offset), | 86 offset(offset), |
85 mirrored(false), | 87 mirrored(false), |
86 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
87 default_unified(switches::UnifiedDesktopEnabled()), | 89 default_unified(true), |
88 #else | 90 #else |
89 default_unified(false), | 91 default_unified(false), |
90 #endif | 92 #endif |
91 primary_id(gfx::Display::kInvalidDisplayID) { | 93 primary_id(gfx::Display::kInvalidDisplayID) { |
92 DCHECK_LE(TOP, position); | 94 DCHECK_LE(TOP, position); |
93 DCHECK_GE(LEFT, position); | 95 DCHECK_GE(LEFT, position); |
94 | 96 |
95 // Set the default value to |position| in case position is invalid. DCHECKs | 97 // Set the default value to |position| in case position is invalid. DCHECKs |
96 // above doesn't stop in Release builds. | 98 // above doesn't stop in Release builds. |
97 if (TOP > position || LEFT < position) | 99 if (TOP > position || LEFT < position) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 dict_value->SetString(kPositionKey, position_str); | 141 dict_value->SetString(kPositionKey, position_str); |
140 dict_value->SetInteger(kOffsetKey, layout.offset); | 142 dict_value->SetInteger(kOffsetKey, layout.offset); |
141 dict_value->SetBoolean(kMirroredKey, layout.mirrored); | 143 dict_value->SetBoolean(kMirroredKey, layout.mirrored); |
142 dict_value->SetBoolean(kDefaultUnifiedKey, layout.default_unified); | 144 dict_value->SetBoolean(kDefaultUnifiedKey, layout.default_unified); |
143 dict_value->SetString(kPrimaryIdKey, base::Int64ToString(layout.primary_id)); | 145 dict_value->SetString(kPrimaryIdKey, base::Int64ToString(layout.primary_id)); |
144 return true; | 146 return true; |
145 } | 147 } |
146 | 148 |
147 std::string DisplayLayout::ToString() const { | 149 std::string DisplayLayout::ToString() const { |
148 const std::string position_str = GetStringFromPosition(position); | 150 const std::string position_str = GetStringFromPosition(position); |
| 151 bool unified = |
| 152 default_unified && |
| 153 Shell::GetInstance()->display_manager()->unified_desktop_enabled(); |
| 154 |
149 return base::StringPrintf("%s, %d%s%s", position_str.c_str(), offset, | 155 return base::StringPrintf("%s, %d%s%s", position_str.c_str(), offset, |
150 mirrored ? ", mirrored" : "", | 156 mirrored ? ", mirrored" : "", |
151 default_unified ? ", unified" : ""); | 157 unified ? ", unified" : ""); |
152 } | 158 } |
153 | 159 |
154 // static | 160 // static |
155 void DisplayLayout::RegisterJSONConverter( | 161 void DisplayLayout::RegisterJSONConverter( |
156 base::JSONValueConverter<DisplayLayout>* converter) { | 162 base::JSONValueConverter<DisplayLayout>* converter) { |
157 converter->RegisterCustomField<Position>( | 163 converter->RegisterCustomField<Position>( |
158 kPositionKey, &DisplayLayout::position, &GetPositionFromString); | 164 kPositionKey, &DisplayLayout::position, &GetPositionFromString); |
159 converter->RegisterIntField(kOffsetKey, &DisplayLayout::offset); | 165 converter->RegisterIntField(kOffsetKey, &DisplayLayout::offset); |
160 converter->RegisterBoolField(kMirroredKey, &DisplayLayout::mirrored); | 166 converter->RegisterBoolField(kMirroredKey, &DisplayLayout::mirrored); |
161 converter->RegisterBoolField(kDefaultUnifiedKey, | 167 converter->RegisterBoolField(kDefaultUnifiedKey, |
162 &DisplayLayout::default_unified); | 168 &DisplayLayout::default_unified); |
163 converter->RegisterCustomField<int64>( | 169 converter->RegisterCustomField<int64>( |
164 kPrimaryIdKey, &DisplayLayout::primary_id, &GetDisplayIdFromString); | 170 kPrimaryIdKey, &DisplayLayout::primary_id, &GetDisplayIdFromString); |
165 } | 171 } |
166 | 172 |
167 } // namespace ash | 173 } // namespace ash |
OLD | NEW |