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

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

Issue 2490323003: Improve monitor compatibility error, move feedback link into button (Closed)
Patch Set: Remove display_notification.1x.icon Created 4 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
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 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/system/system_notifier.h" 10 #include "ash/common/system/system_notifier.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/display/extended_mouse_warp_controller.h" 12 #include "ash/display/extended_mouse_warp_controller.h"
13 #include "ash/display/null_mouse_warp_controller.h" 13 #include "ash/display/null_mouse_warp_controller.h"
14 #include "ash/display/unified_mouse_warp_controller.h" 14 #include "ash/display/unified_mouse_warp_controller.h"
15 #include "ash/host/ash_window_tree_host.h" 15 #include "ash/host/ash_window_tree_host.h"
16 #include "ash/public/interfaces/new_window.mojom.h" 16 #include "ash/public/interfaces/new_window.mojom.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "grit/ash_resources.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "grit/ash_strings.h"
20 #include "ui/aura/env.h" 21 #include "ui/aura/env.h"
21 #include "ui/aura/window_tree_host.h" 22 #include "ui/aura/window_tree_host.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/display/display.h" 24 #include "ui/display/display.h"
25 #include "ui/display/manager/display_manager.h" 25 #include "ui/display/manager/display_manager.h"
26 #include "ui/display/manager/managed_display_info.h" 26 #include "ui/display/manager/managed_display_info.h"
27 #include "ui/gfx/geometry/point.h" 27 #include "ui/gfx/geometry/point.h"
28 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/size_conversions.h" 29 #include "ui/gfx/geometry/size_conversions.h"
30 #include "ui/message_center/message_center.h" 30 #include "ui/message_center/message_center.h"
31 #include "ui/message_center/notification.h" 31 #include "ui/message_center/notification.h"
32 #include "ui/message_center/notification_delegate.h" 32 #include "ui/message_center/notification_delegate.h"
33 #include "ui/message_center/notification_list.h" 33 #include "ui/message_center/notification_list.h"
34 #include "ui/wm/core/coordinate_conversion.h" 34 #include "ui/wm/core/coordinate_conversion.h"
35 35
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 #include "ash/resources/vector_icons/vector_icons.h"
37 #include "base/sys_info.h" 38 #include "base/sys_info.h"
39 #include "ui/gfx/paint_vector_icon.h"
38 #endif 40 #endif
39 41
40 namespace ash { 42 namespace ash {
41 namespace { 43 namespace {
42 44
43 const char kDisplayErrorNotificationId[] = "chrome://settings/display/error"; 45 const char kDisplayErrorNotificationId[] = "chrome://settings/display/error";
44 46
47 #if defined(OS_CHROMEOS)
48 // TODO: These are for new MD vector icons, but are using pre-MD color scheme.
Evan Stade 2016/12/05 22:53:10 please put your name in the TODO (to indicate you
Greg Levin 2016/12/06 22:44:49 Done. Although... I had always thought the name w
Evan Stade 2016/12/06 23:42:18 I certainly hope that I'm not on the hook for all
Greg Levin 2016/12/12 22:36:43 Acknowledged.
49 // When we switch to all MD icons for notifications, these should be updated to
50 // use MD color scheme.
51 const SkColor kDisplayIconColor = 0xFFBDBDBD;
Evan Stade 2016/12/05 22:53:10 nit: SkColorSetRGB(0xBD, 0xBD, 0xBD); (similar be
Greg Levin 2016/12/06 22:44:49 Done.
52 const SkColor kFeedbackIconColor = 0xFF969698;
53 #endif
54
45 // A notification delegate that will start the feedback app when the notication 55 // A notification delegate that will start the feedback app when the notication
46 // is clicked. 56 // is clicked.
47 class DisplayErrorNotificationDelegate 57 class DisplayErrorNotificationDelegate
48 : public message_center::NotificationDelegate { 58 : public message_center::NotificationDelegate {
49 public: 59 public:
50 DisplayErrorNotificationDelegate() = default; 60 DisplayErrorNotificationDelegate() = default;
51 61
52 // message_center::NotificationDelegate: 62 // message_center::NotificationDelegate:
53 bool HasClickedListener() override { return true; } 63 void ButtonClick(int index) override {
54 64 DCHECK_EQ(0, index);
55 void Click() override {
56 WmShell::Get()->new_window_client()->OpenFeedbackPage(); 65 WmShell::Get()->new_window_client()->OpenFeedbackPage();
57 } 66 }
58 67
59 private: 68 private:
60 // Private destructor since NotificationDelegate is ref-counted. 69 // Private destructor since NotificationDelegate is ref-counted.
61 ~DisplayErrorNotificationDelegate() override = default; 70 ~DisplayErrorNotificationDelegate() override = default;
62 71
63 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate); 72 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate);
64 }; 73 };
65 74
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 new_point_in_screen = point_in_native; 165 new_point_in_screen = point_in_native;
157 host->ConvertPointFromNativeScreen(&new_point_in_screen); 166 host->ConvertPointFromNativeScreen(&new_point_in_screen);
158 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); 167 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen);
159 } 168 }
160 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); 169 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen);
161 } 170 }
162 } 171 }
163 172
164 173
165 #if defined(OS_CHROMEOS) 174 #if defined(OS_CHROMEOS)
166 void ShowDisplayErrorNotification(int message_id) { 175 void ShowDisplayErrorNotification(base::string16& message,
176 bool allow_feedback) {
167 // Always remove the notification to make sure the notification appears 177 // Always remove the notification to make sure the notification appears
168 // as a popup in any situation. 178 // as a popup in any situation.
169 message_center::MessageCenter::Get()->RemoveNotification( 179 message_center::MessageCenter::Get()->RemoveNotification(
170 kDisplayErrorNotificationId, false /* by_user */); 180 kDisplayErrorNotificationId, false /* by_user */);
171 181
172 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 182 message_center::RichNotificationData optional_field;
183 if (allow_feedback) {
184 message_center::ButtonInfo send_button(
185 l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_SEND_FEEDBACK));
186 send_button.icon = gfx::Image(
187 CreateVectorIcon(kNotificationFeedbackIcon, kFeedbackIconColor));
188 optional_field.buttons.push_back(send_button);
189 }
190
173 std::unique_ptr<message_center::Notification> notification( 191 std::unique_ptr<message_center::Notification> notification(
174 new message_center::Notification( 192 new message_center::Notification(
175 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId, 193 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId,
176 base::string16(), // title 194 base::string16(), // title
177 l10n_util::GetStringUTF16(message_id), 195 message, gfx::Image(CreateVectorIcon(kDisplayNotificationIcon,
178 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), 196 kDisplayIconColor)),
179 base::string16(), // display_source 197 base::string16(), // display_source
180 GURL(), message_center::NotifierId( 198 GURL(), message_center::NotifierId(
181 message_center::NotifierId::SYSTEM_COMPONENT, 199 message_center::NotifierId::SYSTEM_COMPONENT,
182 system_notifier::kNotifierDisplayError), 200 system_notifier::kNotifierDisplayError),
183 message_center::RichNotificationData(), 201 optional_field, new DisplayErrorNotificationDelegate));
184 new DisplayErrorNotificationDelegate));
185 message_center::MessageCenter::Get()->AddNotification( 202 message_center::MessageCenter::Get()->AddNotification(
186 std::move(notification)); 203 std::move(notification));
187 } 204 }
188 #endif 205 #endif
189 206
190 base::string16 GetDisplayErrorNotificationMessageForTest() { 207 base::string16 GetDisplayErrorNotificationMessageForTest() {
191 message_center::NotificationList::Notifications notifications = 208 message_center::NotificationList::Notifications notifications =
192 message_center::MessageCenter::Get()->GetVisibleNotifications(); 209 message_center::MessageCenter::Get()->GetVisibleNotifications();
193 for (auto* const notification : notifications) { 210 for (auto* const notification : notifications) {
194 if (notification->id() == kDisplayErrorNotificationId) 211 if (notification->id() == kDisplayErrorNotificationId)
195 return notification->message(); 212 return notification->message();
196 } 213 }
197 return base::string16(); 214 return base::string16();
198 } 215 }
199 216
200 } // namespace ash 217 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698