| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_util.h" | 5 #include "ui/display/manager/display_manager_utilities.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> |
| 8 | 9 |
| 9 #include "ash/common/new_window_delegate.h" | 10 #include "base/sys_info.h" |
| 10 #include "ash/common/system/system_notifier.h" | |
| 11 #include "ash/common/wm_shell.h" | |
| 12 #include "ash/display/display_manager.h" | |
| 13 #include "ash/host/ash_window_tree_host.h" | |
| 14 #include "ash/shell.h" | |
| 15 #include "base/strings/string_number_conversions.h" | |
| 16 #include "grit/ash_resources.h" | |
| 17 #include "ui/aura/env.h" | |
| 18 #include "ui/aura/window_tree_host.h" | |
| 19 #include "ui/base/l10n/l10n_util.h" | |
| 20 #include "ui/base/resource/resource_bundle.h" | |
| 21 #include "ui/display/display.h" | |
| 22 #include "ui/display/manager/managed_display_info.h" | 11 #include "ui/display/manager/managed_display_info.h" |
| 23 #include "ui/gfx/geometry/point.h" | |
| 24 #include "ui/gfx/geometry/rect.h" | |
| 25 #include "ui/gfx/geometry/size_conversions.h" | 12 #include "ui/gfx/geometry/size_conversions.h" |
| 26 #include "ui/message_center/message_center.h" | 13 #include "ui/gfx/geometry/size_f.h" |
| 27 #include "ui/message_center/notification.h" | |
| 28 #include "ui/message_center/notification_delegate.h" | |
| 29 #include "ui/message_center/notification_list.h" | |
| 30 #include "ui/wm/core/coordinate_conversion.h" | |
| 31 | 14 |
| 32 #if defined(OS_CHROMEOS) | 15 namespace display { |
| 33 #include "base/sys_info.h" | |
| 34 #endif | |
| 35 | 16 |
| 36 namespace ash { | |
| 37 namespace { | 17 namespace { |
| 38 | 18 |
| 39 const char kDisplayErrorNotificationId[] = "chrome://settings/display/error"; | |
| 40 | |
| 41 // A notification delegate that will start the feedback app when the notication | |
| 42 // is clicked. | |
| 43 class DisplayErrorNotificationDelegate | |
| 44 : public message_center::NotificationDelegate { | |
| 45 public: | |
| 46 DisplayErrorNotificationDelegate() = default; | |
| 47 | |
| 48 // message_center::NotificationDelegate: | |
| 49 bool HasClickedListener() override { return true; } | |
| 50 | |
| 51 void Click() override { | |
| 52 WmShell::Get()->new_window_delegate()->OpenFeedbackPage(); | |
| 53 } | |
| 54 | |
| 55 private: | |
| 56 // Private destructor since NotificationDelegate is ref-counted. | |
| 57 ~DisplayErrorNotificationDelegate() override = default; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate); | |
| 60 }; | |
| 61 | |
| 62 // List of value UI Scale values. Scales for 2x are equivalent to 640, | 19 // List of value UI Scale values. Scales for 2x are equivalent to 640, |
| 63 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on | 20 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on |
| 64 // 2560 pixel width 2x density display. Please see crbug.com/233375 | 21 // 2560 pixel width 2x density display. Please see crbug.com/233375 |
| 65 // for the full list of resolutions. | 22 // for the full list of resolutions. |
| 66 const float kUIScalesFor2x[] = {0.5f, 0.625f, 0.8f, 1.0f, | 23 const float kUIScalesFor2x[] = {0.5f, 0.625f, 0.8f, 1.0f, |
| 67 1.125f, 1.25f, 1.5f, 2.0f}; | 24 1.125f, 1.25f, 1.5f, 2.0f}; |
| 68 const float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f}; | 25 const float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f}; |
| 69 const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f}; | 26 const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f}; |
| 70 const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f}; | 27 const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f}; |
| 71 | 28 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 102 explicit ScaleComparator(float s) : scale(s) {} | 59 explicit ScaleComparator(float s) : scale(s) {} |
| 103 | 60 |
| 104 bool operator()( | 61 bool operator()( |
| 105 const scoped_refptr<display::ManagedDisplayMode>& mode) const { | 62 const scoped_refptr<display::ManagedDisplayMode>& mode) const { |
| 106 const float kEpsilon = 0.0001f; | 63 const float kEpsilon = 0.0001f; |
| 107 return std::abs(scale - mode->ui_scale()) < kEpsilon; | 64 return std::abs(scale - mode->ui_scale()) < kEpsilon; |
| 108 } | 65 } |
| 109 float scale; | 66 float scale; |
| 110 }; | 67 }; |
| 111 | 68 |
| 112 void ConvertPointFromScreenToNative(aura::WindowTreeHost* host, | |
| 113 gfx::Point* point) { | |
| 114 ::wm::ConvertPointFromScreen(host->window(), point); | |
| 115 host->ConvertPointToNativeScreen(point); | |
| 116 } | |
| 117 | |
| 118 scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForUIScale( | |
| 119 const display::ManagedDisplayInfo& info, | |
| 120 float ui_scale) { | |
| 121 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = | |
| 122 info.display_modes(); | |
| 123 auto iter = std::find_if( | |
| 124 modes.begin(), modes.end(), | |
| 125 [ui_scale](const scoped_refptr<display::ManagedDisplayMode>& mode) { | |
| 126 return mode->ui_scale() == ui_scale; | |
| 127 }); | |
| 128 if (iter == modes.end()) | |
| 129 return scoped_refptr<display::ManagedDisplayMode>(); | |
| 130 return *iter; | |
| 131 } | |
| 132 | |
| 133 scoped_refptr<display::ManagedDisplayMode> FindNextMode( | 69 scoped_refptr<display::ManagedDisplayMode> FindNextMode( |
| 134 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes, | 70 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes, |
| 135 size_t index, | 71 size_t index, |
| 136 bool up) { | 72 bool up) { |
| 137 DCHECK_LT(index, modes.size()); | 73 DCHECK_LT(index, modes.size()); |
| 138 size_t new_index = index; | 74 size_t new_index = index; |
| 139 if (up && (index + 1 < modes.size())) | 75 if (up && (index + 1 < modes.size())) |
| 140 ++new_index; | 76 ++new_index; |
| 141 else if (!up && index != 0) | 77 else if (!up && index != 0) |
| 142 --new_index; | 78 --new_index; |
| 143 return modes[new_index]; | 79 return modes[new_index]; |
| 144 } | 80 } |
| 145 | 81 |
| 146 } // namespace | 82 } // namespace |
| 147 | 83 |
| 148 display::ManagedDisplayInfo::ManagedDisplayModeList | 84 display::ManagedDisplayInfo::ManagedDisplayModeList |
| 149 CreateInternalManagedDisplayModeList( | 85 CreateInternalManagedDisplayModeList( |
| 150 const scoped_refptr<display::ManagedDisplayMode>& native_mode) { | 86 const scoped_refptr<display::ManagedDisplayMode>& native_mode) { |
| 151 display::ManagedDisplayInfo::ManagedDisplayModeList display_mode_list; | 87 display::ManagedDisplayInfo::ManagedDisplayModeList display_mode_list; |
| 152 | 88 |
| 153 float native_ui_scale = (native_mode->device_scale_factor() == 1.25f) | 89 float native_ui_scale = (native_mode->device_scale_factor() == 1.25f) |
| 154 ? 1.0f | 90 ? 1.0f |
| 155 : native_mode->device_scale_factor(); | 91 : native_mode->device_scale_factor(); |
| 156 for (float ui_scale : GetScalesForDisplay(native_mode)) { | 92 for (float ui_scale : GetScalesForDisplay(native_mode)) { |
| 157 scoped_refptr<display::ManagedDisplayMode> mode( | 93 scoped_refptr<ManagedDisplayMode> mode(new ManagedDisplayMode( |
| 158 new display::ManagedDisplayMode( | 94 native_mode->size(), native_mode->refresh_rate(), |
| 159 native_mode->size(), native_mode->refresh_rate(), | 95 native_mode->is_interlaced(), ui_scale == native_ui_scale, ui_scale, |
| 160 native_mode->is_interlaced(), ui_scale == native_ui_scale, ui_scale, | 96 native_mode->device_scale_factor())); |
| 161 native_mode->device_scale_factor())); | |
| 162 display_mode_list.push_back(mode); | 97 display_mode_list.push_back(mode); |
| 163 } | 98 } |
| 164 return display_mode_list; | 99 return display_mode_list; |
| 165 } | 100 } |
| 166 | 101 |
| 167 display::ManagedDisplayInfo::ManagedDisplayModeList | 102 display::ManagedDisplayInfo::ManagedDisplayModeList |
| 168 CreateUnifiedManagedDisplayModeList( | 103 CreateUnifiedManagedDisplayModeList( |
| 169 const scoped_refptr<display::ManagedDisplayMode>& native_mode, | 104 const scoped_refptr<display::ManagedDisplayMode>& native_mode, |
| 170 const std::set<std::pair<float, float>>& dsf_scale_list) { | 105 const std::set<std::pair<float, float>>& dsf_scale_list) { |
| 171 display::ManagedDisplayInfo::ManagedDisplayModeList display_mode_list; | 106 display::ManagedDisplayInfo::ManagedDisplayModeList display_mode_list; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 LOG(WARNING) << "Unsupported resolution was requested:" | 145 LOG(WARNING) << "Unsupported resolution was requested:" |
| 211 << resolution.ToString(); | 146 << resolution.ToString(); |
| 212 return scoped_refptr<display::ManagedDisplayMode>(); | 147 return scoped_refptr<display::ManagedDisplayMode>(); |
| 213 } | 148 } |
| 214 return *iter; | 149 return *iter; |
| 215 } | 150 } |
| 216 | 151 |
| 217 scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForNextUIScale( | 152 scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForNextUIScale( |
| 218 const display::ManagedDisplayInfo& info, | 153 const display::ManagedDisplayInfo& info, |
| 219 bool up) { | 154 bool up) { |
| 220 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 155 const ManagedDisplayInfo::ManagedDisplayModeList& modes = |
| 221 if (!display_manager->IsActiveDisplayId(info.id()) || | |
| 222 !display::Display::IsInternalDisplayId(info.id())) { | |
| 223 return scoped_refptr<display::ManagedDisplayMode>(); | |
| 224 } | |
| 225 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = | |
| 226 info.display_modes(); | 156 info.display_modes(); |
| 227 ScaleComparator comparator(info.configured_ui_scale()); | 157 ScaleComparator comparator(info.configured_ui_scale()); |
| 228 auto iter = std::find_if(modes.begin(), modes.end(), comparator); | 158 auto iter = std::find_if(modes.begin(), modes.end(), comparator); |
| 229 return FindNextMode(modes, iter - modes.begin(), up); | 159 return FindNextMode(modes, iter - modes.begin(), up); |
| 230 } | 160 } |
| 231 | 161 |
| 232 scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForNextResolution( | 162 scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForNextResolution( |
| 233 const display::ManagedDisplayInfo& info, | 163 const display::ManagedDisplayInfo& info, |
| 234 bool up) { | 164 bool up) { |
| 235 if (display::Display::IsInternalDisplayId(info.id())) | 165 if (display::Display::IsInternalDisplayId(info.id())) |
| 236 return scoped_refptr<display::ManagedDisplayMode>(); | 166 return scoped_refptr<display::ManagedDisplayMode>(); |
| 237 | 167 |
| 238 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = | 168 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = |
| 239 info.display_modes(); | 169 info.display_modes(); |
| 240 scoped_refptr<display::ManagedDisplayMode> tmp = | 170 scoped_refptr<display::ManagedDisplayMode> tmp = |
| 241 new display::ManagedDisplayMode(info.size_in_pixel(), 0.0, false, false, | 171 new display::ManagedDisplayMode(info.size_in_pixel(), 0.0, false, false, |
| 242 1.0, info.device_scale_factor()); | 172 1.0, info.device_scale_factor()); |
| 243 gfx::Size resolution = tmp->GetSizeInDIP(false); | 173 gfx::Size resolution = tmp->GetSizeInDIP(false); |
| 244 | 174 |
| 245 auto iter = std::find_if( | 175 auto iter = std::find_if( |
| 246 modes.begin(), modes.end(), | 176 modes.begin(), modes.end(), |
| 247 [resolution](const scoped_refptr<display::ManagedDisplayMode>& mode) { | 177 [resolution](const scoped_refptr<display::ManagedDisplayMode>& mode) { |
| 248 return mode->GetSizeInDIP(false) == resolution; | 178 return mode->GetSizeInDIP(false) == resolution; |
| 249 }); | 179 }); |
| 250 return FindNextMode(modes, iter - modes.begin(), up); | 180 return FindNextMode(modes, iter - modes.begin(), up); |
| 251 } | 181 } |
| 252 | 182 |
| 253 bool SetDisplayUIScale(int64_t id, float ui_scale) { | 183 bool HasDisplayModeForUIScale(const ManagedDisplayInfo& info, float ui_scale) { |
| 254 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | |
| 255 if (!display_manager->IsActiveDisplayId(id) || | |
| 256 !display::Display::IsInternalDisplayId(id)) { | |
| 257 return false; | |
| 258 } | |
| 259 const display::ManagedDisplayInfo& info = display_manager->GetDisplayInfo(id); | |
| 260 | |
| 261 scoped_refptr<display::ManagedDisplayMode> mode = | |
| 262 GetDisplayModeForUIScale(info, ui_scale); | |
| 263 if (!mode) | |
| 264 return false; | |
| 265 return display_manager->SetDisplayMode(id, mode); | |
| 266 } | |
| 267 | |
| 268 bool HasDisplayModeForUIScale(const display::ManagedDisplayInfo& info, | |
| 269 float ui_scale) { | |
| 270 ScaleComparator comparator(ui_scale); | 184 ScaleComparator comparator(ui_scale); |
| 271 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = | 185 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = |
| 272 info.display_modes(); | 186 info.display_modes(); |
| 273 return std::find_if(modes.begin(), modes.end(), comparator) != modes.end(); | 187 return std::find_if(modes.begin(), modes.end(), comparator) != modes.end(); |
| 274 } | 188 } |
| 275 | 189 |
| 276 bool ComputeBoundary(const display::Display& a_display, | 190 bool ComputeBoundary(const display::Display& a_display, |
| 277 const display::Display& b_display, | 191 const display::Display& b_display, |
| 278 gfx::Rect* a_edge_in_screen, | 192 gfx::Rect* a_edge_in_screen, |
| 279 gfx::Rect* b_edge_in_screen) { | 193 gfx::Rect* b_edge_in_screen) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } else { | 246 } else { |
| 333 a_edge_in_screen->SetRect(a_bounds.right() - 1, top, 1, bottom - top); | 247 a_edge_in_screen->SetRect(a_bounds.right() - 1, top, 1, bottom - top); |
| 334 b_edge_in_screen->SetRect(b_bounds.x(), top, 1, bottom - top); | 248 b_edge_in_screen->SetRect(b_bounds.x(), top, 1, bottom - top); |
| 335 } | 249 } |
| 336 break; | 250 break; |
| 337 } | 251 } |
| 338 } | 252 } |
| 339 return true; | 253 return true; |
| 340 } | 254 } |
| 341 | 255 |
| 342 gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host, | |
| 343 const gfx::Rect& bounds_in_screen) { | |
| 344 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | |
| 345 gfx::Rect native_bounds = host->GetBounds(); | |
| 346 native_bounds.Inset(ash_host->GetHostInsets()); | |
| 347 gfx::Point start_in_native = bounds_in_screen.origin(); | |
| 348 gfx::Point end_in_native = bounds_in_screen.bottom_right(); | |
| 349 | |
| 350 ConvertPointFromScreenToNative(host, &start_in_native); | |
| 351 ConvertPointFromScreenToNative(host, &end_in_native); | |
| 352 | |
| 353 if (std::abs(start_in_native.x() - end_in_native.x()) < | |
| 354 std::abs(start_in_native.y() - end_in_native.y())) { | |
| 355 // vertical in native | |
| 356 int x = std::abs(native_bounds.x() - start_in_native.x()) < | |
| 357 std::abs(native_bounds.right() - start_in_native.x()) | |
| 358 ? native_bounds.x() | |
| 359 : native_bounds.right() - 1; | |
| 360 return gfx::Rect(x, std::min(start_in_native.y(), end_in_native.y()), 1, | |
| 361 std::abs(end_in_native.y() - start_in_native.y())); | |
| 362 } else { | |
| 363 // horizontal in native | |
| 364 int y = std::abs(native_bounds.y() - start_in_native.y()) < | |
| 365 std::abs(native_bounds.bottom() - start_in_native.y()) | |
| 366 ? native_bounds.y() | |
| 367 : native_bounds.bottom() - 1; | |
| 368 return gfx::Rect(std::min(start_in_native.x(), end_in_native.x()), y, | |
| 369 std::abs(end_in_native.x() - start_in_native.x()), 1); | |
| 370 } | |
| 371 } | |
| 372 | |
| 373 // Moves the cursor to the point inside the root that is closest to | |
| 374 // the point_in_screen, which is outside of the root window. | |
| 375 void MoveCursorTo(AshWindowTreeHost* ash_host, | |
| 376 const gfx::Point& point_in_screen, | |
| 377 bool update_last_location_now) { | |
| 378 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | |
| 379 gfx::Point point_in_native = point_in_screen; | |
| 380 ::wm::ConvertPointFromScreen(host->window(), &point_in_native); | |
| 381 host->ConvertPointToNativeScreen(&point_in_native); | |
| 382 | |
| 383 // now fit the point inside the native bounds. | |
| 384 gfx::Rect native_bounds = host->GetBounds(); | |
| 385 gfx::Point native_origin = native_bounds.origin(); | |
| 386 native_bounds.Inset(ash_host->GetHostInsets()); | |
| 387 // Shrink further so that the mouse doesn't warp on the | |
| 388 // edge. The right/bottom needs to be shrink by 2 to subtract | |
| 389 // the 1 px from width/height value. | |
| 390 native_bounds.Inset(1, 1, 2, 2); | |
| 391 | |
| 392 // Ensure that |point_in_native| is inside the |native_bounds|. | |
| 393 point_in_native.SetToMax(native_bounds.origin()); | |
| 394 point_in_native.SetToMin(native_bounds.bottom_right()); | |
| 395 | |
| 396 gfx::Point point_in_host = point_in_native; | |
| 397 | |
| 398 point_in_host.Offset(-native_origin.x(), -native_origin.y()); | |
| 399 host->MoveCursorToHostLocation(point_in_host); | |
| 400 | |
| 401 if (update_last_location_now) { | |
| 402 gfx::Point new_point_in_screen; | |
| 403 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) { | |
| 404 new_point_in_screen = point_in_host; | |
| 405 // First convert to the unified host. | |
| 406 host->ConvertPointFromHost(&new_point_in_screen); | |
| 407 // Then convert to the unified screen. | |
| 408 Shell::GetPrimaryRootWindow()->GetHost()->ConvertPointFromHost( | |
| 409 &new_point_in_screen); | |
| 410 } else { | |
| 411 new_point_in_screen = point_in_native; | |
| 412 host->ConvertPointFromNativeScreen(&new_point_in_screen); | |
| 413 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); | |
| 414 } | |
| 415 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); | |
| 416 } | |
| 417 } | |
| 418 | |
| 419 int FindDisplayIndexContainingPoint( | 256 int FindDisplayIndexContainingPoint( |
| 420 const std::vector<display::Display>& displays, | 257 const std::vector<display::Display>& displays, |
| 421 const gfx::Point& point_in_screen) { | 258 const gfx::Point& point_in_screen) { |
| 422 auto iter = std::find_if(displays.begin(), displays.end(), | 259 auto iter = std::find_if(displays.begin(), displays.end(), |
| 423 [point_in_screen](const display::Display& display) { | 260 [point_in_screen](const display::Display& display) { |
| 424 return display.bounds().Contains(point_in_screen); | 261 return display.bounds().Contains(point_in_screen); |
| 425 }); | 262 }); |
| 426 return iter == displays.end() ? -1 : (iter - displays.begin()); | 263 return iter == displays.end() ? -1 : (iter - displays.begin()); |
| 427 } | 264 } |
| 428 | 265 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 451 DCHECK_NE(id1, id2); | 288 DCHECK_NE(id1, id2); |
| 452 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID | 289 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID |
| 453 // in edid_parser.cc. | 290 // in edid_parser.cc. |
| 454 int index_1 = id1 & 0xFF; | 291 int index_1 = id1 & 0xFF; |
| 455 int index_2 = id2 & 0xFF; | 292 int index_2 = id2 & 0xFF; |
| 456 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; | 293 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; |
| 457 return display::Display::IsInternalDisplayId(id1) || | 294 return display::Display::IsInternalDisplayId(id1) || |
| 458 (index_1 < index_2 && !display::Display::IsInternalDisplayId(id2)); | 295 (index_1 < index_2 && !display::Display::IsInternalDisplayId(id2)); |
| 459 } | 296 } |
| 460 | 297 |
| 461 #if defined(OS_CHROMEOS) | 298 } // namespace display |
| 462 void ShowDisplayErrorNotification(int message_id) { | |
| 463 // Always remove the notification to make sure the notification appears | |
| 464 // as a popup in any situation. | |
| 465 message_center::MessageCenter::Get()->RemoveNotification( | |
| 466 kDisplayErrorNotificationId, false /* by_user */); | |
| 467 | |
| 468 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | |
| 469 std::unique_ptr<message_center::Notification> notification( | |
| 470 new message_center::Notification( | |
| 471 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId, | |
| 472 base::string16(), // title | |
| 473 l10n_util::GetStringUTF16(message_id), | |
| 474 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), | |
| 475 base::string16(), // display_source | |
| 476 GURL(), message_center::NotifierId( | |
| 477 message_center::NotifierId::SYSTEM_COMPONENT, | |
| 478 system_notifier::kNotifierDisplayError), | |
| 479 message_center::RichNotificationData(), | |
| 480 new DisplayErrorNotificationDelegate)); | |
| 481 message_center::MessageCenter::Get()->AddNotification( | |
| 482 std::move(notification)); | |
| 483 } | |
| 484 #endif | |
| 485 | |
| 486 base::string16 GetDisplayErrorNotificationMessageForTest() { | |
| 487 message_center::NotificationList::Notifications notifications = | |
| 488 message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
| 489 for (auto* const notification : notifications) { | |
| 490 if (notification->id() == kDisplayErrorNotificationId) | |
| 491 return notification->message(); | |
| 492 } | |
| 493 return base::string16(); | |
| 494 } | |
| 495 | |
| 496 } // namespace ash | |
| OLD | NEW |