• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_ENTERPRISE_PLATFORM_KEYS_ENTERPRISE_PLATFORM_KEYS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_ENTERPRISE_PLATFORM_KEYS_API_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/extensions/chrome_extension_function.h"
15 
16 namespace net {
17 class X509Certificate;
18 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList;
19 }
20 
21 namespace extensions {
22 
23 class EnterprisePlatformKeysInternalGenerateKeyFunction
24     : public ChromeUIThreadExtensionFunction {
25  private:
26   virtual ~EnterprisePlatformKeysInternalGenerateKeyFunction();
27   virtual ResponseAction Run() OVERRIDE;
28 
29   // Called when the key was generated. If an error occurred, |public_key_der|
30   // will be empty and instead |error_message| be set.
31   void OnGeneratedKey(const std::string& public_key_der,
32                       const std::string& error_message);
33 
34   DECLARE_EXTENSION_FUNCTION("enterprise.platformKeysInternal.generateKey",
35                              ENTERPRISE_PLATFORMKEYSINTERNAL_GENERATEKEY);
36 };
37 
38 class EnterprisePlatformKeysInternalSignFunction
39     : public ChromeUIThreadExtensionFunction {
40  private:
41   virtual ~EnterprisePlatformKeysInternalSignFunction();
42   virtual ResponseAction Run() OVERRIDE;
43 
44   // Called when the signature was generated. If an error occurred,
45   // |signature| will be empty and instead |error_message| be set.
46   void OnSigned(const std::string& signature, const std::string& error_message);
47 
48   DECLARE_EXTENSION_FUNCTION("enterprise.platformKeysInternal.sign",
49                              ENTERPRISE_PLATFORMKEYSINTERNAL_SIGN);
50 };
51 
52 class EnterprisePlatformKeysGetCertificatesFunction
53     : public ChromeUIThreadExtensionFunction {
54  private:
55   virtual ~EnterprisePlatformKeysGetCertificatesFunction();
56   virtual ResponseAction Run() OVERRIDE;
57 
58   // Called when the list of certificates was determined. If an error occurred,
59   // |certs| will be NULL and instead |error_message| be set.
60   void OnGotCertificates(scoped_ptr<net::CertificateList> certs,
61                          const std::string& error_message);
62 
63   DECLARE_EXTENSION_FUNCTION("enterprise.platformKeys.getCertificates",
64                              ENTERPRISE_PLATFORMKEYS_GETCERTIFICATES);
65 };
66 
67 class EnterprisePlatformKeysImportCertificateFunction
68     : public ChromeUIThreadExtensionFunction {
69  private:
70   virtual ~EnterprisePlatformKeysImportCertificateFunction();
71   virtual ResponseAction Run() OVERRIDE;
72 
73   // Called when the certificate was imported. Only if an error occurred,
74   // |error_message| will be set.
75   void OnImportedCertificate(const std::string& error_message);
76 
77   DECLARE_EXTENSION_FUNCTION("enterprise.platformKeys.importCertificate",
78                              ENTERPRISE_PLATFORMKEYS_IMPORTCERTIFICATE);
79 };
80 
81 class EnterprisePlatformKeysRemoveCertificateFunction
82     : public ChromeUIThreadExtensionFunction {
83  private:
84   virtual ~EnterprisePlatformKeysRemoveCertificateFunction();
85   virtual ResponseAction Run() OVERRIDE;
86 
87   // Called when the certificate was removed. Only if an error occurred,
88   // |error_message| will be set.
89   void OnRemovedCertificate(const std::string& error_message);
90 
91   DECLARE_EXTENSION_FUNCTION("enterprise.platformKeys.removeCertificate",
92                              ENTERPRISE_PLATFORMKEYS_REMOVECERTIFICATE);
93 };
94 
95 class EnterprisePlatformKeysInternalGetTokensFunction
96     : public ChromeUIThreadExtensionFunction {
97  private:
98   virtual ~EnterprisePlatformKeysInternalGetTokensFunction();
99   virtual ResponseAction Run() OVERRIDE;
100 
101   // Called when the list of tokens was determined. If an error occurred,
102   // |token_ids| will be NULL and instead |error_message| be set.
103   void OnGotTokens(scoped_ptr<std::vector<std::string> > token_ids,
104                    const std::string& error_message);
105 
106   DECLARE_EXTENSION_FUNCTION("enterprise.platformKeysInternal.getTokens",
107                              ENTERPRISE_PLATFORMKEYSINTERNAL_GETTOKENS);
108 };
109 
110 }  // namespace extensions
111 
112 #endif  // CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_PLATFORM_KEYS_ENTERPRISE_PLATFORM_KEYS_API_H_
113