Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / instance_id / instance_id_api.h
blob4665b47e8287ca9ee96a84124a5c1d292915900d
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_INSTANCE_ID_INSTANCE_ID_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
8 #include "base/macros.h"
9 #include "components/gcm_driver/instance_id/instance_id.h"
10 #include "extensions/browser/extension_function.h"
12 class Profile;
14 namespace extensions {
16 class InstanceIDApiFunction : public UIThreadExtensionFunction {
17 public:
18 InstanceIDApiFunction();
20 protected:
21 ~InstanceIDApiFunction() override;
23 // ExtensionFunction:
24 ResponseAction Run() override;
26 // Actual implementation of specific functions.
27 virtual ResponseAction DoWork() = 0;
29 // Checks whether the InstanceID API is enabled.
30 bool IsEnabled() const;
32 instance_id::InstanceID* GetInstanceID() const;
34 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiFunction);
37 class InstanceIDGetIDFunction : public InstanceIDApiFunction {
38 public:
39 DECLARE_EXTENSION_FUNCTION("instanceID.getID", INSTANCEID_GETID);
41 InstanceIDGetIDFunction();
43 protected:
44 ~InstanceIDGetIDFunction() override;
46 // InstanceIDApiFunction:
47 ResponseAction DoWork() override;
49 private:
50 void GetIDCompleted(const std::string& id);
52 DISALLOW_COPY_AND_ASSIGN(InstanceIDGetIDFunction);
55 class InstanceIDGetCreationTimeFunction : public InstanceIDApiFunction {
56 public:
57 DECLARE_EXTENSION_FUNCTION("instanceID.getCreationTime",
58 INSTANCEID_GETCREATIONTIME);
60 InstanceIDGetCreationTimeFunction();
62 protected:
63 ~InstanceIDGetCreationTimeFunction() override;
65 // InstanceIDApiFunction:
66 ResponseAction DoWork() override;
68 private:
69 void GetCreationTimeCompleted(const base::Time& creation_time);
71 DISALLOW_COPY_AND_ASSIGN(InstanceIDGetCreationTimeFunction);
74 class InstanceIDGetTokenFunction : public InstanceIDApiFunction {
75 public:
76 DECLARE_EXTENSION_FUNCTION("instanceID.getToken", INSTANCEID_GETTOKEN);
78 InstanceIDGetTokenFunction();
80 protected:
81 ~InstanceIDGetTokenFunction() override;
83 // InstanceIDApiFunction:
84 ResponseAction DoWork() override;
86 private:
87 void GetTokenCompleted(const std::string& token,
88 instance_id::InstanceID::Result result);
90 DISALLOW_COPY_AND_ASSIGN(InstanceIDGetTokenFunction);
93 class InstanceIDDeleteTokenFunction : public InstanceIDApiFunction {
94 public:
95 DECLARE_EXTENSION_FUNCTION("instanceID.deleteToken", INSTANCEID_DELETETOKEN);
97 InstanceIDDeleteTokenFunction();
99 protected:
100 ~InstanceIDDeleteTokenFunction() override;
102 // InstanceIDApiFunction:
103 ResponseAction DoWork() override;
105 private:
106 void DeleteTokenCompleted(instance_id::InstanceID::Result result);
108 DISALLOW_COPY_AND_ASSIGN(InstanceIDDeleteTokenFunction);
111 class InstanceIDDeleteIDFunction : public InstanceIDApiFunction {
112 public:
113 DECLARE_EXTENSION_FUNCTION("instanceID.deleteID",
114 INSTANCEID_DELETEID);
116 InstanceIDDeleteIDFunction();
118 protected:
119 ~InstanceIDDeleteIDFunction() override;
121 // InstanceIDApiFunction:
122 ResponseAction DoWork() override;
124 private:
125 void DeleteIDCompleted(instance_id::InstanceID::Result result);
127 DISALLOW_COPY_AND_ASSIGN(InstanceIDDeleteIDFunction);
130 } // namespace extensions
132 #endif // CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_