1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef ASH_DISPLAY_PROJECTING_OBSERVER_H_ 6 #define ASH_DISPLAY_PROJECTING_OBSERVER_H_ 7 8 #include "ash/ash_export.h" 9 #include "ash/shell_observer.h" 10 #include "base/macros.h" 11 #include "ui/display/manager/display_configurator.h" 12 13 namespace ash { 14 15 class ASH_EXPORT ProjectingObserver 16 : public display::DisplayConfigurator::Observer, 17 public ShellObserver { 18 public: 19 // |display_configurator| must outlive this instance. May be null in tests. 20 explicit ProjectingObserver( 21 display::DisplayConfigurator* display_configurator); 22 ~ProjectingObserver() override; 23 24 // DisplayConfigurator::Observer implementation: 25 void OnDisplayModeChanged( 26 const display::DisplayConfigurator::DisplayStateList& outputs) override; 27 28 // ash::ShellObserver implementation: 29 void OnCastingSessionStartedOrStopped(bool started) override; 30 31 private: 32 friend class ProjectingObserverTest; 33 34 // Sends the current projecting state to power manager. 35 void SetIsProjecting(); 36 37 display::DisplayConfigurator* display_configurator_; // Unowned 38 39 // True if at least one output is internal. This value is updated when 40 // |OnDisplayModeChanged| is called. 41 bool has_internal_output_ = false; 42 43 // Keeps track of the number of connected outputs. 44 int output_count_ = 0; 45 46 // Number of outstanding casting sessions. 47 int casting_session_count_ = 0; 48 49 DISALLOW_COPY_AND_ASSIGN(ProjectingObserver); 50 }; 51 52 } // namespace ash 53 54 #endif // ASH_DISPLAY_PROJECTING_OBSERVER_H_ 55