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

Side by Side Diff: chrome/browser/chromeos/platform_keys/platform_keys_service.h

Issue 927293002: platformKeys: Hook up the certificate selection dialog to selectClientCertificates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_perms
Patch Set: Rebased. Created 5 years, 10 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" 17 #include "chrome/browser/chromeos/platform_keys/platform_keys.h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 19
20 namespace content { 20 namespace content {
21 class BrowserContext; 21 class BrowserContext;
22 class WebContents;
22 } 23 }
23 24
24 namespace base { 25 namespace base {
25 class ListValue; 26 class ListValue;
26 class Value; 27 class Value;
27 } 28 }
28 29
29 namespace extensions { 30 namespace extensions {
30 class StateStore; 31 class StateStore;
31 } 32 }
32 33
33 namespace net { 34 namespace net {
34 class X509Certificate; 35 class X509Certificate;
35 typedef std::vector<scoped_refptr<X509Certificate>> CertificateList; 36 typedef std::vector<scoped_refptr<X509Certificate>> CertificateList;
36 } 37 }
37 38
38 namespace chromeos { 39 namespace chromeos {
39 40
40 class PlatformKeysService : public KeyedService { 41 class PlatformKeysService : public KeyedService {
41 public: 42 public:
42 struct KeyEntry; 43 struct KeyEntry;
43 using KeyEntries = std::vector<KeyEntry>; 44 using KeyEntries = std::vector<KeyEntry>;
44 45
45 // The SelectDelegate is used to select a single certificate from all 46 // The SelectDelegate is used to select a single certificate from all
46 // certificates matching a request (see SelectClientCertificates). E.g. this 47 // certificates matching a request (see SelectClientCertificates). E.g. this
47 // can happen by exposing UI to let the user select. 48 // can happen by exposing UI to let the user select.
48 class SelectDelegate { 49 class SelectDelegate {
49 public: 50 public:
50 // TODO(pneubeck): Handle if the selection was aborted, e.g. by the user. 51 using CertificateSelectedCallback = base::Callback<void(
51 using CertificateSelectedCallback = 52 const scoped_refptr<net::X509Certificate>& selection)>;
52 base::Callback<void(scoped_refptr<net::X509Certificate> selection)>;
53 53
54 SelectDelegate(); 54 SelectDelegate();
55 virtual ~SelectDelegate(); 55 virtual ~SelectDelegate();
56 56
57 // Called on an interactive SelectClientCertificates call with the list of 57 // Called on an interactive SelectClientCertificates call with the list of
58 // matching certificates, |certs|. 58 // matching certificates, |certs|.
59 // The certificate passed to |callback| will be forwarded to the 59 // The certificate passed to |callback| will be forwarded to the
60 // calling extension and the extension will get unlimited sign permission 60 // calling extension and the extension will get unlimited sign permission
61 // for this cert. By passing null to |callback|, no cert will be selected. 61 // for this cert. By passing null to |callback|, no cert will be selected.
62 // Must eventually call |callback| or be destructed. |callback| must not be 62 // Must eventually call |callback| or be destructed. |callback| must not be
63 // called after this delegate is destructed. 63 // called after this delegate is destructed.
64 // |web_contents| and |context| provide the context in which the
65 // certificates were requested and are not null.
64 virtual void Select(const std::string& extension_id, 66 virtual void Select(const std::string& extension_id,
65 const net::CertificateList& certs, 67 const net::CertificateList& certs,
66 const CertificateSelectedCallback& callback) = 0; 68 const CertificateSelectedCallback& callback,
69 content::WebContents* web_contents,
70 content::BrowserContext* context) = 0;
67 71
68 private: 72 private:
69 DISALLOW_ASSIGN(SelectDelegate); 73 DISALLOW_ASSIGN(SelectDelegate);
70 }; 74 };
71 75
72 // Stores registration information in |state_store|, i.e. for each extension 76 // Stores registration information in |state_store|, i.e. for each extension
73 // the list of public keys that are valid to be used for signing. Each key can 77 // the list of public keys that are valid to be used for signing. Each key can
74 // be used for signing at most once. 78 // be used for signing at most once.
75 // The format written to |state_store| is: 79 // The format written to |state_store| is:
76 // kStateStorePlatformKeys maps to a list of strings. 80 // kStateStorePlatformKeys maps to a list of strings.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 162
159 // Returns a list of certificates matching |request|. 163 // Returns a list of certificates matching |request|.
160 // 1) all certificates that match the request (like being rooted in one of the 164 // 1) all certificates that match the request (like being rooted in one of the
161 // give CAs) are determined. 2) if |interactive| is true, the currently set 165 // give CAs) are determined. 2) if |interactive| is true, the currently set
162 // SelectDelegate is used to select a single certificate from these matches 166 // SelectDelegate is used to select a single certificate from these matches
163 // which will the extension will also be granted access to. 3) only 167 // which will the extension will also be granted access to. 3) only
164 // certificates, that the extension has unlimited sign permission for, will be 168 // certificates, that the extension has unlimited sign permission for, will be
165 // returned. 169 // returned.
166 // |callback| will be invoked with these certificates or an error message. 170 // |callback| will be invoked with these certificates or an error message.
167 // Will only call back during the lifetime of this object. 171 // Will only call back during the lifetime of this object.
172 // |web_contents| must not be null.
168 void SelectClientCertificates( 173 void SelectClientCertificates(
169 const platform_keys::ClientCertificateRequest& request, 174 const platform_keys::ClientCertificateRequest& request,
170 bool interactive, 175 bool interactive,
171 const std::string& extension_id, 176 const std::string& extension_id,
172 const SelectCertificatesCallback& callback); 177 const SelectCertificatesCallback& callback,
178 content::WebContents* web_contents);
173 179
174 private: 180 private:
175 using GetPlatformKeysCallback = 181 using GetPlatformKeysCallback =
176 base::Callback<void(scoped_ptr<KeyEntries> platform_keys)>; 182 base::Callback<void(scoped_ptr<KeyEntries> platform_keys)>;
177 183
178 enum SignPermission { ONCE, UNLIMITED }; 184 enum SignPermission { ONCE, UNLIMITED };
179 185
180 class PermissionUpdateTask; 186 class PermissionUpdateTask;
181 class SelectTask; 187 class SelectTask;
182 class SignTask; 188 class SignTask;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 scoped_ptr<SelectDelegate> select_delegate_; 240 scoped_ptr<SelectDelegate> select_delegate_;
235 std::queue<linked_ptr<Task>> tasks_; 241 std::queue<linked_ptr<Task>> tasks_;
236 base::WeakPtrFactory<PlatformKeysService> weak_factory_; 242 base::WeakPtrFactory<PlatformKeysService> weak_factory_;
237 243
238 DISALLOW_COPY_AND_ASSIGN(PlatformKeysService); 244 DISALLOW_COPY_AND_ASSIGN(PlatformKeysService);
239 }; 245 };
240 246
241 } // namespace chromeos 247 } // namespace chromeos
242 248
243 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 249 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/chromeos/platform_keys/platform_keys_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698