Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: extensions/browser/api/display_source/display_source_event_router.h

Issue 1410093008: Introduce chrome.displaySource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from Antony Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/display_source/display_source_event_router.h
diff --git a/extensions/browser/api/display_source/display_source_event_router.h b/extensions/browser/api/display_source/display_source_event_router.h
new file mode 100644
index 0000000000000000000000000000000000000000..6697fe80dd60aaeca2bd9129f6379957dd7632f8
--- /dev/null
+++ b/extensions/browser/api/display_source/display_source_event_router.h
@@ -0,0 +1,54 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_
+#define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "extensions/browser/api/display_source/display_source_connection_delegate.h"
+#include "extensions/browser/event_router.h"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace extensions {
+
+// Observe listeners to 'onSinksUpdated' events.
+class DisplaySourceEventRouter
+ : public KeyedService,
+ public EventRouter::Observer,
+ public DisplaySourceConnectionDelegate::Observer {
+ public:
+ static DisplaySourceEventRouter* Create(
+ content::BrowserContext* browser_context);
+
+ ~DisplaySourceEventRouter() override;
+
+ private:
+ explicit DisplaySourceEventRouter(content::BrowserContext* browser_context);
+
+ // KeyedService overrides:
+ void Shutdown() override;
+
+ // EventRouter::Observer overrides:
+ void OnListenerAdded(const EventListenerInfo& details) override;
+ void OnListenerRemoved(const EventListenerInfo& details) override;
+
+ // DisplaySourceConnectionDelegate::Observer overrides:
+ void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) override;
+
+ private:
+ void StartOrStopListeningForSinksChanges();
+
+ content::BrowserContext* browser_context_;
+ bool listening_;
+
+ DISALLOW_COPY_AND_ASSIGN(DisplaySourceEventRouter);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_

Powered by Google App Engine
This is Rietveld 408576698