OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resolution_notification_controller.h" | 5 #include "ash/display/resolution_notification_controller.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 void ResolutionChangeNotificationDelegate::Display() { | 66 void ResolutionChangeNotificationDelegate::Display() { |
67 } | 67 } |
68 | 68 |
69 void ResolutionChangeNotificationDelegate::Error() { | 69 void ResolutionChangeNotificationDelegate::Error() { |
70 } | 70 } |
71 | 71 |
72 void ResolutionChangeNotificationDelegate::Close(bool by_user) { | 72 void ResolutionChangeNotificationDelegate::Close(bool by_user) { |
73 if (by_user) | 73 if (by_user) |
74 controller_->AcceptResolutionChange(); | 74 controller_->AcceptResolutionChange(false); |
75 } | 75 } |
76 | 76 |
77 void ResolutionChangeNotificationDelegate::Click() { | 77 void ResolutionChangeNotificationDelegate::Click() { |
78 controller_->AcceptResolutionChange(); | 78 controller_->AcceptResolutionChange(true); |
79 } | 79 } |
80 | 80 |
81 bool ResolutionChangeNotificationDelegate::HasClickedListener() { | 81 bool ResolutionChangeNotificationDelegate::HasClickedListener() { |
82 return true; | 82 return true; |
83 } | 83 } |
84 | 84 |
85 void ResolutionChangeNotificationDelegate::ButtonClick(int button_index) { | 85 void ResolutionChangeNotificationDelegate::ButtonClick(int button_index) { |
86 // If there's the timeout, the first button is "Accept". Otherwise the | 86 // If there's the timeout, the first button is "Accept". Otherwise the |
87 // button click should be "Revert". | 87 // button click should be "Revert". |
88 if (has_timeout_ && button_index == 0) | 88 if (has_timeout_ && button_index == 0) |
89 controller_->AcceptResolutionChange(); | 89 controller_->AcceptResolutionChange(true); |
90 else | 90 else |
91 controller_->RevertResolutionChange(); | 91 controller_->RevertResolutionChange(); |
92 } | 92 } |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 // static | 96 // static |
97 const int ResolutionNotificationController::kTimeoutInSec = 15; | 97 const int ResolutionNotificationController::kTimeoutInSec = 15; |
98 | 98 |
99 // static | 99 // static |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (!change_info_) | 236 if (!change_info_) |
237 return; | 237 return; |
238 | 238 |
239 --change_info_->timeout_count; | 239 --change_info_->timeout_count; |
240 if (change_info_->timeout_count == 0) | 240 if (change_info_->timeout_count == 0) |
241 RevertResolutionChange(); | 241 RevertResolutionChange(); |
242 else | 242 else |
243 CreateOrUpdateNotification(); | 243 CreateOrUpdateNotification(); |
244 } | 244 } |
245 | 245 |
246 void ResolutionNotificationController::AcceptResolutionChange() { | 246 void ResolutionNotificationController::AcceptResolutionChange( |
247 message_center::MessageCenter::Get()->RemoveNotification( | 247 bool close_notification) { |
248 kNotificationId, false /* by_user */); | 248 if (close_notification) { |
| 249 message_center::MessageCenter::Get()->RemoveNotification( |
| 250 kNotificationId, false /* by_user */); |
| 251 } |
249 base::Closure callback = change_info_->accept_callback; | 252 base::Closure callback = change_info_->accept_callback; |
250 change_info_.reset(); | 253 change_info_.reset(); |
251 callback.Run(); | 254 callback.Run(); |
252 } | 255 } |
253 | 256 |
254 void ResolutionNotificationController::RevertResolutionChange() { | 257 void ResolutionNotificationController::RevertResolutionChange() { |
255 message_center::MessageCenter::Get()->RemoveNotification( | 258 message_center::MessageCenter::Get()->RemoveNotification( |
256 kNotificationId, false /* by_user */); | 259 kNotificationId, false /* by_user */); |
257 int64 display_id = change_info_->display_id; | 260 int64 display_id = change_info_->display_id; |
258 gfx::Size old_resolution = change_info_->old_resolution; | 261 gfx::Size old_resolution = change_info_->old_resolution; |
(...skipping 28 matching lines...) Expand all Loading... |
287 &ResolutionNotificationController::OnTimerTick); | 290 &ResolutionNotificationController::OnTimerTick); |
288 } | 291 } |
289 } | 292 } |
290 | 293 |
291 void ResolutionNotificationController::SuppressTimerForTest() { | 294 void ResolutionNotificationController::SuppressTimerForTest() { |
292 g_use_timer = false; | 295 g_use_timer = false; |
293 } | 296 } |
294 | 297 |
295 } // namespace internal | 298 } // namespace internal |
296 } // namespace ash | 299 } // namespace ash |
OLD | NEW |