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

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

Issue 23470003: Implemented a switch for bypassing platform verification consent UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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
« no previous file with comments | « chrome/browser/chromeos/attestation/platform_verification_flow.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "platform_verification_flow.h" 5 #include "platform_verification_flow.h"
6 6
7 #include "base/command_line.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" 10 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
10 #include "chrome/browser/chromeos/login/user_manager.h" 11 #include "chrome/browser/chromeos/login/user_manager.h"
11 #include "chrome/browser/chromeos/settings/cros_settings.h" 12 #include "chrome/browser/chromeos/settings/cros_settings.h"
12 #include "chrome/browser/chromeos/system/statistics_provider.h" 13 #include "chrome/browser/chromeos/system/statistics_provider.h"
13 #include "chrome/browser/prefs/scoped_user_pref_update.h" 14 #include "chrome/browser/prefs/scoped_user_pref_update.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chromeos/attestation/attestation_flow.h" 16 #include "chromeos/attestation/attestation_flow.h"
16 #include "chromeos/cryptohome/async_method_caller.h" 17 #include "chromeos/cryptohome/async_method_caller.h"
17 #include "chromeos/dbus/cryptohome_client.h" 18 #include "chromeos/dbus/cryptohome_client.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "components/user_prefs/pref_registry_syncable.h" 20 #include "components/user_prefs/pref_registry_syncable.h"
20 #include "components/user_prefs/user_prefs.h" 21 #include "components/user_prefs/user_prefs.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 24
24 namespace { 25 namespace {
26 // A switch which allows consent to be given on the command line.
27 // TODO(dkrahn): Remove this when UI has been implemented.
Mattias Nissler (ping if slow) 2013/09/06 13:40:21 nit: Can you reference the bug that tracks UI impl
Darren Krahn 2013/09/06 15:52:59 Done.
28 const char kAutoApproveSwitch[] =
29 "auto-approve-platform-verification-consent-prompts";
30
25 // A callback method to handle DBus errors. 31 // A callback method to handle DBus errors.
26 void DBusCallback(const base::Callback<void(bool)>& on_success, 32 void DBusCallback(const base::Callback<void(bool)>& on_success,
27 const base::Closure& on_failure, 33 const base::Closure& on_failure,
28 chromeos::DBusMethodCallStatus call_status, 34 chromeos::DBusMethodCallStatus call_status,
29 bool result) { 35 bool result) {
30 if (call_status == chromeos::DBUS_METHOD_CALL_SUCCESS) { 36 if (call_status == chromeos::DBUS_METHOD_CALL_SUCCESS) {
31 on_success.Run(result); 37 on_success.Run(result);
32 } else { 38 } else {
33 LOG(ERROR) << "PlatformVerificationFlow: DBus call failed!"; 39 LOG(ERROR) << "PlatformVerificationFlow: DBus call failed!";
34 on_failure.Run(); 40 on_failure.Run();
35 } 41 }
36 } 42 }
37 } // namespace 43 } // namespace
38 44
39 namespace chromeos { 45 namespace chromeos {
40 namespace attestation { 46 namespace attestation {
41 47
48 // A default implementation of the Delegate interface.
49 class DefaultDelegate : public PlatformVerificationFlow::Delegate {
50 public:
51 DefaultDelegate() {}
52 virtual ~DefaultDelegate() {}
53
54 virtual void ShowConsentPrompt(
55 PlatformVerificationFlow::ConsentType type,
56 content::WebContents* web_contents,
57 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) {
58 if (CommandLine::ForCurrentProcess()->HasSwitch(kAutoApproveSwitch)) {
59 LOG(WARNING) << "PlatformVerificationFlow: Automatic approval enabled.";
60 callback.Run(PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW);
61 } else {
62 LOG(ERROR) << "PlatformVerificationFlow: Consent prompt not implemented.";
Mattias Nissler (ping if slow) 2013/09/06 13:40:21 NOTIMPLEMENTED() might be the thing you're looking
Darren Krahn 2013/09/06 15:52:59 Done.
63 callback.Run(PlatformVerificationFlow::CONSENT_RESPONSE_NONE);
64 }
65 }
66
67 private:
68 DISALLOW_COPY_AND_ASSIGN(DefaultDelegate);
69 };
70
71 PlatformVerificationFlow::PlatformVerificationFlow()
72 : attestation_flow_(NULL),
73 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()),
74 cryptohome_client_(DBusThreadManager::Get()->GetCryptohomeClient()),
75 user_manager_(UserManager::Get()),
76 delegate_(NULL),
77 testing_prefs_(NULL),
78 weak_factory_(this) {
79 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
80 scoped_ptr<ServerProxy> attestation_ca_client(new AttestationCAClient());
81 default_attestation_flow_.reset(new AttestationFlow(
82 async_caller_,
83 cryptohome_client_,
84 attestation_ca_client.Pass()));
85 attestation_flow_ = default_attestation_flow_.get();
86 default_delegate_.reset(new DefaultDelegate());
87 delegate_ = default_delegate_.get();
88 }
89
42 PlatformVerificationFlow::PlatformVerificationFlow( 90 PlatformVerificationFlow::PlatformVerificationFlow(
43 AttestationFlow* attestation_flow, 91 AttestationFlow* attestation_flow,
44 cryptohome::AsyncMethodCaller* async_caller, 92 cryptohome::AsyncMethodCaller* async_caller,
45 CryptohomeClient* cryptohome_client, 93 CryptohomeClient* cryptohome_client,
46 UserManager* user_manager, 94 UserManager* user_manager,
47 system::StatisticsProvider* statistics_provider, 95 system::StatisticsProvider* statistics_provider,
48 Delegate* delegate) 96 Delegate* delegate)
49 : attestation_flow_(attestation_flow), 97 : attestation_flow_(attestation_flow),
50 async_caller_(async_caller), 98 async_caller_(async_caller),
51 cryptohome_client_(cryptohome_client), 99 cryptohome_client_(cryptohome_client),
52 user_manager_(user_manager), 100 user_manager_(user_manager),
53 statistics_provider_(statistics_provider), 101 statistics_provider_(statistics_provider),
54 delegate_(delegate), 102 delegate_(delegate),
103 testing_prefs_(NULL),
55 weak_factory_(this) { 104 weak_factory_(this) {
56 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 105 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
57 } 106 }
58 107
59 PlatformVerificationFlow::~PlatformVerificationFlow() { 108 PlatformVerificationFlow::~PlatformVerificationFlow() {
60 } 109 }
61 110
62 void PlatformVerificationFlow::ChallengePlatformKey( 111 void PlatformVerificationFlow::ChallengePlatformKey(
63 content::WebContents* web_contents, 112 content::WebContents* web_contents,
64 const std::string& service_id, 113 const std::string& service_id,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 bool allow_domain) { 393 bool allow_domain) {
345 PrefService* pref_service = GetPrefs(web_contents); 394 PrefService* pref_service = GetPrefs(web_contents);
346 CHECK(pref_service); 395 CHECK(pref_service);
347 DictionaryPrefUpdate updater(pref_service, prefs::kRAConsentDomains); 396 DictionaryPrefUpdate updater(pref_service, prefs::kRAConsentDomains);
348 const GURL& url = GetURL(web_contents); 397 const GURL& url = GetURL(web_contents);
349 updater->SetBoolean(url.host(), allow_domain); 398 updater->SetBoolean(url.host(), allow_domain);
350 } 399 }
351 400
352 } // namespace attestation 401 } // namespace attestation
353 } // namespace chromeos 402 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/attestation/platform_verification_flow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698