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