OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "components/keyed_service/core/keyed_service.h" |
| 10 #include "extensions/browser/api/display_source/display_source_connection_delega
te.h" |
| 11 #include "extensions/browser/event_router.h" |
| 12 |
| 13 namespace content { |
| 14 class BrowserContext; |
| 15 } |
| 16 |
| 17 namespace extensions { |
| 18 |
| 19 // Observe listeners to 'onSinksUpdated' events. |
| 20 class DisplaySourceEventRouter |
| 21 : public KeyedService, |
| 22 public EventRouter::Observer, |
| 23 public DisplaySourceConnectionDelegate::Observer { |
| 24 public: |
| 25 static DisplaySourceEventRouter* Create( |
| 26 content::BrowserContext* browser_context); |
| 27 |
| 28 ~DisplaySourceEventRouter() override; |
| 29 |
| 30 private: |
| 31 explicit DisplaySourceEventRouter(content::BrowserContext* browser_context); |
| 32 |
| 33 // KeyedService overrides: |
| 34 void Shutdown() override; |
| 35 |
| 36 // EventRouter::Observer overrides: |
| 37 void OnListenerAdded(const EventListenerInfo& details) override; |
| 38 void OnListenerRemoved(const EventListenerInfo& details) override; |
| 39 |
| 40 // DisplaySourceConnectionDelegate::Observer overrides: |
| 41 void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) override; |
| 42 |
| 43 private: |
| 44 void StartOrStopListeningForSinksChanges(); |
| 45 |
| 46 content::BrowserContext* browser_context_; |
| 47 bool listening_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(DisplaySourceEventRouter); |
| 50 }; |
| 51 |
| 52 } // namespace extensions |
| 53 |
| 54 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_ |
OLD | NEW |