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

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

Issue 106373003: Restructured PlatformVerificationFlow testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // This callback will be called when a user has given a |response| to a 87 // This callback will be called when a user has given a |response| to a
88 // consent request of the specified |type|. 88 // consent request of the specified |type|.
89 typedef base::Callback<void(ConsentResponse response)> ConsentCallback; 89 typedef base::Callback<void(ConsentResponse response)> ConsentCallback;
90 90
91 // Invokes consent UI within the context of |web_contents| and calls 91 // Invokes consent UI within the context of |web_contents| and calls
92 // |callback| when the user responds. 92 // |callback| when the user responds.
93 // Precondition: The last committed URL for |web_contents| has a valid 93 // Precondition: The last committed URL for |web_contents| has a valid
94 // origin. 94 // origin.
95 virtual void ShowConsentPrompt(content::WebContents* web_contents, 95 virtual void ShowConsentPrompt(content::WebContents* web_contents,
96 const ConsentCallback& callback) = 0; 96 const ConsentCallback& callback) = 0;
97
98 // Gets prefs associated with the given |web_contents|. If no prefs are
99 // associated with |web_contents| then NULL is returned.
100 virtual PrefService* GetPrefs(content::WebContents* web_contents) = 0;
101
102 // Gets the URL associated with the given |web_contents|.
103 virtual const GURL& GetURL(content::WebContents* web_contents) = 0;
104
105 // Gets the user associated with the given |web_contents|. NULL may be
106 // returned.
107 virtual User* GetUser(content::WebContents* web_contents) = 0;
108
109 // Gets the content settings map associated with the given |web_contents|.
110 virtual HostContentSettingsMap* GetContentSettings(
111 content::WebContents* web_contents) = 0;
112
113 // Returns true iff |web_contents| belongs to a guest or incognito session.
114 virtual bool IsGuestOrIncognito(content::WebContents* web_contents) = 0;
97 }; 115 };
98 116
99 // This callback will be called when a challenge operation completes. If 117 // This callback will be called when a challenge operation completes. If
100 // |result| is SUCCESS then |signed_data| holds the data which was signed 118 // |result| is SUCCESS then |signed_data| holds the data which was signed
101 // by the platform key (this is the original challenge appended with a random 119 // by the platform key (this is the original challenge appended with a random
102 // nonce) and |signature| holds the RSA-PKCS1-v1.5 signature. The 120 // nonce) and |signature| holds the RSA-PKCS1-v1.5 signature. The
103 // |platform_key_certificate| certifies the key used to generate the 121 // |platform_key_certificate| certifies the key used to generate the
104 // signature. This key may be generated on demand and is not guaranteed to 122 // signature. This key may be generated on demand and is not guaranteed to
105 // persist across multiple calls to this method. The browser does not check 123 // persist across multiple calls to this method. The browser does not check
106 // the validity of |signature| or |platform_key_certificate|. 124 // the validity of |signature| or |platform_key_certificate|.
107 typedef base::Callback<void(Result result, 125 typedef base::Callback<void(Result result,
108 const std::string& signed_data, 126 const std::string& signed_data,
109 const std::string& signature, 127 const std::string& signature,
110 const std::string& platform_key_certificate)> 128 const std::string& platform_key_certificate)>
111 ChallengeCallback; 129 ChallengeCallback;
112 130
113 // A constructor that uses the default implementation of all dependencies 131 // A constructor that uses the default implementation of all dependencies
114 // including Delegate. 132 // including Delegate.
115 PlatformVerificationFlow(); 133 PlatformVerificationFlow();
116 134
117 // An alternate constructor which specifies dependent objects explicitly. 135 // An alternate constructor which specifies dependent objects explicitly.
118 // This is useful in testing. The caller retains ownership of all pointers. 136 // This is useful in testing. The caller retains ownership of all pointers.
119 PlatformVerificationFlow(AttestationFlow* attestation_flow, 137 PlatformVerificationFlow(AttestationFlow* attestation_flow,
120 cryptohome::AsyncMethodCaller* async_caller, 138 cryptohome::AsyncMethodCaller* async_caller,
121 CryptohomeClient* cryptohome_client, 139 CryptohomeClient* cryptohome_client,
122 UserManager* user_manager,
123 Delegate* delegate); 140 Delegate* delegate);
124 141
125 // Invokes an asynchronous operation to challenge a platform key. Any user 142 // Invokes an asynchronous operation to challenge a platform key. Any user
126 // interaction will be associated with |web_contents|. The |service_id| is an 143 // interaction will be associated with |web_contents|. The |service_id| is an
127 // arbitrary value but it should uniquely identify the origin of the request 144 // arbitrary value but it should uniquely identify the origin of the request
128 // and should not be determined by that origin; its purpose is to prevent 145 // and should not be determined by that origin; its purpose is to prevent
129 // collusion between multiple services. The |challenge| is also an arbitrary 146 // collusion between multiple services. The |challenge| is also an arbitrary
130 // value but it should be time sensitive or associated to some kind of session 147 // value but it should be time sensitive or associated to some kind of session
131 // because its purpose is to prevent certificate replay. The |callback| will 148 // because its purpose is to prevent certificate replay. The |callback| will
132 // be called when the operation completes. The duration of the operation can 149 // be called when the operation completes. The duration of the operation can
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // |certificate| is the platform certificate for the key which signed the 230 // |certificate| is the platform certificate for the key which signed the
214 // |challenge|. The arguments to ChallengePlatformKey are in |context|. 231 // |challenge|. The arguments to ChallengePlatformKey are in |context|.
215 // |operation_success| is true iff the challenge signing operation was 232 // |operation_success| is true iff the challenge signing operation was
216 // successful. If it was successful, |response_data| holds the challenge 233 // successful. If it was successful, |response_data| holds the challenge
217 // response and the method will invoke |context.callback|. 234 // response and the method will invoke |context.callback|.
218 void OnChallengeReady(const ChallengeContext& context, 235 void OnChallengeReady(const ChallengeContext& context,
219 const std::string& certificate, 236 const std::string& certificate,
220 bool operation_success, 237 bool operation_success,
221 const std::string& response_data); 238 const std::string& response_data);
222 239
223 // Gets prefs associated with the given |web_contents|. If prefs have been
224 // set explicitly using set_testing_prefs(), then these are always returned.
225 // If no prefs are associated with |web_contents| then NULL is returned.
226 PrefService* GetPrefs(content::WebContents* web_contents);
227
228 // Gets the URL associated with the given |web_contents|. If a URL as been
229 // set explicitly using set_testing_url(), then this value is always returned.
230 const GURL& GetURL(content::WebContents* web_contents);
231
232 // Gets the user associated with the given |web_contents|. NULL may be
233 // returned. If |web_contents| is NULL (e.g. during testing), then the
234 // current active user will be returned.
235 User* GetUser(content::WebContents* web_contents);
236
237 // Gets the content settings map associated with the given |web_contents|. If
238 // |testing_content_settings_| is set, then this is always returned.
239 HostContentSettingsMap* GetContentSettings(
240 content::WebContents* web_contents);
241
242 // Checks whether policy or profile settings associated with |web_contents| 240 // Checks whether policy or profile settings associated with |web_contents|
243 // have attestation for content protection explicitly disabled. 241 // have attestation for content protection explicitly disabled.
244 bool IsAttestationEnabled(content::WebContents* web_contents); 242 bool IsAttestationEnabled(content::WebContents* web_contents);
245 243
246 // Updates user settings for the profile associated with |web_contents| based 244 // Updates user settings for the profile associated with |web_contents| based
247 // on the |consent_response| to the request of type |consent_type|. 245 // on the |consent_response| to the request of type |consent_type|.
248 bool UpdateSettings(content::WebContents* web_contents, 246 bool UpdateSettings(content::WebContents* web_contents,
249 ConsentResponse consent_response); 247 ConsentResponse consent_response);
250 248
251 // Finds the domain-specific consent pref in |content_settings| for |url|. If 249 // Finds the domain-specific consent pref in |content_settings| for |url|. If
252 // a pref exists for the domain, returns true and sets |pref_value| if it is 250 // a pref exists for the domain, returns true and sets |pref_value| if it is
253 // not NULL. 251 // not NULL.
254 bool GetDomainPref(HostContentSettingsMap* content_settings, 252 bool GetDomainPref(HostContentSettingsMap* content_settings,
255 const GURL& url, 253 const GURL& url,
256 bool* pref_value); 254 bool* pref_value);
257 255
258 // Records the domain-specific consent pref in |content_settings| for |url|. 256 // Records the domain-specific consent pref in |content_settings| for |url|.
259 // The pref will be set to |allow_domain|. 257 // The pref will be set to |allow_domain|.
260 void RecordDomainConsent(HostContentSettingsMap* content_settings, 258 void RecordDomainConsent(HostContentSettingsMap* content_settings,
261 const GURL& url, 259 const GURL& url,
262 bool allow_domain); 260 bool allow_domain);
263 261
264 // Returns true iff |certificate| is an expired X.509 certificate. 262 // Returns true iff |certificate| is an expired X.509 certificate.
265 bool IsExpired(const std::string& certificate); 263 bool IsExpired(const std::string& certificate);
266 264
267 // Returns true iff |web_contents| belongs to a guest or incognito session.
268 bool IsGuestOrIncognito(content::WebContents* web_contents);
269
270 void set_testing_prefs(PrefService* testing_prefs) {
271 testing_prefs_ = testing_prefs;
272 }
273
274 void set_testing_url(const GURL& testing_url) {
275 testing_url_ = testing_url;
276 }
277
278 void set_testing_content_settings(HostContentSettingsMap* settings) {
279 testing_content_settings_ = settings;
280 }
281
282 AttestationFlow* attestation_flow_; 265 AttestationFlow* attestation_flow_;
283 scoped_ptr<AttestationFlow> default_attestation_flow_; 266 scoped_ptr<AttestationFlow> default_attestation_flow_;
284 cryptohome::AsyncMethodCaller* async_caller_; 267 cryptohome::AsyncMethodCaller* async_caller_;
285 CryptohomeClient* cryptohome_client_; 268 CryptohomeClient* cryptohome_client_;
286 UserManager* user_manager_;
287 Delegate* delegate_; 269 Delegate* delegate_;
288 scoped_ptr<Delegate> default_delegate_; 270 scoped_ptr<Delegate> default_delegate_;
289 PrefService* testing_prefs_;
290 GURL testing_url_;
291 HostContentSettingsMap* testing_content_settings_;
292 base::TimeDelta timeout_delay_; 271 base::TimeDelta timeout_delay_;
293 272
294 DISALLOW_COPY_AND_ASSIGN(PlatformVerificationFlow); 273 DISALLOW_COPY_AND_ASSIGN(PlatformVerificationFlow);
295 }; 274 };
296 275
297 } // namespace attestation 276 } // namespace attestation
298 } // namespace chromeos 277 } // namespace chromeos
299 278
300 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_ 279 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698