1 // Copyright 2019 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 CHROME_BROWSER_CHROMEOS_WINDOW_THROTTLE_OBSERVER_BASE_H_ 6 #define CHROME_BROWSER_CHROMEOS_WINDOW_THROTTLE_OBSERVER_BASE_H_ 7 8 #include "base/macros.h" 9 #include "chrome/browser/chromeos/throttle_observer.h" 10 #include "ui/wm/public/activation_change_observer.h" 11 12 namespace content { 13 class BrowserContext; 14 } 15 16 namespace aura { 17 class Window; 18 } 19 20 namespace chromeos { 21 22 // Base class for locks that observe changes in window activation. 23 class WindowThrottleObserverBase : public ThrottleObserver, 24 public wm::ActivationChangeObserver { 25 public: 26 WindowThrottleObserverBase(ThrottleObserver::PriorityLevel level, 27 std::string name); 28 ~WindowThrottleObserverBase() override = default; 29 30 // ThrottleObserver: 31 void StartObserving(content::BrowserContext* context, 32 const ObserverStateChangedCallback& callback) override; 33 void StopObserving() override; 34 35 // wm::ActivationChangeObserver: 36 void OnWindowActivated(ActivationReason reason, 37 aura::Window* gained_active, 38 aura::Window* lost_active) override; 39 40 protected: 41 // Returns true if the window activation should set the state to active, and 42 // false if the window activation should set state to inactive. 43 virtual bool ProcessWindowActivation(ActivationReason reason, 44 aura::Window* gained_active, 45 aura::Window* lost_active) = 0; 46 47 private: 48 DISALLOW_COPY_AND_ASSIGN(WindowThrottleObserverBase); 49 }; 50 51 } // namespace chromeos 52 53 #endif // CHROME_BROWSER_CHROMEOS_WINDOW_THROTTLE_OBSERVER_BASE_H_ 54