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

Side by Side Diff: ash/display/display_util.cc

Issue 1952353003: Show message to indicate that mirriring with more than 3 display is not supported. (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
« no previous file with comments | « ash/display/display_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "ash/display/display_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
11 #include "ash/host/ash_window_tree_host.h" 11 #include "ash/host/ash_window_tree_host.h"
12 #include "ash/new_window_delegate.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/system/system_notifier.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "grit/ash_resources.h"
14 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
15 #include "ui/aura/window_tree_host.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"
16 #include "ui/display/display.h" 21 #include "ui/display/display.h"
17 #include "ui/gfx/geometry/point.h" 22 #include "ui/gfx/geometry/point.h"
18 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/size_conversions.h" 24 #include "ui/gfx/geometry/size_conversions.h"
25 #include "ui/message_center/message_center.h"
26 #include "ui/message_center/notification.h"
27 #include "ui/message_center/notification_delegate.h"
28 #include "ui/message_center/notification_list.h"
20 #include "ui/wm/core/coordinate_conversion.h" 29 #include "ui/wm/core/coordinate_conversion.h"
21 30
22 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
23 #include "base/sys_info.h" 32 #include "base/sys_info.h"
24 #endif 33 #endif
25 34
26 namespace ash { 35 namespace ash {
27 namespace { 36 namespace {
28 37
38 const char kDisplayErrorNotificationId[] = "chrome://settings/display/error";
39
40 // A notification delegate that will start the feedback app when the notication
41 // is clicked.
42 class DisplayErrorNotificationDelegate
43 : public message_center::NotificationDelegate {
44 public:
45 DisplayErrorNotificationDelegate() = default;
46
47 // message_center::NotificationDelegate:
48 bool HasClickedListener() override { return true; }
49
50 void Click() override {
51 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
52 }
53
54 private:
55 // Private destructor since NotificationDelegate is ref-counted.
56 ~DisplayErrorNotificationDelegate() override = default;
57
58 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate);
59 };
60
29 // List of value UI Scale values. Scales for 2x are equivalent to 640, 61 // List of value UI Scale values. Scales for 2x are equivalent to 640,
30 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on 62 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on
31 // 2560 pixel width 2x density display. Please see crbug.com/233375 63 // 2560 pixel width 2x density display. Please see crbug.com/233375
32 // for the full list of resolutions. 64 // for the full list of resolutions.
33 const float kUIScalesFor2x[] = 65 const float kUIScalesFor2x[] =
34 {0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f, 2.0f}; 66 {0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f, 2.0f};
35 const float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f }; 67 const float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f };
36 const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f }; 68 const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f };
37 const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f }; 69 const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f };
38 70
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 DCHECK_NE(id1, id2); 432 DCHECK_NE(id1, id2);
401 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID 433 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID
402 // in edid_parser.cc. 434 // in edid_parser.cc.
403 int index_1 = id1 & 0xFF; 435 int index_1 = id1 & 0xFF;
404 int index_2 = id2 & 0xFF; 436 int index_2 = id2 & 0xFF;
405 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; 437 DCHECK_NE(index_1, index_2) << id1 << " and " << id2;
406 return display::Display::IsInternalDisplayId(id1) || 438 return display::Display::IsInternalDisplayId(id1) ||
407 (index_1 < index_2 && !display::Display::IsInternalDisplayId(id2)); 439 (index_1 < index_2 && !display::Display::IsInternalDisplayId(id2));
408 } 440 }
409 441
442 void ShowDisplayErrorNotification(int message_id) {
443 // Always remove the notification to make sure the notification appears
444 // as a popup in any situation.
445 message_center::MessageCenter::Get()->RemoveNotification(
446 kDisplayErrorNotificationId, false /* by_user */);
447
448 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
449 std::unique_ptr<message_center::Notification> notification(
450 new message_center::Notification(
451 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId,
452 base::string16(), // title
453 l10n_util::GetStringUTF16(message_id),
454 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY),
455 base::string16(), // display_source
456 GURL(), message_center::NotifierId(
457 message_center::NotifierId::SYSTEM_COMPONENT,
458 system_notifier::kNotifierDisplayError),
459 message_center::RichNotificationData(),
460 new DisplayErrorNotificationDelegate));
461 message_center::MessageCenter::Get()->AddNotification(
462 std::move(notification));
463 }
464
465 base::string16 GetDisplayErrorNotificationMessageForTest() {
466 message_center::NotificationList::Notifications notifications =
467 message_center::MessageCenter::Get()->GetVisibleNotifications();
468 for (auto const notification : notifications) {
469 if (notification->id() == kDisplayErrorNotificationId)
470 return notification->message();
471 }
472 return base::string16();
473 }
474
410 } // namespace ash 475 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698