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

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

Issue 2490323003: Improve monitor compatibility error, move feedback link into button (Closed)
Patch Set: Fix vector icons (2nd try) Created 4 years, 1 month 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') | ash/resources/vector_icons/BUILD.gn » ('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 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";
46 const SkColor kNotificationIconColor = 0xFFBDBDBD;
44 47
45 // A notification delegate that will start the feedback app when the notication 48 // A notification delegate that will start the feedback app when the notication
46 // is clicked. 49 // is clicked.
47 class DisplayErrorNotificationDelegate 50 class DisplayErrorNotificationDelegate
48 : public message_center::NotificationDelegate { 51 : public message_center::NotificationDelegate {
49 public: 52 public:
50 DisplayErrorNotificationDelegate() = default; 53 DisplayErrorNotificationDelegate() = default;
51 54
52 // message_center::NotificationDelegate: 55 // message_center::NotificationDelegate:
53 bool HasClickedListener() override { return true; } 56 void ButtonClick(int index) override {
54 57 DCHECK(index == 0);
oshima 2016/11/22 21:51:56 DCHECK_EQ.
Greg Levin 2016/11/29 16:26:28 Done.
55 void Click() override {
56 WmShell::Get()->new_window_client()->OpenFeedbackPage(); 58 WmShell::Get()->new_window_client()->OpenFeedbackPage();
57 } 59 }
58 60
59 private: 61 private:
60 // Private destructor since NotificationDelegate is ref-counted. 62 // Private destructor since NotificationDelegate is ref-counted.
61 ~DisplayErrorNotificationDelegate() override = default; 63 ~DisplayErrorNotificationDelegate() override = default;
62 64
63 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate); 65 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate);
64 }; 66 };
65 67
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 new_point_in_screen = point_in_native; 158 new_point_in_screen = point_in_native;
157 host->ConvertPointFromNativeScreen(&new_point_in_screen); 159 host->ConvertPointFromNativeScreen(&new_point_in_screen);
158 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); 160 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen);
159 } 161 }
160 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); 162 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen);
161 } 163 }
162 } 164 }
163 165
164 166
165 #if defined(OS_CHROMEOS) 167 #if defined(OS_CHROMEOS)
166 void ShowDisplayErrorNotification(int message_id) { 168 void ShowDisplayErrorNotification(base::string16& message,
169 bool allow_feedback) {
167 // Always remove the notification to make sure the notification appears 170 // Always remove the notification to make sure the notification appears
168 // as a popup in any situation. 171 // as a popup in any situation.
169 message_center::MessageCenter::Get()->RemoveNotification( 172 message_center::MessageCenter::Get()->RemoveNotification(
170 kDisplayErrorNotificationId, false /* by_user */); 173 kDisplayErrorNotificationId, false /* by_user */);
171 174
172 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 175 message_center::RichNotificationData optional_field;
176 if (allow_feedback) {
177 message_center::ButtonInfo send_button(
178 l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_SEND_FEEDBACK));
179 send_button.icon = gfx::Image(
180 CreateVectorIcon(kNotificationFeedbackIcon, kNotificationIconColor));
181 optional_field.buttons.push_back(send_button);
182 }
183
173 std::unique_ptr<message_center::Notification> notification( 184 std::unique_ptr<message_center::Notification> notification(
174 new message_center::Notification( 185 new message_center::Notification(
175 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId, 186 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId,
176 base::string16(), // title 187 base::string16(), // title
177 l10n_util::GetStringUTF16(message_id), 188 message, gfx::Image(CreateVectorIcon(kDisplayNotificationIcon,
178 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), 189 kNotificationIconColor)),
179 base::string16(), // display_source 190 base::string16(), // display_source
180 GURL(), message_center::NotifierId( 191 GURL(), message_center::NotifierId(
181 message_center::NotifierId::SYSTEM_COMPONENT, 192 message_center::NotifierId::SYSTEM_COMPONENT,
182 system_notifier::kNotifierDisplayError), 193 system_notifier::kNotifierDisplayError),
183 message_center::RichNotificationData(), 194 optional_field, new DisplayErrorNotificationDelegate));
184 new DisplayErrorNotificationDelegate));
185 message_center::MessageCenter::Get()->AddNotification( 195 message_center::MessageCenter::Get()->AddNotification(
186 std::move(notification)); 196 std::move(notification));
187 } 197 }
188 #endif 198 #endif
189 199
190 base::string16 GetDisplayErrorNotificationMessageForTest() { 200 base::string16 GetDisplayErrorNotificationMessageForTest() {
191 message_center::NotificationList::Notifications notifications = 201 message_center::NotificationList::Notifications notifications =
192 message_center::MessageCenter::Get()->GetVisibleNotifications(); 202 message_center::MessageCenter::Get()->GetVisibleNotifications();
193 for (auto* const notification : notifications) { 203 for (auto* const notification : notifications) {
194 if (notification->id() == kDisplayErrorNotificationId) 204 if (notification->id() == kDisplayErrorNotificationId)
195 return notification->message(); 205 return notification->message();
196 } 206 }
197 return base::string16(); 207 return base::string16();
198 } 208 }
199 209
200 } // namespace ash 210 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_util.h ('k') | ash/resources/vector_icons/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698