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

Side by Side Diff: chrome/browser/chromeos/attestation/platform_verification_flow.h

Issue 31043008: Changed platform verification user consent logic to be per-domain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_
6 #define CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_ 6 #define CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 enum Result { 48 enum Result {
49 SUCCESS, // The operation succeeded. 49 SUCCESS, // The operation succeeded.
50 INTERNAL_ERROR, // The operation failed unexpectedly. 50 INTERNAL_ERROR, // The operation failed unexpectedly.
51 PLATFORM_NOT_VERIFIED, // The platform cannot be verified. For example: 51 PLATFORM_NOT_VERIFIED, // The platform cannot be verified. For example:
52 // - It is not a Chrome device. 52 // - It is not a Chrome device.
53 // - It is not running a verified OS image. 53 // - It is not running a verified OS image.
54 USER_REJECTED, // The user explicitly rejected the operation. 54 USER_REJECTED, // The user explicitly rejected the operation.
55 POLICY_REJECTED, // The operation is not allowed by policy/settings. 55 POLICY_REJECTED, // The operation is not allowed by policy/settings.
56 }; 56 };
57 57
58 enum ConsentType {
59 CONSENT_TYPE_NONE, // No consent necessary.
60 CONSENT_TYPE_ATTESTATION, // Consent to use attestation.
61 CONSENT_TYPE_ALWAYS, // Consent because 'Always Ask' was requested.
62 };
63
64 enum ConsentResponse { 58 enum ConsentResponse {
65 CONSENT_RESPONSE_NONE, 59 CONSENT_RESPONSE_NONE,
66 CONSENT_RESPONSE_ALLOW, 60 CONSENT_RESPONSE_ALLOW,
67 CONSENT_RESPONSE_DENY, 61 CONSENT_RESPONSE_DENY,
68 CONSENT_RESPONSE_ALWAYS_ASK,
69 }; 62 };
70 63
71 // An interface which allows settings and UI to be abstracted for testing 64 // An interface which allows settings and UI to be abstracted for testing
72 // purposes. For normal operation the default implementation should be used. 65 // purposes. For normal operation the default implementation should be used.
73 class Delegate { 66 class Delegate {
74 public: 67 public:
75 virtual ~Delegate() {} 68 virtual ~Delegate() {}
76 69
77 // This callback will be called when a user has given a |response| to a 70 // This callback will be called when a user has given a |response| to a
78 // consent request of the specified |type|. 71 // consent request of the specified |type|.
79 typedef base::Callback<void(ConsentResponse response)> ConsentCallback; 72 typedef base::Callback<void(ConsentResponse response)> ConsentCallback;
80 73
81 // Invokes consent UI of the given |type| within the context of 74 // Invokes consent UI within the context of |web_contents| and calls
82 // |web_contents| and calls |callback| when the user responds. 75 // |callback| when the user responds.
83 virtual void ShowConsentPrompt(ConsentType type, 76 virtual void ShowConsentPrompt(content::WebContents* web_contents,
84 content::WebContents* web_contents,
85 const ConsentCallback& callback) = 0; 77 const ConsentCallback& callback) = 0;
86 }; 78 };
87 79
88 // This callback will be called when a challenge operation completes. If 80 // This callback will be called when a challenge operation completes. If
89 // |result| is SUCCESS then |signed_data| holds the data which was signed 81 // |result| is SUCCESS then |signed_data| holds the data which was signed
90 // by the platform key (this is the original challenge appended with a random 82 // by the platform key (this is the original challenge appended with a random
91 // nonce) and |signature| holds the RSA-PKCS1-v1.5 signature. The 83 // nonce) and |signature| holds the RSA-PKCS1-v1.5 signature. The
92 // |platform_key_certificate| certifies the key used to generate the 84 // |platform_key_certificate| certifies the key used to generate the
93 // signature. This key may be generated on demand and is not guaranteed to 85 // signature. This key may be generated on demand and is not guaranteed to
94 // persist across multiple calls to this method. The browser does not check 86 // persist across multiple calls to this method. The browser does not check
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // ChallengePlatformKey except for the additional |attestation_enrolled| which 136 // ChallengePlatformKey except for the additional |attestation_enrolled| which
145 // specifies whether attestation has been enrolled for this device. 137 // specifies whether attestation has been enrolled for this device.
146 void CheckConsent(content::WebContents* web_contents, 138 void CheckConsent(content::WebContents* web_contents,
147 const std::string& service_id, 139 const std::string& service_id,
148 const std::string& challenge, 140 const std::string& challenge,
149 const ChallengeCallback& callback, 141 const ChallengeCallback& callback,
150 bool attestation_enrolled); 142 bool attestation_enrolled);
151 143
152 // A callback called when the user has given their consent response. All 144 // A callback called when the user has given their consent response. All
153 // parameters are the same as in ChallengePlatformKey except for the 145 // parameters are the same as in ChallengePlatformKey except for the
154 // additional |consent_type| and |consent_response| which indicate the consent 146 // additional |consent_required| and |consent_response| which indicate that
155 // type and user response, respectively. If the response indicates that the 147 // user interaction was required and the user response, respectively. If the
156 // operation should proceed, this method invokes a certificate request. 148 // response indicates that the operation should proceed, this method invokes a
149 // certificate request.
157 void OnConsentResponse(content::WebContents* web_contents, 150 void OnConsentResponse(content::WebContents* web_contents,
158 const std::string& service_id, 151 const std::string& service_id,
159 const std::string& challenge, 152 const std::string& challenge,
160 const ChallengeCallback& callback, 153 const ChallengeCallback& callback,
161 ConsentType consent_type, 154 bool consent_required,
162 ConsentResponse consent_response); 155 ConsentResponse consent_response);
163 156
164 // A callback called when an attestation certificate request operation 157 // A callback called when an attestation certificate request operation
165 // completes. |service_id|, |challenge|, and |callback| are the same as in 158 // completes. |service_id|, |challenge|, and |callback| are the same as in
166 // ChallengePlatformKey. |user_id| identifies the user for which the 159 // ChallengePlatformKey. |user_id| identifies the user for which the
167 // certificate was requested. |operation_success| is true iff the certificate 160 // certificate was requested. |operation_success| is true iff the certificate
168 // request operation succeeded. |certificate| holds the certificate for the 161 // request operation succeeded. |certificate| holds the certificate for the
169 // platform key on success. If the certificate request was successful, this 162 // platform key on success. If the certificate request was successful, this
170 // method invokes a request to sign the challenge. 163 // method invokes a request to sign the challenge.
171 void OnCertificateReady(const std::string& user_id, 164 void OnCertificateReady(const std::string& user_id,
(...skipping 13 matching lines...) Expand all
185 const std::string& challenge, 178 const std::string& challenge,
186 const ChallengeCallback& callback, 179 const ChallengeCallback& callback,
187 bool operation_success, 180 bool operation_success,
188 const std::string& response_data); 181 const std::string& response_data);
189 182
190 // Gets prefs associated with the given |web_contents|. If prefs have been 183 // Gets prefs associated with the given |web_contents|. If prefs have been
191 // set explicitly using set_testing_prefs(), then these are always returned. 184 // set explicitly using set_testing_prefs(), then these are always returned.
192 // If no prefs are associated with |web_contents| then NULL is returned. 185 // If no prefs are associated with |web_contents| then NULL is returned.
193 PrefService* GetPrefs(content::WebContents* web_contents); 186 PrefService* GetPrefs(content::WebContents* web_contents);
194 187
195 // Gets the URL associated with the given |web_contents|. If a URL as been 188 // Gets the web origin URL spec associated with |web_contents|. If a URL has
196 // set explicitly using set_testing_url(), then this value is always returned. 189 // been set explicitly using set_testing_url(), then this value is used
197 const GURL& GetURL(content::WebContents* web_contents); 190 // instead. If the origin URL is not valid, the empty string is returned.
191 std::string GetURLSpec(content::WebContents* web_contents);
198 192
199 // Gets the user associated with the given |web_contents|. NULL may be 193 // Gets the user associated with the given |web_contents|. NULL may be
200 // returned. If |web_contents| is NULL (e.g. during testing), then the 194 // returned. If |web_contents| is NULL (e.g. during testing), then the
201 // current active user will be returned. 195 // current active user will be returned.
202 User* GetUser(content::WebContents* web_contents); 196 User* GetUser(content::WebContents* web_contents);
203 197
204 // Checks whether policy or profile settings associated with |web_contents| 198 // Checks whether policy or profile settings associated with |web_contents|
205 // have attestation for content protection explicitly disabled. 199 // have attestation for content protection explicitly disabled.
206 bool IsAttestationEnabled(content::WebContents* web_contents); 200 bool IsAttestationEnabled(content::WebContents* web_contents);
207 201
208 // Checks whether this is the first use on this device for the user associated
209 // with |web_contents|.
210 bool IsFirstUse(content::WebContents* web_contents);
211
212 // Checks if settings indicate that consent is required for the web origin
213 // represented by |web_contents| because the user requested to be prompted.
214 bool IsAlwaysAskRequired(content::WebContents* web_contents);
215
216 // Updates user settings for the profile associated with |web_contents| based 202 // Updates user settings for the profile associated with |web_contents| based
217 // on the |consent_response| to the request of type |consent_type|. 203 // on the |consent_response| to the request of type |consent_type|.
218 bool UpdateSettings(content::WebContents* web_contents, 204 bool UpdateSettings(content::WebContents* web_contents,
219 ConsentType consent_type,
220 ConsentResponse consent_response); 205 ConsentResponse consent_response);
221 206
222 // Finds the domain-specific consent pref for the domain associated with 207 // Finds the domain-specific consent pref for the domain associated with
223 // |web_contents|. If a pref exists for the domain, returns true and sets 208 // |web_contents|. If a pref exists for the domain, returns true and sets
224 // |pref_value| if it is not NULL. 209 // |pref_value| if it is not NULL.
225 // 210 //
226 // Precondition: A valid PrefService must be available via GetPrefs(). 211 // Precondition: A valid PrefService must be available via GetPrefs().
227 bool GetDomainPref(content::WebContents* web_contents, bool* pref_value); 212 bool GetDomainPref(PrefService* pref_service,
213 const std::string& url_spec,
214 bool* pref_value);
228 215
229 // Records the domain-specific consent pref for the domain associated with 216 // Records the domain-specific consent pref for the domain associated with
230 // |web_contents|. The pref will be set to |allow_domain|. 217 // |web_contents|. The pref will be set to |allow_domain|.
231 // 218 //
232 // Precondition: A valid PrefService must be available via GetPrefs(). 219 // Precondition: A valid PrefService must be available via GetPrefs().
233 void RecordDomainConsent(content::WebContents* web_contents, 220 void RecordDomainConsent(PrefService* pref_service,
221 const std::string& url_spec,
234 bool allow_domain); 222 bool allow_domain);
235 223
236 AttestationFlow* attestation_flow_; 224 AttestationFlow* attestation_flow_;
237 scoped_ptr<AttestationFlow> default_attestation_flow_; 225 scoped_ptr<AttestationFlow> default_attestation_flow_;
238 cryptohome::AsyncMethodCaller* async_caller_; 226 cryptohome::AsyncMethodCaller* async_caller_;
239 CryptohomeClient* cryptohome_client_; 227 CryptohomeClient* cryptohome_client_;
240 UserManager* user_manager_; 228 UserManager* user_manager_;
241 Delegate* delegate_; 229 Delegate* delegate_;
242 scoped_ptr<Delegate> default_delegate_; 230 scoped_ptr<Delegate> default_delegate_;
243 PrefService* testing_prefs_; 231 PrefService* testing_prefs_;
244 GURL testing_url_; 232 GURL testing_url_;
245 233
246 // Note: This should remain the last member so it'll be destroyed and 234 // Note: This should remain the last member so it'll be destroyed and
247 // invalidate the weak pointers before any other members are destroyed. 235 // invalidate the weak pointers before any other members are destroyed.
248 base::WeakPtrFactory<PlatformVerificationFlow> weak_factory_; 236 base::WeakPtrFactory<PlatformVerificationFlow> weak_factory_;
249 237
250 DISALLOW_COPY_AND_ASSIGN(PlatformVerificationFlow); 238 DISALLOW_COPY_AND_ASSIGN(PlatformVerificationFlow);
251 }; 239 };
252 240
253 } // namespace attestation 241 } // namespace attestation
254 } // namespace chromeos 242 } // namespace chromeos
255 243
256 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_ 244 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698