OLD | NEW |
---|---|
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 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" | 5 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 namespace attestation { | 72 namespace attestation { |
73 | 73 |
74 // A default implementation of the Delegate interface. | 74 // A default implementation of the Delegate interface. |
75 class DefaultDelegate : public PlatformVerificationFlow::Delegate { | 75 class DefaultDelegate : public PlatformVerificationFlow::Delegate { |
76 public: | 76 public: |
77 DefaultDelegate() {} | 77 DefaultDelegate() {} |
78 ~DefaultDelegate() override {} | 78 ~DefaultDelegate() override {} |
79 | 79 |
80 void ShowConsentPrompt( | 80 void ShowConsentPrompt( |
81 content::WebContents* web_contents, | 81 content::WebContents* web_contents, |
82 const GURL& requesting_origin, | |
82 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 83 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
83 override { | 84 override { |
84 PlatformVerificationDialog::ShowDialog(web_contents, callback); | 85 PlatformVerificationDialog::ShowDialog(web_contents, requesting_origin, |
86 callback); | |
85 } | 87 } |
86 | 88 |
87 PrefService* GetPrefs(content::WebContents* web_contents) override { | 89 PrefService* GetPrefs(content::WebContents* web_contents) override { |
88 return user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()); | 90 return user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()); |
89 } | 91 } |
90 | 92 |
91 const GURL& GetURL(content::WebContents* web_contents) override { | 93 const GURL& GetURL(content::WebContents* web_contents) override { |
92 const GURL& url = web_contents->GetLastCommittedURL(); | 94 const GURL& url = web_contents->GetLastCommittedURL(); |
93 if (!url.is_valid()) | 95 if (!url.is_valid()) |
94 return web_contents->GetVisibleURL(); | 96 return web_contents->GetVisibleURL(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 !pref_service->GetBoolean(prefs::kRAConsentFirstTime) || | 230 !pref_service->GetBoolean(prefs::kRAConsentFirstTime) || |
229 // Consent required if consent has never been given for this domain. | 231 // Consent required if consent has never been given for this domain. |
230 !GetDomainPref(delegate_->GetContentSettings(context.web_contents), | 232 !GetDomainPref(delegate_->GetContentSettings(context.web_contents), |
231 delegate_->GetURL(context.web_contents), | 233 delegate_->GetURL(context.web_contents), |
232 NULL)); | 234 NULL)); |
233 Delegate::ConsentCallback consent_callback = base::Bind( | 235 Delegate::ConsentCallback consent_callback = base::Bind( |
234 &PlatformVerificationFlow::OnConsentResponse, | 236 &PlatformVerificationFlow::OnConsentResponse, |
235 this, | 237 this, |
236 context, | 238 context, |
237 consent_required); | 239 consent_required); |
238 if (consent_required) | 240 if (consent_required) { |
239 delegate_->ShowConsentPrompt(context.web_contents, consent_callback); | 241 // TODO(xhwang): Using delegate_->GetURL() here is not right. The consent |
240 else | 242 // may be requested by a frame from a different origin. |
ddorwin
2015/02/05 03:25:26
Add bug#?
xhwang
2015/02/05 05:46:51
Done.
| |
243 delegate_->ShowConsentPrompt( | |
244 context.web_contents, | |
245 delegate_->GetURL(context.web_contents).GetOrigin(), consent_callback); | |
246 } else { | |
241 consent_callback.Run(CONSENT_RESPONSE_NONE); | 247 consent_callback.Run(CONSENT_RESPONSE_NONE); |
248 } | |
242 } | 249 } |
243 | 250 |
244 void PlatformVerificationFlow::RegisterProfilePrefs( | 251 void PlatformVerificationFlow::RegisterProfilePrefs( |
245 user_prefs::PrefRegistrySyncable* prefs) { | 252 user_prefs::PrefRegistrySyncable* prefs) { |
246 prefs->RegisterBooleanPref(prefs::kRAConsentFirstTime, | 253 prefs->RegisterBooleanPref(prefs::kRAConsentFirstTime, |
247 false, | 254 false, |
248 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 255 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
249 } | 256 } |
250 | 257 |
251 void PlatformVerificationFlow::OnConsentResponse( | 258 void PlatformVerificationFlow::OnConsentResponse( |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 certificate.length())); | 503 certificate.length())); |
497 if (!x509.get() || x509->valid_expiry().is_null()) { | 504 if (!x509.get() || x509->valid_expiry().is_null()) { |
498 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; | 505 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; |
499 return false; | 506 return false; |
500 } | 507 } |
501 return (base::Time::Now() > x509->valid_expiry()); | 508 return (base::Time::Now() > x509->valid_expiry()); |
502 } | 509 } |
503 | 510 |
504 } // namespace attestation | 511 } // namespace attestation |
505 } // namespace chromeos | 512 } // namespace chromeos |
OLD | NEW |