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

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

Issue 1540753002: Switch to standard integer types in ash/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: arraysize Created 5 years 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
« no previous file with comments | « ash/system/chromeos/tray_display.h ('k') | ash/system/chromeos/tray_tracing.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/display/screen_orientation_controller_chromeos.h" 10 #include "ash/display/screen_orientation_controller_chromeos.h"
(...skipping 23 matching lines...) Expand all
34 34
35 using message_center::Notification; 35 using message_center::Notification;
36 36
37 namespace ash { 37 namespace ash {
38 namespace { 38 namespace {
39 39
40 DisplayManager* GetDisplayManager() { 40 DisplayManager* GetDisplayManager() {
41 return Shell::GetInstance()->display_manager(); 41 return Shell::GetInstance()->display_manager();
42 } 42 }
43 43
44 base::string16 GetDisplayName(int64 display_id) { 44 base::string16 GetDisplayName(int64_t display_id) {
45 return base::UTF8ToUTF16( 45 return base::UTF8ToUTF16(
46 GetDisplayManager()->GetDisplayNameForId(display_id)); 46 GetDisplayManager()->GetDisplayNameForId(display_id));
47 } 47 }
48 48
49 base::string16 GetDisplaySize(int64 display_id) { 49 base::string16 GetDisplaySize(int64_t display_id) {
50 DisplayManager* display_manager = GetDisplayManager(); 50 DisplayManager* display_manager = GetDisplayManager();
51 51
52 const gfx::Display* display = &display_manager->GetDisplayForId(display_id); 52 const gfx::Display* display = &display_manager->GetDisplayForId(display_id);
53 53
54 // We don't show display size for mirrored display. Fallback 54 // We don't show display size for mirrored display. Fallback
55 // to empty string if this happens on release build. 55 // to empty string if this happens on release build.
56 bool mirroring = display_manager->mirroring_display_id() == display_id; 56 bool mirroring = display_manager->mirroring_display_id() == display_id;
57 DCHECK(!mirroring); 57 DCHECK(!mirroring);
58 if (mirroring) 58 if (mirroring)
59 return base::string16(); 59 return base::string16();
60 60
61 DCHECK(display->is_valid()); 61 DCHECK(display->is_valid());
62 return base::UTF8ToUTF16(display->size().ToString()); 62 return base::UTF8ToUTF16(display->size().ToString());
63 } 63 }
64 64
65 // Returns 1-line information for the specified display, like 65 // Returns 1-line information for the specified display, like
66 // "InternalDisplay: 1280x750" 66 // "InternalDisplay: 1280x750"
67 base::string16 GetDisplayInfoLine(int64 display_id) { 67 base::string16 GetDisplayInfoLine(int64_t display_id) {
68 const DisplayInfo& display_info = 68 const DisplayInfo& display_info =
69 GetDisplayManager()->GetDisplayInfo(display_id); 69 GetDisplayManager()->GetDisplayInfo(display_id);
70 if (GetDisplayManager()->mirroring_display_id() == display_id) 70 if (GetDisplayManager()->mirroring_display_id() == display_id)
71 return GetDisplayName(display_id); 71 return GetDisplayName(display_id);
72 72
73 base::string16 size_text = GetDisplaySize(display_id); 73 base::string16 size_text = GetDisplaySize(display_id);
74 base::string16 display_data; 74 base::string16 display_data;
75 if (display_info.has_overscan()) { 75 if (display_info.has_overscan()) {
76 display_data = l10n_util::GetStringFUTF16( 76 display_data = l10n_util::GetStringFUTF16(
77 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION, 77 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION,
78 size_text, 78 size_text,
79 l10n_util::GetStringUTF16( 79 l10n_util::GetStringUTF16(
80 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); 80 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN));
81 } else { 81 } else {
82 display_data = size_text; 82 display_data = size_text;
83 } 83 }
84 84
85 return l10n_util::GetStringFUTF16( 85 return l10n_util::GetStringFUTF16(
86 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 86 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
87 GetDisplayName(display_id), 87 GetDisplayName(display_id),
88 display_data); 88 display_data);
89 } 89 }
90 90
91 base::string16 GetAllDisplayInfo() { 91 base::string16 GetAllDisplayInfo() {
92 DisplayManager* display_manager = GetDisplayManager(); 92 DisplayManager* display_manager = GetDisplayManager();
93 std::vector<base::string16> lines; 93 std::vector<base::string16> lines;
94 int64 internal_id = gfx::Display::kInvalidDisplayID; 94 int64_t internal_id = gfx::Display::kInvalidDisplayID;
95 // Make sure to show the internal display first. 95 // Make sure to show the internal display first.
96 if (!display_manager->IsInUnifiedMode() && 96 if (!display_manager->IsInUnifiedMode() &&
97 gfx::Display::IsInternalDisplayId(display_manager->first_display_id())) { 97 gfx::Display::IsInternalDisplayId(display_manager->first_display_id())) {
98 internal_id = display_manager->first_display_id(); 98 internal_id = display_manager->first_display_id();
99 lines.push_back(GetDisplayInfoLine(internal_id)); 99 lines.push_back(GetDisplayInfoLine(internal_id));
100 } 100 }
101 101
102 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 102 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
103 int64 id = display_manager->GetDisplayAt(i).id(); 103 int64_t id = display_manager->GetDisplayAt(i).id();
104 if (id == internal_id) 104 if (id == internal_id)
105 continue; 105 continue;
106 lines.push_back(GetDisplayInfoLine(id)); 106 lines.push_back(GetDisplayInfoLine(id));
107 } 107 }
108 108
109 return base::JoinString(lines, base::ASCIIToUTF16("\n")); 109 return base::JoinString(lines, base::ASCIIToUTF16("\n"));
110 } 110 }
111 111
112 void OpenSettings() { 112 void OpenSettings() {
113 // switch is intentionally introduced without default, to cause an error when 113 // switch is intentionally introduced without default, to cause an error when
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return true; 181 return true;
182 } 182 }
183 183
184 // Returns the name of the currently connected external display. 184 // Returns the name of the currently connected external display.
185 // This should not be used when the external display is used for 185 // This should not be used when the external display is used for
186 // mirroring. 186 // mirroring.
187 static base::string16 GetExternalDisplayName() { 187 static base::string16 GetExternalDisplayName() {
188 DisplayManager* display_manager = GetDisplayManager(); 188 DisplayManager* display_manager = GetDisplayManager();
189 DCHECK(!display_manager->IsInMirrorMode()); 189 DCHECK(!display_manager->IsInMirrorMode());
190 190
191 int64 external_id = gfx::Display::kInvalidDisplayID; 191 int64_t external_id = gfx::Display::kInvalidDisplayID;
192 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 192 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
193 int64 id = display_manager->GetDisplayAt(i).id(); 193 int64_t id = display_manager->GetDisplayAt(i).id();
194 if (!gfx::Display::IsInternalDisplayId(id)) { 194 if (!gfx::Display::IsInternalDisplayId(id)) {
195 external_id = id; 195 external_id = id;
196 break; 196 break;
197 } 197 }
198 } 198 }
199 199
200 if (external_id == gfx::Display::kInvalidDisplayID) { 200 if (external_id == gfx::Display::kInvalidDisplayID) {
201 return l10n_util::GetStringUTF16( 201 return l10n_util::GetStringUTF16(
202 IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); 202 IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
203 } 203 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, 242 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
243 GetDisplayName(display_manager->mirroring_display_id())); 243 GetDisplayName(display_manager->mirroring_display_id()));
244 } 244 }
245 return l10n_util::GetStringUTF16( 245 return l10n_util::GetStringUTF16(
246 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); 246 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL);
247 } 247 }
248 248
249 if (display_manager->IsInUnifiedMode()) 249 if (display_manager->IsInUnifiedMode())
250 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED); 250 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
251 251
252 int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 252 int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id();
253 if (gfx::Display::HasInternalDisplay() && 253 if (gfx::Display::HasInternalDisplay() &&
254 !(gfx::Display::IsInternalDisplayId(primary_id))) { 254 !(gfx::Display::IsInternalDisplayId(primary_id))) {
255 if (additional_message_out) { 255 if (additional_message_out) {
256 *additional_message_out = ash::SubstituteChromeOSDeviceType( 256 *additional_message_out = ash::SubstituteChromeOSDeviceType(
257 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION); 257 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION);
258 } 258 }
259 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); 259 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED);
260 } 260 }
261 261
262 return base::string16(); 262 return base::string16();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); 301 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
302 } 302 }
303 303
304 void TrayDisplay::UpdateDisplayInfo(TrayDisplay::DisplayInfoMap* old_info) { 304 void TrayDisplay::UpdateDisplayInfo(TrayDisplay::DisplayInfoMap* old_info) {
305 if (old_info) 305 if (old_info)
306 old_info->swap(display_info_); 306 old_info->swap(display_info_);
307 display_info_.clear(); 307 display_info_.clear();
308 308
309 DisplayManager* display_manager = GetDisplayManager(); 309 DisplayManager* display_manager = GetDisplayManager();
310 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 310 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
311 int64 id = display_manager->GetDisplayAt(i).id(); 311 int64_t id = display_manager->GetDisplayAt(i).id();
312 display_info_[id] = display_manager->GetDisplayInfo(id); 312 display_info_[id] = display_manager->GetDisplayInfo(id);
313 } 313 }
314 } 314 }
315 315
316 bool TrayDisplay::GetDisplayMessageForNotification( 316 bool TrayDisplay::GetDisplayMessageForNotification(
317 const TrayDisplay::DisplayInfoMap& old_info, 317 const TrayDisplay::DisplayInfoMap& old_info,
318 base::string16* message_out, 318 base::string16* message_out,
319 base::string16* additional_message_out) { 319 base::string16* additional_message_out) {
320 // Display is added or removed. Use the same message as the one in 320 // Display is added or removed. Use the same message as the one in
321 // the system tray. 321 // the system tray.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 bool TrayDisplay::GetAccessibleStateForTesting(ui::AXViewState* state) { 442 bool TrayDisplay::GetAccessibleStateForTesting(ui::AXViewState* state) {
443 views::View* view = default_; 443 views::View* view = default_;
444 if (view) { 444 if (view) {
445 view->GetAccessibleState(state); 445 view->GetAccessibleState(state);
446 return true; 446 return true;
447 } 447 }
448 return false; 448 return false;
449 } 449 }
450 450
451 } // namespace ash 451 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_display.h ('k') | ash/system/chromeos/tray_tracing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698