Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_ |
| 6 #define ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_ | 6 #define ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // ScreenLayoutObserver is responsible to send notification to users when screen | 22 // ScreenLayoutObserver is responsible to send notification to users when screen |
| 23 // resolution changes or screen rotation changes. | 23 // resolution changes or screen rotation changes. |
| 24 class ASH_EXPORT ScreenLayoutObserver : public WmDisplayObserver { | 24 class ASH_EXPORT ScreenLayoutObserver : public WmDisplayObserver { |
| 25 public: | 25 public: |
| 26 ScreenLayoutObserver(); | 26 ScreenLayoutObserver(); |
| 27 ~ScreenLayoutObserver() override; | 27 ~ScreenLayoutObserver() override; |
| 28 | 28 |
| 29 // Overridden from WmDisplayObserver: | 29 // Overridden from WmDisplayObserver: |
| 30 void OnDisplayConfigurationChanged() override; | 30 void OnDisplayConfigurationChanged() override; |
| 31 | 31 |
| 32 // Allow tests to suppress showing notifications. | |
|
oshima
2016/10/11 20:50:34
nit: update the comment. (or clarify as it sounds
James Cook
2016/10/11 20:58:17
Done.
| |
| 33 void set_show_notifications_for_testing(bool show) { | |
| 34 show_notifications_for_testing = show; | |
| 35 } | |
| 36 | |
| 32 private: | 37 private: |
| 33 friend class ScreenLayoutObserverTest; | 38 friend class ScreenLayoutObserverTest; |
| 34 | 39 |
| 35 using DisplayInfoMap = std::map<int64_t, display::ManagedDisplayInfo>; | 40 using DisplayInfoMap = std::map<int64_t, display::ManagedDisplayInfo>; |
| 36 | 41 |
| 37 static const char kNotificationId[]; | 42 static const char kNotificationId[]; |
| 38 | 43 |
| 39 // Scans the current display info and updates |display_info_|. Sets the | 44 // Scans the current display info and updates |display_info_|. Sets the |
| 40 // previous data to |old_info| if it's not NULL. | 45 // previous data to |old_info| if it's not NULL. |
| 41 void UpdateDisplayInfo(DisplayInfoMap* old_info); | 46 void UpdateDisplayInfo(DisplayInfoMap* old_info); |
| 42 | 47 |
| 43 // Compares the current display settings with |old_info| and determine what | 48 // Compares the current display settings with |old_info| and determine what |
| 44 // message should be shown for notification. Returns true if there's a | 49 // message should be shown for notification. Returns true if there's a |
| 45 // meaningful change. Note that it's possible to return true and set | 50 // meaningful change. Note that it's possible to return true and set |
| 46 // |message_out| to empty, which means the notification should be removed. It | 51 // |message_out| to empty, which means the notification should be removed. It |
| 47 // also sets |additional_message_out| which appears in the notification with | 52 // also sets |additional_message_out| which appears in the notification with |
| 48 // the |message_out|. | 53 // the |message_out|. |
| 49 bool GetDisplayMessageForNotification(const DisplayInfoMap& old_info, | 54 bool GetDisplayMessageForNotification(const DisplayInfoMap& old_info, |
| 50 base::string16* message_out, | 55 base::string16* message_out, |
| 51 base::string16* additional_message_out); | 56 base::string16* additional_message_out); |
| 52 | 57 |
| 53 // Creates or updates the display notification. | 58 // Creates or updates the display notification. |
| 54 void CreateOrUpdateNotification(const base::string16& message, | 59 void CreateOrUpdateNotification(const base::string16& message, |
| 55 const base::string16& additional_message); | 60 const base::string16& additional_message); |
| 56 | 61 |
| 57 DisplayInfoMap display_info_; | 62 DisplayInfoMap display_info_; |
| 58 | 63 |
| 64 bool show_notifications_for_testing = true; | |
| 65 | |
| 59 DISALLOW_COPY_AND_ASSIGN(ScreenLayoutObserver); | 66 DISALLOW_COPY_AND_ASSIGN(ScreenLayoutObserver); |
| 60 }; | 67 }; |
| 61 | 68 |
| 62 } // namespace ash | 69 } // namespace ash |
| 63 | 70 |
| 64 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_ | 71 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_ |
| OLD | NEW |