| 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_DISPLAY_CHANGE_OBSERVER_CHROMEOS_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_CHROMEOS_H_ |
| 6 #define ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_CHROMEOS_H_ | 6 #define ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
| 13 #include "ash/common/shell_observer.h" | |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "ui/display/chromeos/display_configurator.h" | 15 #include "ui/display/chromeos/display_configurator.h" |
| 16 #include "ui/display/manager/display_string_provider.h" |
| 16 #include "ui/display/manager/managed_display_info.h" | 17 #include "ui/display/manager/managed_display_info.h" |
| 17 #include "ui/events/devices/input_device_event_observer.h" | 18 #include "ui/events/devices/input_device_event_observer.h" |
| 18 | 19 |
| 20 namespace display { |
| 21 class DisplayManager; |
| 22 } |
| 23 |
| 19 namespace ash { | 24 namespace ash { |
| 20 | 25 |
| 21 class DisplayMode; | 26 class DisplayMode; |
| 22 class DisplaySnapshot; | 27 class DisplaySnapshot; |
| 23 | 28 |
| 24 // An object that observes changes in display configuration and | 29 // An object that observes changes in display configuration and updates |
| 25 // update DisplayManagers. | 30 // DisplayManager. |
| 26 class DisplayChangeObserver : public ui::DisplayConfigurator::StateController, | 31 class DisplayChangeObserver : public ui::DisplayConfigurator::StateController, |
| 27 public ui::DisplayConfigurator::Observer, | 32 public ui::DisplayConfigurator::Observer, |
| 28 public ui::InputDeviceEventObserver, | 33 public ui::InputDeviceEventObserver { |
| 29 public ShellObserver { | |
| 30 public: | 34 public: |
| 31 // Returns the mode list for internal display. | 35 // Returns the mode list for internal display. |
| 32 ASH_EXPORT static display::ManagedDisplayInfo::ManagedDisplayModeList | 36 ASH_EXPORT static display::ManagedDisplayInfo::ManagedDisplayModeList |
| 33 GetInternalManagedDisplayModeList( | 37 GetInternalManagedDisplayModeList( |
| 34 const display::ManagedDisplayInfo& display_info, | 38 const display::ManagedDisplayInfo& display_info, |
| 35 const ui::DisplaySnapshot& output); | 39 const ui::DisplaySnapshot& output); |
| 36 | 40 |
| 37 // Returns the resolution list. | 41 // Returns the resolution list. |
| 38 ASH_EXPORT static display::ManagedDisplayInfo::ManagedDisplayModeList | 42 ASH_EXPORT static display::ManagedDisplayInfo::ManagedDisplayModeList |
| 39 GetExternalManagedDisplayModeList(const ui::DisplaySnapshot& output); | 43 GetExternalManagedDisplayModeList(const ui::DisplaySnapshot& output); |
| 40 | 44 |
| 41 DisplayChangeObserver(); | 45 explicit DisplayChangeObserver( |
| 46 std::unique_ptr<display::DisplayStringProvider> string_provider); |
| 42 ~DisplayChangeObserver() override; | 47 ~DisplayChangeObserver() override; |
| 43 | 48 |
| 49 void set_display_manager(display::DisplayManager* display_manager) { |
| 50 display_manager_ = display_manager; |
| 51 } |
| 52 |
| 53 void set_display_configurator(ui::DisplayConfigurator* display_configurator) { |
| 54 display_configurator_ = display_configurator; |
| 55 } |
| 56 |
| 44 // ui::DisplayConfigurator::StateController overrides: | 57 // ui::DisplayConfigurator::StateController overrides: |
| 45 ui::MultipleDisplayState GetStateForDisplayIds( | 58 ui::MultipleDisplayState GetStateForDisplayIds( |
| 46 const ui::DisplayConfigurator::DisplayStateList& outputs) const override; | 59 const ui::DisplayConfigurator::DisplayStateList& outputs) const override; |
| 47 bool GetResolutionForDisplayId(int64_t display_id, | 60 bool GetResolutionForDisplayId(int64_t display_id, |
| 48 gfx::Size* size) const override; | 61 gfx::Size* size) const override; |
| 49 | 62 |
| 50 // Overriden from ui::DisplayConfigurator::Observer: | 63 // Overriden from ui::DisplayConfigurator::Observer: |
| 51 void OnDisplayModeChanged( | 64 void OnDisplayModeChanged( |
| 52 const ui::DisplayConfigurator::DisplayStateList& outputs) override; | 65 const ui::DisplayConfigurator::DisplayStateList& outputs) override; |
| 53 void OnDisplayModeChangeFailed( | 66 void OnDisplayModeChangeFailed( |
| 54 const ui::DisplayConfigurator::DisplayStateList& displays, | 67 const ui::DisplayConfigurator::DisplayStateList& displays, |
| 55 ui::MultipleDisplayState failed_new_state) override; | 68 ui::MultipleDisplayState failed_new_state) override; |
| 56 | 69 |
| 57 // Overriden from ui::InputDeviceEventObserver: | 70 // Overriden from ui::InputDeviceEventObserver: |
| 58 void OnTouchscreenDeviceConfigurationChanged() override; | 71 void OnTouchscreenDeviceConfigurationChanged() override; |
| 59 | 72 |
| 60 // Overriden from ShellObserver: | |
| 61 void OnAppTerminating() override; | |
| 62 | |
| 63 // Exposed for testing. | 73 // Exposed for testing. |
| 64 ASH_EXPORT static float FindDeviceScaleFactor(float dpi); | 74 ASH_EXPORT static float FindDeviceScaleFactor(float dpi); |
| 65 | 75 |
| 66 private: | 76 private: |
| 77 std::unique_ptr<display::DisplayStringProvider> string_provider_; |
| 78 display::DisplayManager* display_manager_ = nullptr; |
| 79 ui::DisplayConfigurator* display_configurator_ = nullptr; |
| 80 |
| 67 DISALLOW_COPY_AND_ASSIGN(DisplayChangeObserver); | 81 DISALLOW_COPY_AND_ASSIGN(DisplayChangeObserver); |
| 68 }; | 82 }; |
| 69 | 83 |
| 70 } // namespace ash | 84 } // namespace ash |
| 71 | 85 |
| 72 #endif // ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_CHROMEOS_H_ | 86 #endif // ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_CHROMEOS_H_ |
| OLD | NEW |