Chromium Code Reviews| 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" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 // A class which manages the notification of display resolution change and | 25 // A class which manages the notification of display resolution change and |
| 26 // also manages the timeout in case the new resolution is unusable. | 26 // also manages the timeout in case the new resolution is unusable. |
| 27 class ASH_EXPORT ResolutionNotificationController | 27 class ASH_EXPORT ResolutionNotificationController |
| 28 : public display::DisplayObserver, | 28 : public display::DisplayObserver, |
| 29 public WindowTreeHostManager::Observer { | 29 public WindowTreeHostManager::Observer { |
| 30 public: | 30 public: |
| 31 ResolutionNotificationController(); | 31 ResolutionNotificationController(); |
| 32 ~ResolutionNotificationController() override; | 32 ~ResolutionNotificationController() override; |
| 33 | 33 |
| 34 // Prepare a resolution change notification for |display_id| from | 34 // If |display_id| is not the internal display, Prepare a resolution change |
| 35 // |old_resolution| to |new_resolution|, which offers a button to revert the | 35 // notification for |display_id| from |old_resolution| to |new_resolution|, |
| 36 // change in case something goes wrong. The notification times out if there's | 36 // which offers a button to revert the change in case something goes wrong. |
| 37 // only one display connected and the user is trying to modify its resolution. | 37 // The notification times out if there's only one display connected and the |
| 38 // In that case, the timeout has to be set since the user cannot make any | 38 // user is trying to modify its resolution. In that case, the timeout has to |
| 39 // changes if something goes wrong. | 39 // be set since the user cannot make any changes if something goes wrong. |
| 40 // | |
| 41 // Then call DisplayManager::SetDisplayMode() to apply the resolution change, | |
| 42 // and return the result; true if success, false otherwise. | |
| 43 // In case SetDisplayMode() fails, the prepared notification will be | |
| 44 // discarded. | |
| 45 // | |
| 46 // If |display_id| is the internal display, the resolution change is applied | |
| 47 // directly without preparing the confirm/revert notification (this kind of | |
| 48 // notification is only useful for external displays). | |
| 40 // | 49 // |
| 41 // This method does not create a notification itself. The notification will be | 50 // This method does not create a notification itself. The notification will be |
| 42 // created the next OnDisplayConfigurationChanged(), which will be called | 51 // created the next OnDisplayConfigurationChanged(), which will be called |
| 43 // asynchronously after the resolution change is requested. So typically this | 52 // asynchronously after the resolution change is requested by this method. |
| 44 // method will be combined with resolution change methods like | 53 // |
| 45 // DisplayManager::SetDisplayMode(). | 54 // |accept_callback| will be called when the user accepts the resoltion change |
| 46 void PrepareNotification( | 55 // by closing the notification bubble or clicking on the accept button (if |
| 56 // any). | |
| 57 bool PrepareNotificationAndSetDisplayMode( | |
| 47 int64_t display_id, | 58 int64_t display_id, |
| 48 const scoped_refptr<display::ManagedDisplayMode>& old_resolution, | 59 const scoped_refptr<display::ManagedDisplayMode>& old_resolution, |
| 49 const scoped_refptr<display::ManagedDisplayMode>& new_resolution, | 60 const scoped_refptr<display::ManagedDisplayMode>& new_resolution, |
| 50 const base::Closure& accept_callback); | 61 const base::Closure& accept_callback) WARN_UNUSED_RESULT; |
|
stevenjb
2017/04/10 17:33:52
I like this change and the explanation, but should
oshima
2017/04/10 17:46:18
I don't have strong opinion, and leave it to you g
afakhry
2017/04/10 23:26:21
I also don't have a strong opinion about this, but
| |
| 51 | 62 |
| 52 // Returns true if the notification is visible or scheduled to be visible and | 63 // Returns true if the notification is visible or scheduled to be visible and |
| 53 // the notification times out. | 64 // the notification times out. |
| 54 bool DoesNotificationTimeout(); | 65 bool DoesNotificationTimeout(); |
| 55 | 66 |
| 56 // Called by the notification delegate when the user accepts the display | 67 // Called by the notification delegate when the user accepts the display |
| 57 // resolution change. Set |close_notification| to true when the notification | 68 // resolution change. Set |close_notification| to true when the notification |
| 58 // should be removed. | 69 // should be removed. |
| 59 void AcceptResolutionChange(bool close_notification); | 70 void AcceptResolutionChange(bool close_notification); |
| 60 | 71 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 static void SuppressTimerForTest(); | 105 static void SuppressTimerForTest(); |
| 95 | 106 |
| 96 std::unique_ptr<ResolutionChangeInfo> change_info_; | 107 std::unique_ptr<ResolutionChangeInfo> change_info_; |
| 97 | 108 |
| 98 DISALLOW_COPY_AND_ASSIGN(ResolutionNotificationController); | 109 DISALLOW_COPY_AND_ASSIGN(ResolutionNotificationController); |
| 99 }; | 110 }; |
| 100 | 111 |
| 101 } // namespace ash | 112 } // namespace ash |
| 102 | 113 |
| 103 #endif // ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ | 114 #endif // ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ |
| OLD | NEW |