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

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

Issue 398753004: [cros] Move User class to user_manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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
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/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/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" 13 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
14 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" 14 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h"
15 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" 15 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
16 #include "chrome/browser/chromeos/login/users/user.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 16 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 17 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "chrome/browser/content_settings/host_content_settings_map.h" 18 #include "chrome/browser/content_settings/host_content_settings_map.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/content_settings_pattern.h" 20 #include "chrome/common/content_settings_pattern.h"
22 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
23 #include "chromeos/attestation/attestation_flow.h" 22 #include "chromeos/attestation/attestation_flow.h"
24 #include "chromeos/cryptohome/async_method_caller.h" 23 #include "chromeos/cryptohome/async_method_caller.h"
25 #include "chromeos/dbus/cryptohome_client.h" 24 #include "chromeos/dbus/cryptohome_client.h"
26 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
27 #include "components/pref_registry/pref_registry_syncable.h" 26 #include "components/pref_registry/pref_registry_syncable.h"
27 #include "components/user_manager/user.h"
28 #include "components/user_prefs/user_prefs.h" 28 #include "components/user_prefs/user_prefs.h"
29 #include "content/public/browser/browser_context.h" 29 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/user_metrics.h" 31 #include "content/public/browser/user_metrics.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 #include "content/public/common/url_constants.h" 33 #include "content/public/common/url_constants.h"
34 #include "net/cert/x509_certificate.h" 34 #include "net/cert/x509_certificate.h"
35 35
36 namespace { 36 namespace {
37 37
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()); 80 return user_prefs::UserPrefs::Get(web_contents->GetBrowserContext());
81 } 81 }
82 82
83 virtual const GURL& GetURL(content::WebContents* web_contents) OVERRIDE { 83 virtual const GURL& GetURL(content::WebContents* web_contents) OVERRIDE {
84 const GURL& url = web_contents->GetLastCommittedURL(); 84 const GURL& url = web_contents->GetLastCommittedURL();
85 if (!url.is_valid()) 85 if (!url.is_valid())
86 return web_contents->GetVisibleURL(); 86 return web_contents->GetVisibleURL();
87 return url; 87 return url;
88 } 88 }
89 89
90 virtual User* GetUser(content::WebContents* web_contents) OVERRIDE { 90 virtual user_manager::User* GetUser(
91 content::WebContents* web_contents) OVERRIDE {
91 return ProfileHelper::Get()->GetUserByProfile( 92 return ProfileHelper::Get()->GetUserByProfile(
92 Profile::FromBrowserContext(web_contents->GetBrowserContext())); 93 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
93 } 94 }
94 95
95 virtual HostContentSettingsMap* GetContentSettings( 96 virtual HostContentSettingsMap* GetContentSettings(
96 content::WebContents* web_contents) OVERRIDE { 97 content::WebContents* web_contents) OVERRIDE {
97 return Profile::FromBrowserContext(web_contents->GetBrowserContext())-> 98 return Profile::FromBrowserContext(web_contents->GetBrowserContext())->
98 GetHostContentSettingsMap(); 99 GetHostContentSettingsMap();
99 } 100 }
100 101
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return; 248 return;
248 } else if (consent_response == CONSENT_RESPONSE_ALLOW) { 249 } else if (consent_response == CONSENT_RESPONSE_ALLOW) {
249 content::RecordAction( 250 content::RecordAction(
250 base::UserMetricsAction("PlatformVerificationAccepted")); 251 base::UserMetricsAction("PlatformVerificationAccepted"));
251 VLOG(1) << "Platform verification accepted by user."; 252 VLOG(1) << "Platform verification accepted by user.";
252 } 253 }
253 } 254 }
254 255
255 // At this point all user interaction is complete and we can proceed with the 256 // At this point all user interaction is complete and we can proceed with the
256 // certificate request. 257 // certificate request.
257 chromeos::User* user = delegate_->GetUser(context.web_contents); 258 user_manager::User* user = delegate_->GetUser(context.web_contents);
258 if (!user) { 259 if (!user) {
259 ReportError(context.callback, INTERNAL_ERROR); 260 ReportError(context.callback, INTERNAL_ERROR);
260 LOG(ERROR) << "Profile does not map to a valid user."; 261 LOG(ERROR) << "Profile does not map to a valid user.";
261 return; 262 return;
262 } 263 }
263 264
264 GetCertificate(context, user->email(), false /* Don't force a new key */); 265 GetCertificate(context, user->email(), false /* Don't force a new key */);
265 } 266 }
266 267
267 void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context, 268 void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 certificate.length())); 471 certificate.length()));
471 if (!x509.get() || x509->valid_expiry().is_null()) { 472 if (!x509.get() || x509->valid_expiry().is_null()) {
472 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; 473 LOG(WARNING) << "Failed to parse certificate, cannot check expiry.";
473 return false; 474 return false;
474 } 475 }
475 return (base::Time::Now() > x509->valid_expiry()); 476 return (base::Time::Now() > x509->valid_expiry());
476 } 477 }
477 478
478 } // namespace attestation 479 } // namespace attestation
479 } // namespace chromeos 480 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698