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 #ifndef ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ | 5 #ifndef ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ |
6 #define ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ | 6 #define ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "ui/gfx/display_observer.h" | 13 #include "ui/gfx/display_observer.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 FORWARD_DECLARE_TEST(DisplayPreferencesTest, PreventStore); | 17 FORWARD_DECLARE_TEST(DisplayPreferencesTest, PreventStore); |
18 } // namespace chromeos | 18 } // namespace chromeos |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 class Label; | 21 class Label; |
22 class Widget; | 22 class Widget; |
23 } // namespace views | 23 } // namespace views |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 | 26 |
| 27 struct DisplayMode; |
| 28 |
27 // A class which manages the notification of display resolution change and | 29 // A class which manages the notification of display resolution change and |
28 // also manages the timeout in case the new resolution is unusable. | 30 // also manages the timeout in case the new resolution is unusable. |
29 class ASH_EXPORT ResolutionNotificationController | 31 class ASH_EXPORT ResolutionNotificationController |
30 : public gfx::DisplayObserver, | 32 : public gfx::DisplayObserver, |
31 public DisplayController::Observer { | 33 public DisplayController::Observer { |
32 public: | 34 public: |
33 ResolutionNotificationController(); | 35 ResolutionNotificationController(); |
34 virtual ~ResolutionNotificationController(); | 36 virtual ~ResolutionNotificationController(); |
35 | 37 |
36 // Updates the display resolution for |display_id| to |new_resolution| and | 38 // Prepare a resolution change notification for |display_id| from |
37 // creates a notification for this change which offers a button to revert the | 39 // |old_resolution| to |new_resolution|, which offers a button to revert the |
38 // change in case something goes wrong. The notification times out if there's | 40 // change in case something goes wrong. The notification times out if there's |
39 // only one display connected and the user is trying to modify its resolution. | 41 // only one display connected and the user is trying to modify its resolution. |
40 // In that case, the timeout has to be set since the user cannot make any | 42 // In that case, the timeout has to be set since the user cannot make any |
41 // changes if something goes wrong. | 43 // changes if something goes wrong. |
42 void SetDisplayResolutionAndNotify( | 44 // |
43 int64 display_id, | 45 // This method does not create a notification itself. The notification will be |
44 const gfx::Size& old_resolution, | 46 // created the next OnDisplayConfigurationChanged(), which will be called |
45 const gfx::Size& new_resolution, | 47 // asynchronously after the resolution change is requested. So typically this |
46 const base::Closure& accept_callback); | 48 // method will be combined with resolution change methods like |
| 49 // DisplayManager::SetDisplayMode(). |
| 50 void PrepareNotification(int64 display_id, |
| 51 const DisplayMode& old_resolution, |
| 52 const DisplayMode& new_resolution, |
| 53 const base::Closure& accept_callback); |
47 | 54 |
48 // Returns true if the notification is visible or scheduled to be visible and | 55 // Returns true if the notification is visible or scheduled to be visible and |
49 // the notification times out. | 56 // the notification times out. |
50 bool DoesNotificationTimeout(); | 57 bool DoesNotificationTimeout(); |
51 | 58 |
52 // Called by the notification delegate when the user accepts the display | 59 // Called by the notification delegate when the user accepts the display |
53 // resolution change. Set |close_notification| to true when the notification | 60 // resolution change. Set |close_notification| to true when the notification |
54 // should be removed. | 61 // should be removed. |
55 void AcceptResolutionChange(bool close_notification); | 62 void AcceptResolutionChange(bool close_notification); |
56 | 63 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 static void SuppressTimerForTest(); | 97 static void SuppressTimerForTest(); |
91 | 98 |
92 scoped_ptr<ResolutionChangeInfo> change_info_; | 99 scoped_ptr<ResolutionChangeInfo> change_info_; |
93 | 100 |
94 DISALLOW_COPY_AND_ASSIGN(ResolutionNotificationController); | 101 DISALLOW_COPY_AND_ASSIGN(ResolutionNotificationController); |
95 }; | 102 }; |
96 | 103 |
97 } // namespace ash | 104 } // namespace ash |
98 | 105 |
99 #endif // ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ | 106 #endif // ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ |
OLD | NEW |