Commit c56df86e authored by dkrahn@chromium.org's avatar dkrahn@chromium.org

Implemented a switch for bypassing platform verification consent UI.

UI for the consent prompt is not ready yet but we want a way to perform an
end-to-end integration test.  This allows the consent to be explicitly given
on the command line.

BUG=chromium:270316
TEST=unit, manual

Review URL: https://chromiumcodereview.appspot.com/23470003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221747 0039d316-1c4b-4281-b951-d872f2087c98
parent 020991d3
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "platform_verification_flow.h" #include "platform_verification_flow.h"
#include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "chrome/browser/chromeos/attestation/attestation_ca_client.h" #include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
...@@ -22,6 +23,11 @@ ...@@ -22,6 +23,11 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
namespace { namespace {
// A switch which allows consent to be given on the command line.
// TODO(dkrahn): Remove this when UI has been implemented (crbug.com/270908).
const char kAutoApproveSwitch[] =
"auto-approve-platform-verification-consent-prompts";
// A callback method to handle DBus errors. // A callback method to handle DBus errors.
void DBusCallback(const base::Callback<void(bool)>& on_success, void DBusCallback(const base::Callback<void(bool)>& on_success,
const base::Closure& on_failure, const base::Closure& on_failure,
...@@ -39,6 +45,48 @@ void DBusCallback(const base::Callback<void(bool)>& on_success, ...@@ -39,6 +45,48 @@ void DBusCallback(const base::Callback<void(bool)>& on_success,
namespace chromeos { namespace chromeos {
namespace attestation { namespace attestation {
// A default implementation of the Delegate interface.
class DefaultDelegate : public PlatformVerificationFlow::Delegate {
public:
DefaultDelegate() {}
virtual ~DefaultDelegate() {}
virtual void ShowConsentPrompt(
PlatformVerificationFlow::ConsentType type,
content::WebContents* web_contents,
const PlatformVerificationFlow::Delegate::ConsentCallback& callback)
OVERRIDE {
if (CommandLine::ForCurrentProcess()->HasSwitch(kAutoApproveSwitch)) {
LOG(WARNING) << "PlatformVerificationFlow: Automatic approval enabled.";
callback.Run(PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW);
} else {
NOTIMPLEMENTED();
}
}
private:
DISALLOW_COPY_AND_ASSIGN(DefaultDelegate);
};
PlatformVerificationFlow::PlatformVerificationFlow()
: attestation_flow_(NULL),
async_caller_(cryptohome::AsyncMethodCaller::GetInstance()),
cryptohome_client_(DBusThreadManager::Get()->GetCryptohomeClient()),
user_manager_(UserManager::Get()),
delegate_(NULL),
testing_prefs_(NULL),
weak_factory_(this) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
scoped_ptr<ServerProxy> attestation_ca_client(new AttestationCAClient());
default_attestation_flow_.reset(new AttestationFlow(
async_caller_,
cryptohome_client_,
attestation_ca_client.Pass()));
attestation_flow_ = default_attestation_flow_.get();
default_delegate_.reset(new DefaultDelegate());
delegate_ = default_delegate_.get();
}
PlatformVerificationFlow::PlatformVerificationFlow( PlatformVerificationFlow::PlatformVerificationFlow(
AttestationFlow* attestation_flow, AttestationFlow* attestation_flow,
cryptohome::AsyncMethodCaller* async_caller, cryptohome::AsyncMethodCaller* async_caller,
...@@ -52,6 +100,7 @@ PlatformVerificationFlow::PlatformVerificationFlow( ...@@ -52,6 +100,7 @@ PlatformVerificationFlow::PlatformVerificationFlow(
user_manager_(user_manager), user_manager_(user_manager),
statistics_provider_(statistics_provider), statistics_provider_(statistics_provider),
delegate_(delegate), delegate_(delegate),
testing_prefs_(NULL),
weak_factory_(this) { weak_factory_(this) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
} }
......
...@@ -103,8 +103,7 @@ class PlatformVerificationFlow { ...@@ -103,8 +103,7 @@ class PlatformVerificationFlow {
// A constructor that uses the default implementation of all dependencies // A constructor that uses the default implementation of all dependencies
// including Delegate. // including Delegate.
// TODO(dkrahn): Enable this when the default delegate has been implemented. PlatformVerificationFlow();
// PlatformVerificationFlow();
// An alternate constructor which specifies dependent objects explicitly. // An alternate constructor which specifies dependent objects explicitly.
// This is useful in testing. The caller retains ownership of all pointers. // This is useful in testing. The caller retains ownership of all pointers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment