| 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 CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_
API_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_
API_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "ash/common/cast_config_delegate.h" | |
| 11 #include "base/callback_list.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/observer_list.h" | |
| 14 #include "extensions/browser/browser_context_keyed_api_factory.h" | |
| 15 #include "extensions/browser/extension_function.h" | |
| 16 | |
| 17 namespace extensions { | |
| 18 | |
| 19 class CastDeviceUpdateListeners : public BrowserContextKeyedAPI { | |
| 20 public: | |
| 21 explicit CastDeviceUpdateListeners(content::BrowserContext* context); | |
| 22 ~CastDeviceUpdateListeners() override; | |
| 23 | |
| 24 // Fetches an instance for the given context. | |
| 25 static CastDeviceUpdateListeners* Get(content::BrowserContext* context); | |
| 26 | |
| 27 // Adds an observer that will be invoked when new device data is available. | |
| 28 void AddObserver(ash::CastConfigDelegate::Observer* observer); | |
| 29 void RemoveObserver(ash::CastConfigDelegate::Observer* observer); | |
| 30 | |
| 31 // BrowserContextKeyedAPI implementation: | |
| 32 static BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>* | |
| 33 GetFactoryInstance(); | |
| 34 static const bool kServiceIsCreatedWithBrowserContext = false; | |
| 35 | |
| 36 private: | |
| 37 using ReceiverAndActivityList = | |
| 38 std::vector<ash::CastConfigDelegate::ReceiverAndActivity>; | |
| 39 | |
| 40 friend class CastDevicesPrivateUpdateDevicesFunction; // For NotifyCallbacks. | |
| 41 void NotifyCallbacks(const ReceiverAndActivityList& devices); | |
| 42 | |
| 43 base::ObserverList<ash::CastConfigDelegate::Observer> observer_list_; | |
| 44 | |
| 45 friend class BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>; | |
| 46 | |
| 47 // BrowserContextKeyedAPI implementation: | |
| 48 static const char* service_name() { return "CastDeviceUpdateListeners"; } | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(CastDeviceUpdateListeners); | |
| 51 }; | |
| 52 | |
| 53 // static void updateDeviceState(ReceiverActivity[] devices); | |
| 54 class CastDevicesPrivateUpdateDevicesFunction : | |
| 55 public UIThreadExtensionFunction { | |
| 56 public: | |
| 57 CastDevicesPrivateUpdateDevicesFunction(); | |
| 58 | |
| 59 private: | |
| 60 ~CastDevicesPrivateUpdateDevicesFunction() override; | |
| 61 | |
| 62 // ExtensionFunction: | |
| 63 ResponseAction Run() override; | |
| 64 | |
| 65 DECLARE_EXTENSION_FUNCTION("cast.devicesPrivate.updateDevices", | |
| 66 CASTDEVICESPRIVATE_UPDATEDEVICES); | |
| 67 DISALLOW_COPY_AND_ASSIGN(CastDevicesPrivateUpdateDevicesFunction); | |
| 68 }; | |
| 69 | |
| 70 } // namespace extensions | |
| 71 | |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVA
TE_API_H_ | |
| OLD | NEW |