| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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_MEDIA_CONTROLLER_H_ | |
| 6 #define ASH_MEDIA_CONTROLLER_H_ | |
| 7 | |
| 8 #include "ash/public/interfaces/media.mojom.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/observer_list.h" | |
| 11 #include "mojo/public/cpp/bindings/associated_binding.h" | |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 | |
| 16 // Forwards notifications from the MediaController to observers. | |
| 17 class MediaCaptureObserver { | |
| 18 public: | |
| 19 // Called when media capture state has changed. | |
| 20 virtual void OnMediaCaptureChanged( | |
| 21 const std::vector<mojom::MediaCaptureState>& capture_states) = 0; | |
| 22 | |
| 23 protected: | |
| 24 virtual ~MediaCaptureObserver() {} | |
| 25 }; | |
| 26 | |
| 27 // Provides the MediaController interface to the outside world. This lets a | |
| 28 // consumer of ash provide a MediaClient, which we will dispatch to if one has | |
| 29 // been provided to us. | |
| 30 class MediaController : public mojom::MediaController, | |
| 31 public mojom::MediaClient { | |
| 32 public: | |
| 33 MediaController(); | |
| 34 ~MediaController() override; | |
| 35 | |
| 36 void BindRequest(mojom::MediaControllerRequest request); | |
| 37 | |
| 38 void AddObserver(MediaCaptureObserver* observer); | |
| 39 void RemoveObserver(MediaCaptureObserver* observer); | |
| 40 | |
| 41 // mojom::MediaClient: | |
| 42 void HandleMediaNextTrack() override; | |
| 43 void HandleMediaPlayPause() override; | |
| 44 void HandleMediaPrevTrack() override; | |
| 45 void RequestCaptureState() override; | |
| 46 | |
| 47 private: | |
| 48 friend class MultiProfileMediaTrayItemTest; | |
| 49 | |
| 50 // mojom::MediaController: | |
| 51 void SetClient(mojom::MediaClientAssociatedPtrInfo client) override; | |
| 52 void NotifyCaptureState( | |
| 53 const std::vector<mojom::MediaCaptureState>& capture_states) override; | |
| 54 | |
| 55 mojo::BindingSet<mojom::MediaController> bindings_; | |
| 56 | |
| 57 mojom::MediaClientAssociatedPtr client_; | |
| 58 | |
| 59 base::ObserverList<MediaCaptureObserver> observers_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(MediaController); | |
| 62 }; | |
| 63 | |
| 64 } // namespace ash | |
| 65 | |
| 66 #endif // ASH_MEDIA_CONTROLLER_H_ | |
| OLD | NEW |