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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_util.cc
diff --git a/ash/display/display_util.cc b/ash/display/display_util.cc
index afa67d2a91aa5538ad6b34201cce16c3e5179755..ec36ab2336b6c3f12b45e936f67a71a0de47baf8 100644
--- a/ash/display/display_util.cc
+++ b/ash/display/display_util.cc
@@ -9,14 +9,23 @@
#include "ash/display/display_info.h"
#include "ash/display/display_manager.h"
#include "ash/host/ash_window_tree_host.h"
+#include "ash/new_window_delegate.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "base/strings/string_number_conversions.h"
+#include "grit/ash_resources.h"
#include "ui/aura/env.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size_conversions.h"
+#include "ui/message_center/message_center.h"
+#include "ui/message_center/notification.h"
+#include "ui/message_center/notification_delegate.h"
+#include "ui/message_center/notification_list.h"
#include "ui/wm/core/coordinate_conversion.h"
#if defined(OS_CHROMEOS)
@@ -26,6 +35,29 @@
namespace ash {
namespace {
+const char kDisplayErrorNotificationId[] = "chrome://settings/display/error";
+
+// A notification delegate that will start the feedback app when the notication
+// is clicked.
+class DisplayErrorNotificationDelegate
+ : public message_center::NotificationDelegate {
+ public:
+ DisplayErrorNotificationDelegate() = default;
+
+ // message_center::NotificationDelegate:
+ bool HasClickedListener() override { return true; }
+
+ void Click() override {
+ ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
+ }
+
+ private:
+ // Private destructor since NotificationDelegate is ref-counted.
+ ~DisplayErrorNotificationDelegate() override = default;
+
+ DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate);
+};
+
// List of value UI Scale values. Scales for 2x are equivalent to 640,
// 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on
// 2560 pixel width 2x density display. Please see crbug.com/233375
@@ -407,4 +439,37 @@ bool CompareDisplayIds(int64_t id1, int64_t id2) {
(index_1 < index_2 && !display::Display::IsInternalDisplayId(id2));
}
+void ShowDisplayErrorNotification(int message_id) {
+ // Always remove the notification to make sure the notification appears
+ // as a popup in any situation.
+ message_center::MessageCenter::Get()->RemoveNotification(
+ kDisplayErrorNotificationId, false /* by_user */);
+
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ std::unique_ptr<message_center::Notification> notification(
+ new message_center::Notification(
+ message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId,
+ base::string16(), // title
+ l10n_util::GetStringUTF16(message_id),
+ bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY),
+ base::string16(), // display_source
+ GURL(), message_center::NotifierId(
+ message_center::NotifierId::SYSTEM_COMPONENT,
+ system_notifier::kNotifierDisplayError),
+ message_center::RichNotificationData(),
+ new DisplayErrorNotificationDelegate));
+ message_center::MessageCenter::Get()->AddNotification(
+ std::move(notification));
+}
+
+base::string16 GetDisplayErrorNotificationMessageForTest() {
+ message_center::NotificationList::Notifications notifications =
+ message_center::MessageCenter::Get()->GetVisibleNotifications();
+ for (auto const notification : notifications) {
+ if (notification->id() == kDisplayErrorNotificationId)
+ return notification->message();
+ }
+ return base::string16();
+}
+
} // namespace ash
« 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