Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / cast_devices_private / cast_devices_private_api.h
blob7621d83c15711feee774968e98027a979a6f3850
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.
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_
8 #include <vector>
10 #include "ash/cast_config_delegate.h"
11 #include "base/callback_list.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_function.h"
15 namespace extensions {
17 class CastDeviceUpdateListeners : public BrowserContextKeyedAPI {
18 public:
19 explicit CastDeviceUpdateListeners(content::BrowserContext* context);
20 ~CastDeviceUpdateListeners() override;
22 // Fetch an instance for the given context.
23 static CastDeviceUpdateListeners* Get(content::BrowserContext* context);
25 // Register a function that will be invoked only when a new device update is
26 // available.
27 ash::CastConfigDelegate::DeviceUpdateSubscription RegisterCallback(
28 const ash::CastConfigDelegate::ReceiversAndActivitesCallback& callback);
30 // BrowserContextKeyedAPI implementation:
31 static BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>*
32 GetFactoryInstance();
33 static const bool kServiceIsCreatedWithBrowserContext = false;
35 private:
36 using ReceiverAndActivityList =
37 std::vector<ash::CastConfigDelegate::ReceiverAndActivity>;
39 friend class CastDevicesPrivateUpdateDevicesFunction; // For NotifyCallbacks.
40 void NotifyCallbacks(const ReceiverAndActivityList& devices);
42 base::CallbackList<void(const ReceiverAndActivityList&)> callback_list_;
44 friend class BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>;
46 // BrowserContextKeyedAPI implementation:
47 static const char* service_name() { return "CastDeviceUpdateListeners"; }
49 DISALLOW_COPY_AND_ASSIGN(CastDeviceUpdateListeners);
52 // static void updateDeviceState(ReceiverActivity[] devices);
53 class CastDevicesPrivateUpdateDevicesFunction :
54 public UIThreadExtensionFunction {
55 public:
56 CastDevicesPrivateUpdateDevicesFunction();
58 private:
59 ~CastDevicesPrivateUpdateDevicesFunction() override;
61 // ExtensionFunction:
62 ResponseAction Run() override;
64 DECLARE_EXTENSION_FUNCTION("cast.devicesPrivate.updateDevices",
65 CASTDEVICESPRIVATE_UPDATEDEVICES);
66 DISALLOW_COPY_AND_ASSIGN(CastDevicesPrivateUpdateDevicesFunction);
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_API_H_