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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" | 10 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 content_settings_ = new HostContentSettingsMap(&pref_service_, false); | 69 content_settings_ = new HostContentSettingsMap(&pref_service_, false); |
70 } | 70 } |
71 | 71 |
72 void TearDown() { | 72 void TearDown() { |
73 content_settings_->ShutdownOnUIThread(); | 73 content_settings_->ShutdownOnUIThread(); |
74 } | 74 } |
75 | 75 |
76 virtual void ShowConsentPrompt( | 76 virtual void ShowConsentPrompt( |
77 content::WebContents* web_contents, | 77 content::WebContents* web_contents, |
78 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 78 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
79 OVERRIDE { | 79 override { |
80 num_consent_calls_++; | 80 num_consent_calls_++; |
81 callback.Run(response_); | 81 callback.Run(response_); |
82 } | 82 } |
83 | 83 |
84 virtual PrefService* GetPrefs(content::WebContents* web_contents) OVERRIDE { | 84 virtual PrefService* GetPrefs(content::WebContents* web_contents) override { |
85 return &pref_service_; | 85 return &pref_service_; |
86 } | 86 } |
87 | 87 |
88 virtual const GURL& GetURL(content::WebContents* web_contents) OVERRIDE { | 88 virtual const GURL& GetURL(content::WebContents* web_contents) override { |
89 return url_; | 89 return url_; |
90 } | 90 } |
91 | 91 |
92 virtual user_manager::User* GetUser( | 92 virtual user_manager::User* GetUser( |
93 content::WebContents* web_contents) OVERRIDE { | 93 content::WebContents* web_contents) override { |
94 return mock_user_manager_.GetActiveUser(); | 94 return mock_user_manager_.GetActiveUser(); |
95 } | 95 } |
96 | 96 |
97 virtual HostContentSettingsMap* GetContentSettings( | 97 virtual HostContentSettingsMap* GetContentSettings( |
98 content::WebContents* web_contents) OVERRIDE { | 98 content::WebContents* web_contents) override { |
99 return content_settings_.get(); | 99 return content_settings_.get(); |
100 } | 100 } |
101 | 101 |
102 virtual bool IsGuestOrIncognito(content::WebContents* web_contents) OVERRIDE { | 102 virtual bool IsGuestOrIncognito(content::WebContents* web_contents) override { |
103 return is_incognito_; | 103 return is_incognito_; |
104 } | 104 } |
105 | 105 |
106 void set_response(PlatformVerificationFlow::ConsentResponse response) { | 106 void set_response(PlatformVerificationFlow::ConsentResponse response) { |
107 response_ = response; | 107 response_ = response; |
108 } | 108 } |
109 | 109 |
110 int num_consent_calls() { | 110 int num_consent_calls() { |
111 return num_consent_calls_; | 111 return num_consent_calls_; |
112 } | 112 } |
(...skipping 21 matching lines...) Expand all Loading... |
134 | 134 |
135 DISALLOW_COPY_AND_ASSIGN(FakeDelegate); | 135 DISALLOW_COPY_AND_ASSIGN(FakeDelegate); |
136 }; | 136 }; |
137 | 137 |
138 class CustomFakeCryptohomeClient : public FakeCryptohomeClient { | 138 class CustomFakeCryptohomeClient : public FakeCryptohomeClient { |
139 public: | 139 public: |
140 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS), | 140 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS), |
141 attestation_enrolled_(true), | 141 attestation_enrolled_(true), |
142 attestation_prepared_(true) {} | 142 attestation_prepared_(true) {} |
143 virtual void TpmAttestationIsEnrolled( | 143 virtual void TpmAttestationIsEnrolled( |
144 const BoolDBusMethodCallback& callback) OVERRIDE { | 144 const BoolDBusMethodCallback& callback) override { |
145 base::MessageLoop::current()->PostTask(FROM_HERE, | 145 base::MessageLoop::current()->PostTask(FROM_HERE, |
146 base::Bind(callback, | 146 base::Bind(callback, |
147 call_status_, | 147 call_status_, |
148 attestation_enrolled_)); | 148 attestation_enrolled_)); |
149 } | 149 } |
150 | 150 |
151 virtual void TpmAttestationIsPrepared( | 151 virtual void TpmAttestationIsPrepared( |
152 const BoolDBusMethodCallback& callback) OVERRIDE { | 152 const BoolDBusMethodCallback& callback) override { |
153 base::MessageLoop::current()->PostTask(FROM_HERE, | 153 base::MessageLoop::current()->PostTask(FROM_HERE, |
154 base::Bind(callback, | 154 base::Bind(callback, |
155 call_status_, | 155 call_status_, |
156 attestation_prepared_)); | 156 attestation_prepared_)); |
157 } | 157 } |
158 | 158 |
159 void set_call_status(DBusMethodCallStatus call_status) { | 159 void set_call_status(DBusMethodCallStatus call_status) { |
160 call_status_ = call_status; | 160 call_status_ = call_status; |
161 } | 161 } |
162 | 162 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); | 481 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); |
482 fake_cryptohome_client_.set_attestation_enrolled(false); | 482 fake_cryptohome_client_.set_attestation_enrolled(false); |
483 fake_cryptohome_client_.set_attestation_prepared(false); | 483 fake_cryptohome_client_.set_attestation_prepared(false); |
484 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 484 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
485 base::RunLoop().RunUntilIdle(); | 485 base::RunLoop().RunUntilIdle(); |
486 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); | 486 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); |
487 } | 487 } |
488 | 488 |
489 } // namespace attestation | 489 } // namespace attestation |
490 } // namespace chromeos | 490 } // namespace chromeos |
OLD | NEW |