1 // Copyright 2018 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_SYSTEM_MODEL_VIRTUAL_KEYBOARD_MODEL_H_ 6 #define ASH_SYSTEM_MODEL_VIRTUAL_KEYBOARD_MODEL_H_ 7 8 #include <memory> 9 10 #include "ash/ash_export.h" 11 #include "ash/public/cpp/keyboard/arc/arc_input_method_bounds_tracker.h" 12 #include "base/macros.h" 13 #include "base/observer_list.h" 14 15 namespace ash { 16 17 // Model to store virtual keyboard visibility state. 18 class ASH_EXPORT VirtualKeyboardModel 19 : public ArcInputMethodBoundsTracker::Observer { 20 public: 21 class Observer { 22 public: ~Observer()23 virtual ~Observer() {} 24 25 virtual void OnVirtualKeyboardVisibilityChanged() = 0; 26 }; 27 28 VirtualKeyboardModel(); 29 ~VirtualKeyboardModel() override; 30 31 void AddObserver(Observer* observer); 32 void RemoveObserver(Observer* observer); 33 34 // Start/stop observing ArcInputMethodBoundsTracker. 35 void SetInputMethodBoundsTrackerObserver( 36 ArcInputMethodBoundsTracker* input_method_bounds_tracker); 37 void RemoveInputMethodBoundsTrackerObserver( 38 ArcInputMethodBoundsTracker* input_method_bounds_tracker); 39 40 // ArcInputMethodBoundsTracker::Observer: 41 void OnArcInputMethodBoundsChanged(const gfx::Rect& bounds) override; 42 visible()43 bool visible() const { return visible_; } arc_keyboard_bounds()44 const gfx::Rect& arc_keyboard_bounds() const { return arc_keyboard_bounds_; } 45 46 private: 47 void NotifyChanged(); 48 49 // The visibility of virtual keyboard. 50 bool visible_ = false; 51 52 gfx::Rect arc_keyboard_bounds_; 53 54 base::ObserverList<Observer>::Unchecked observers_; 55 56 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardModel); 57 }; 58 59 } // namespace ash 60 61 #endif // ASH_SYSTEM_MODEL_VIRTUAL_KEYBOARD_MODEL_H_ 62