summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkrahn@chromium.org <dkrahn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 19:10:29 +0000
committerdkrahn@chromium.org <dkrahn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 19:10:29 +0000
commitc56df86ed5b8a11c915e73fa7569c482d6e18f62 (patch)
treec6e221ae7e069b2aee5fb0e95b5e0fe5e1a2fcc4
parent020991d3e5efabd7bc02ec3a159f813e40d0dd85 (diff)
downloadchromium_src-c56df86ed5b8a11c915e73fa7569c482d6e18f62.zip
chromium_src-c56df86ed5b8a11c915e73fa7569c482d6e18f62.tar.gz
chromium_src-c56df86ed5b8a11c915e73fa7569c482d6e18f62.tar.bz2
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
-rw-r--r--chrome/browser/chromeos/attestation/platform_verification_flow.cc49
-rw-r--r--chrome/browser/chromeos/attestation/platform_verification_flow.h3
2 files changed, 50 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/attestation/platform_verification_flow.cc b/chrome/browser/chromeos/attestation/platform_verification_flow.cc
index f29a934..392389f 100644
--- a/chrome/browser/chromeos/attestation/platform_verification_flow.cc
+++ b/chrome/browser/chromeos/attestation/platform_verification_flow.cc
@@ -4,6 +4,7 @@
#include "platform_verification_flow.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
@@ -22,6 +23,11 @@
#include "content/public/browser/web_contents.h"
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.
void DBusCallback(const base::Callback<void(bool)>& on_success,
const base::Closure& on_failure,
@@ -39,6 +45,48 @@ void DBusCallback(const base::Callback<void(bool)>& on_success,
namespace chromeos {
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(
AttestationFlow* attestation_flow,
cryptohome::AsyncMethodCaller* async_caller,
@@ -52,6 +100,7 @@ PlatformVerificationFlow::PlatformVerificationFlow(
user_manager_(user_manager),
statistics_provider_(statistics_provider),
delegate_(delegate),
+ testing_prefs_(NULL),
weak_factory_(this) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
}
diff --git a/chrome/browser/chromeos/attestation/platform_verification_flow.h b/chrome/browser/chromeos/attestation/platform_verification_flow.h
index 0cf868b..6a99c08 100644
--- a/chrome/browser/chromeos/attestation/platform_verification_flow.h
+++ b/chrome/browser/chromeos/attestation/platform_verification_flow.h
@@ -103,8 +103,7 @@ class PlatformVerificationFlow {
// A constructor that uses the default implementation of all dependencies
// including Delegate.
- // TODO(dkrahn): Enable this when the default delegate has been implemented.
- // PlatformVerificationFlow();
+ PlatformVerificationFlow();
// An alternate constructor which specifies dependent objects explicitly.
// This is useful in testing. The caller retains ownership of all pointers.