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

Side by Side Diff: ash/system/chromeos/tray_display.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/system/chromeos/tray_display.h" 5 #include "ash/system/chromeos/tray_display.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
12 #include "ash/display/screen_orientation_controller_chromeos.h" 12 #include "ash/display/screen_orientation_controller_chromeos.h"
13 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/system/chromeos/devicetype_utils.h" 15 #include "ash/system/chromeos/devicetype_utils.h"
16 #include "ash/system/system_notifier.h" 16 #include "ash/system/system_notifier.h"
17 #include "ash/system/tray/actionable_view.h" 17 #include "ash/system/tray/actionable_view.h"
18 #include "ash/system/tray/fixed_sized_image_view.h" 18 #include "ash/system/tray/fixed_sized_image_view.h"
19 #include "ash/system/tray/system_tray.h" 19 #include "ash/system/tray/system_tray.h"
20 #include "ash/system/tray/system_tray_delegate.h" 20 #include "ash/system/tray/system_tray_delegate.h"
21 #include "ash/system/tray/tray_constants.h" 21 #include "ash/system/tray/tray_constants.h"
22 #include "ash/system/tray/tray_notification_view.h" 22 #include "ash/system/tray/tray_notification_view.h"
23 #include "base/bind.h" 23 #include "base/bind.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "grit/ash_resources.h" 26 #include "grit/ash_resources.h"
27 #include "grit/ash_strings.h" 27 #include "grit/ash_strings.h"
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/display.h" 30 #include "ui/display/display.h"
31 #include "ui/message_center/message_center.h" 31 #include "ui/message_center/message_center.h"
32 #include "ui/message_center/notification.h" 32 #include "ui/message_center/notification.h"
33 #include "ui/message_center/notification_delegate.h" 33 #include "ui/message_center/notification_delegate.h"
34 #include "ui/views/controls/image_view.h" 34 #include "ui/views/controls/image_view.h"
35 #include "ui/views/controls/label.h" 35 #include "ui/views/controls/label.h"
36 #include "ui/views/layout/box_layout.h" 36 #include "ui/views/layout/box_layout.h"
37 37
38 using message_center::Notification; 38 using message_center::Notification;
39 39
40 namespace ash { 40 namespace ash {
41 namespace { 41 namespace {
42 42
43 DisplayManager* GetDisplayManager() { 43 DisplayManager* GetDisplayManager() {
44 return Shell::GetInstance()->display_manager(); 44 return Shell::GetInstance()->display_manager();
45 } 45 }
46 46
47 base::string16 GetDisplayName(int64_t display_id) { 47 base::string16 GetDisplayName(int64_t display_id) {
48 return base::UTF8ToUTF16( 48 return base::UTF8ToUTF16(
49 GetDisplayManager()->GetDisplayNameForId(display_id)); 49 GetDisplayManager()->GetDisplayNameForId(display_id));
50 } 50 }
51 51
52 base::string16 GetDisplaySize(int64_t display_id) { 52 base::string16 GetDisplaySize(int64_t display_id) {
53 DisplayManager* display_manager = GetDisplayManager(); 53 DisplayManager* display_manager = GetDisplayManager();
54 54
55 const gfx::Display* display = &display_manager->GetDisplayForId(display_id); 55 const display::Display* display =
56 &display_manager->GetDisplayForId(display_id);
56 57
57 // We don't show display size for mirrored display. Fallback 58 // We don't show display size for mirrored display. Fallback
58 // to empty string if this happens on release build. 59 // to empty string if this happens on release build.
59 bool mirroring = display_manager->mirroring_display_id() == display_id; 60 bool mirroring = display_manager->mirroring_display_id() == display_id;
60 DCHECK(!mirroring); 61 DCHECK(!mirroring);
61 if (mirroring) 62 if (mirroring)
62 return base::string16(); 63 return base::string16();
63 64
64 DCHECK(display->is_valid()); 65 DCHECK(display->is_valid());
65 return base::UTF8ToUTF16(display->size().ToString()); 66 return base::UTF8ToUTF16(display->size().ToString());
(...skipping 21 matching lines...) Expand all
87 88
88 return l10n_util::GetStringFUTF16( 89 return l10n_util::GetStringFUTF16(
89 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 90 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
90 GetDisplayName(display_id), 91 GetDisplayName(display_id),
91 display_data); 92 display_data);
92 } 93 }
93 94
94 base::string16 GetAllDisplayInfo() { 95 base::string16 GetAllDisplayInfo() {
95 DisplayManager* display_manager = GetDisplayManager(); 96 DisplayManager* display_manager = GetDisplayManager();
96 std::vector<base::string16> lines; 97 std::vector<base::string16> lines;
97 int64_t internal_id = gfx::Display::kInvalidDisplayID; 98 int64_t internal_id = display::Display::kInvalidDisplayID;
98 // Make sure to show the internal display first. 99 // Make sure to show the internal display first.
99 if (!display_manager->IsInUnifiedMode() && 100 if (!display_manager->IsInUnifiedMode() &&
100 gfx::Display::IsInternalDisplayId(display_manager->first_display_id())) { 101 display::Display::IsInternalDisplayId(
102 display_manager->first_display_id())) {
101 internal_id = display_manager->first_display_id(); 103 internal_id = display_manager->first_display_id();
102 lines.push_back(GetDisplayInfoLine(internal_id)); 104 lines.push_back(GetDisplayInfoLine(internal_id));
103 } 105 }
104 106
105 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 107 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
106 int64_t id = display_manager->GetDisplayAt(i).id(); 108 int64_t id = display_manager->GetDisplayAt(i).id();
107 if (id == internal_id) 109 if (id == internal_id)
108 continue; 110 continue;
109 lines.push_back(GetDisplayInfoLine(id)); 111 lines.push_back(GetDisplayInfoLine(id));
110 } 112 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return true; 186 return true;
185 } 187 }
186 188
187 // Returns the name of the currently connected external display. 189 // Returns the name of the currently connected external display.
188 // This should not be used when the external display is used for 190 // This should not be used when the external display is used for
189 // mirroring. 191 // mirroring.
190 static base::string16 GetExternalDisplayName() { 192 static base::string16 GetExternalDisplayName() {
191 DisplayManager* display_manager = GetDisplayManager(); 193 DisplayManager* display_manager = GetDisplayManager();
192 DCHECK(!display_manager->IsInMirrorMode()); 194 DCHECK(!display_manager->IsInMirrorMode());
193 195
194 int64_t external_id = gfx::Display::kInvalidDisplayID; 196 int64_t external_id = display::Display::kInvalidDisplayID;
195 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 197 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
196 int64_t id = display_manager->GetDisplayAt(i).id(); 198 int64_t id = display_manager->GetDisplayAt(i).id();
197 if (!gfx::Display::IsInternalDisplayId(id)) { 199 if (!display::Display::IsInternalDisplayId(id)) {
198 external_id = id; 200 external_id = id;
199 break; 201 break;
200 } 202 }
201 } 203 }
202 204
203 if (external_id == gfx::Display::kInvalidDisplayID) { 205 if (external_id == display::Display::kInvalidDisplayID) {
204 return l10n_util::GetStringUTF16( 206 return l10n_util::GetStringUTF16(
205 IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); 207 IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
206 } 208 }
207 209
208 // The external display name may have an annotation of "(width x height)" in 210 // The external display name may have an annotation of "(width x height)" in
209 // case that the display is rotated or its resolution is changed. 211 // case that the display is rotated or its resolution is changed.
210 base::string16 name = GetDisplayName(external_id); 212 base::string16 name = GetDisplayName(external_id);
211 const DisplayInfo& display_info = 213 const DisplayInfo& display_info =
212 display_manager->GetDisplayInfo(external_id); 214 display_manager->GetDisplayInfo(external_id);
213 if (display_info.GetActiveRotation() != gfx::Display::ROTATE_0 || 215 if (display_info.GetActiveRotation() != display::Display::ROTATE_0 ||
214 display_info.configured_ui_scale() != 1.0f || 216 display_info.configured_ui_scale() != 1.0f ||
215 !display_info.overscan_insets_in_dip().IsEmpty()) { 217 !display_info.overscan_insets_in_dip().IsEmpty()) {
216 name = l10n_util::GetStringFUTF16( 218 name = l10n_util::GetStringFUTF16(
217 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 219 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME,
218 name, GetDisplaySize(external_id)); 220 name, GetDisplaySize(external_id));
219 } else if (display_info.overscan_insets_in_dip().IsEmpty() && 221 } else if (display_info.overscan_insets_in_dip().IsEmpty() &&
220 display_info.has_overscan()) { 222 display_info.has_overscan()) {
221 name = l10n_util::GetStringFUTF16( 223 name = l10n_util::GetStringFUTF16(
222 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 224 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME,
223 name, l10n_util::GetStringUTF16( 225 name, l10n_util::GetStringUTF16(
224 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); 226 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN));
225 } 227 }
226 228
227 return name; 229 return name;
228 } 230 }
229 231
230 static base::string16 GetTrayDisplayMessage( 232 static base::string16 GetTrayDisplayMessage(
231 base::string16* additional_message_out) { 233 base::string16* additional_message_out) {
232 DisplayManager* display_manager = GetDisplayManager(); 234 DisplayManager* display_manager = GetDisplayManager();
233 if (display_manager->GetNumDisplays() > 1) { 235 if (display_manager->GetNumDisplays() > 1) {
234 if (gfx::Display::HasInternalDisplay()) { 236 if (display::Display::HasInternalDisplay()) {
235 return l10n_util::GetStringFUTF16( 237 return l10n_util::GetStringFUTF16(
236 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetExternalDisplayName()); 238 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetExternalDisplayName());
237 } 239 }
238 return l10n_util::GetStringUTF16( 240 return l10n_util::GetStringUTF16(
239 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); 241 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL);
240 } 242 }
241 243
242 if (display_manager->IsInMirrorMode()) { 244 if (display_manager->IsInMirrorMode()) {
243 if (gfx::Display::HasInternalDisplay()) { 245 if (display::Display::HasInternalDisplay()) {
244 return l10n_util::GetStringFUTF16( 246 return l10n_util::GetStringFUTF16(
245 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, 247 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
246 GetDisplayName(display_manager->mirroring_display_id())); 248 GetDisplayName(display_manager->mirroring_display_id()));
247 } 249 }
248 return l10n_util::GetStringUTF16( 250 return l10n_util::GetStringUTF16(
249 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); 251 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL);
250 } 252 }
251 253
252 if (display_manager->IsInUnifiedMode()) 254 if (display_manager->IsInUnifiedMode())
253 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED); 255 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
254 256
255 int64_t primary_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 257 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
256 if (gfx::Display::HasInternalDisplay() && 258 if (display::Display::HasInternalDisplay() &&
257 !(gfx::Display::IsInternalDisplayId(primary_id))) { 259 !(display::Display::IsInternalDisplayId(primary_id))) {
258 if (additional_message_out) { 260 if (additional_message_out) {
259 *additional_message_out = ash::SubstituteChromeOSDeviceType( 261 *additional_message_out = ash::SubstituteChromeOSDeviceType(
260 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION); 262 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION);
261 } 263 }
262 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); 264 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED);
263 } 265 }
264 266
265 return base::string16(); 267 return base::string16();
266 } 268 }
267 269
268 private: 270 private:
269 bool ShouldShowFirstDisplayInfo() const { 271 bool ShouldShowFirstDisplayInfo() const {
270 const int64_t first_display_id = GetDisplayManager()->first_display_id(); 272 const int64_t first_display_id = GetDisplayManager()->first_display_id();
271 273
272 const DisplayInfo& display_info = 274 const DisplayInfo& display_info =
273 GetDisplayManager()->GetDisplayInfo(first_display_id); 275 GetDisplayManager()->GetDisplayInfo(first_display_id);
274 return (display_info.GetActiveRotation() != gfx::Display::ROTATE_0 && 276 return (display_info.GetActiveRotation() != display::Display::ROTATE_0 &&
275 (display_info.active_rotation_source() != 277 (display_info.active_rotation_source() !=
276 gfx::Display::ROTATION_SOURCE_ACCELEROMETER || 278 display::Display::ROTATION_SOURCE_ACCELEROMETER ||
277 !gfx::Display::IsInternalDisplayId(first_display_id))) || 279 !display::Display::IsInternalDisplayId(first_display_id))) ||
278 display_info.configured_ui_scale() != 1.0f || 280 display_info.configured_ui_scale() != 1.0f ||
279 !display_info.overscan_insets_in_dip().IsEmpty() || 281 !display_info.overscan_insets_in_dip().IsEmpty() ||
280 display_info.has_overscan(); 282 display_info.has_overscan();
281 } 283 }
282 284
283 // Overridden from ActionableView. 285 // Overridden from ActionableView.
284 bool PerformAction(const ui::Event& event) override { 286 bool PerformAction(const ui::Event& event) override {
285 OpenSettings(); 287 OpenSettings();
286 return true; 288 return true;
287 } 289 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 old_iter->second.configured_ui_scale()) { 349 old_iter->second.configured_ui_scale()) {
348 *additional_message_out = l10n_util::GetStringFUTF16( 350 *additional_message_out = l10n_util::GetStringFUTF16(
349 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, 351 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED,
350 GetDisplayName(iter->first), GetDisplaySize(iter->first)); 352 GetDisplayName(iter->first), GetDisplaySize(iter->first));
351 return true; 353 return true;
352 } 354 }
353 if (iter->second.GetActiveRotation() != 355 if (iter->second.GetActiveRotation() !=
354 old_iter->second.GetActiveRotation()) { 356 old_iter->second.GetActiveRotation()) {
355 int rotation_text_id = 0; 357 int rotation_text_id = 0;
356 switch (iter->second.GetActiveRotation()) { 358 switch (iter->second.GetActiveRotation()) {
357 case gfx::Display::ROTATE_0: 359 case display::Display::ROTATE_0:
358 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION; 360 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION;
359 break; 361 break;
360 case gfx::Display::ROTATE_90: 362 case display::Display::ROTATE_90:
361 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90; 363 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90;
362 break; 364 break;
363 case gfx::Display::ROTATE_180: 365 case display::Display::ROTATE_180:
364 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180; 366 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180;
365 break; 367 break;
366 case gfx::Display::ROTATE_270: 368 case display::Display::ROTATE_270:
367 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270; 369 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270;
368 break; 370 break;
369 } 371 }
370 *additional_message_out = l10n_util::GetStringFUTF16( 372 *additional_message_out = l10n_util::GetStringFUTF16(
371 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetDisplayName(iter->first), 373 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetDisplayName(iter->first),
372 l10n_util::GetStringUTF16(rotation_text_id)); 374 l10n_util::GetStringUTF16(rotation_text_id));
373 return true; 375 return true;
374 } 376 }
375 } 377 }
376 378
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 bool TrayDisplay::GetAccessibleStateForTesting(ui::AXViewState* state) { 453 bool TrayDisplay::GetAccessibleStateForTesting(ui::AXViewState* state) {
452 views::View* view = default_; 454 views::View* view = default_;
453 if (view) { 455 if (view) {
454 view->GetAccessibleState(state); 456 view->GetAccessibleState(state);
455 return true; 457 return true;
456 } 458 }
457 return false; 459 return false;
458 } 460 }
459 461
460 } // namespace ash 462 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc ('k') | ash/system/chromeos/tray_display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698