Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/signin/chrome_proximity_auth_client.h" | 5 #include "chrome/browser/signin/chrome_proximity_auth_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | |
| 9 #include "base/sys_info.h" | |
| 10 #include "base/version.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_window.h" | 12 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/signin/easy_unlock_service.h" | 13 #include "chrome/browser/signin/easy_unlock_service.h" |
| 14 #include "chrome/browser/signin/easy_unlock_service_regular.h" | |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 11 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
| 17 #include "components/proximity_auth/cryptauth/cryptauth_client_impl.h" | |
| 18 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h" | |
| 19 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" | |
| 20 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | |
| 21 #include "components/signin/core/browser/profile_oauth2_token_service.h" | |
| 12 #include "components/signin/core/browser/signin_manager_base.h" | 22 #include "components/signin/core/browser/signin_manager_base.h" |
| 23 #include "components/version_info/version_info.h" | |
| 24 | |
| 25 #if defined(OS_CHROMEOS) | |
| 26 #include "chrome/browser/chromeos/login/easy_unlock/secure_message_delegate_chro meos.h" | |
| 27 #endif | |
| 13 | 28 |
| 14 using proximity_auth::ScreenlockState; | 29 using proximity_auth::ScreenlockState; |
| 15 | 30 |
| 16 ChromeProximityAuthClient::ChromeProximityAuthClient(Profile* profile) | 31 ChromeProximityAuthClient::ChromeProximityAuthClient(Profile* profile) |
| 17 : profile_(profile) { | 32 : profile_(profile) { |
| 18 } | 33 } |
| 19 | 34 |
| 20 ChromeProximityAuthClient::~ChromeProximityAuthClient() { | 35 ChromeProximityAuthClient::~ChromeProximityAuthClient() { |
| 21 } | 36 } |
| 22 | 37 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 39 EasyUnlockService* service = EasyUnlockService::Get(profile_); | 54 EasyUnlockService* service = EasyUnlockService::Get(profile_); |
| 40 if (service) | 55 if (service) |
| 41 service->FinalizeUnlock(success); | 56 service->FinalizeUnlock(success); |
| 42 } | 57 } |
| 43 | 58 |
| 44 void ChromeProximityAuthClient::FinalizeSignin(const std::string& secret) { | 59 void ChromeProximityAuthClient::FinalizeSignin(const std::string& secret) { |
| 45 EasyUnlockService* service = EasyUnlockService::Get(profile_); | 60 EasyUnlockService* service = EasyUnlockService::Get(profile_); |
| 46 if (service) | 61 if (service) |
| 47 service->FinalizeSignin(secret); | 62 service->FinalizeSignin(secret); |
| 48 } | 63 } |
| 64 | |
| 65 PrefService* ChromeProximityAuthClient::GetPrefService() { | |
| 66 return profile_->GetPrefs(); | |
| 67 } | |
| 68 | |
| 69 scoped_ptr<proximity_auth::SecureMessageDelegate> | |
| 70 ChromeProximityAuthClient::CreateSecureMessageDelegate() { | |
| 71 #if defined(OS_CHROMEOS) | |
| 72 return make_scoped_ptr(new chromeos::SecureMessageDelegateChromeOS()); | |
| 73 #else | |
| 74 return nullptr; | |
| 75 #endif | |
| 76 } | |
| 77 | |
| 78 scoped_ptr<proximity_auth::CryptAuthClientFactory> | |
| 79 ChromeProximityAuthClient::CreateCryptAuthClientFactory() { | |
| 80 return make_scoped_ptr(new proximity_auth::CryptAuthClientFactoryImpl( | |
| 81 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), GetAccountId(), | |
| 82 profile_->GetRequestContext(), GetDeviceClassifier())); | |
| 83 } | |
| 84 | |
| 85 cryptauth::DeviceClassifier ChromeProximityAuthClient::GetDeviceClassifier() { | |
| 86 cryptauth::DeviceClassifier device_classifier; | |
| 87 | |
| 88 #if defined(OS_CHROMEOS) | |
| 89 int32 major_version, minor_version, bugfix_version; | |
| 90 // TODO(tengs): base::OperatingSystemVersionNumbers only works for ChromeOS. | |
| 91 // We need to get different numbers for other platforms. | |
| 92 base::SysInfo::OperatingSystemVersionNumbers(&major_version, &minor_version, | |
| 93 &bugfix_version); | |
| 94 device_classifier.set_device_os_version_code(major_version); | |
| 95 device_classifier.set_device_type(cryptauth::CHROME); | |
|
sacomoto
2015/08/27 11:29:31
This is sent to CryptAuth, right? Why does it need
Tim Song
2015/08/27 18:23:52
The people maintaining CryptAuth want to distingui
sacomoto
2015/08/28 14:40:23
I see. Thanks.
| |
| 96 #endif | |
| 97 | |
| 98 const std::vector<uint32_t>& version_components = | |
| 99 base::Version(version_info::GetVersionNumber()).components(); | |
| 100 if (version_components.size() > 0) | |
| 101 device_classifier.set_device_software_version_code(version_components[0]); | |
| 102 | |
| 103 device_classifier.set_device_software_package(version_info::GetProductName()); | |
| 104 return device_classifier; | |
| 105 } | |
| 106 | |
| 107 std::string ChromeProximityAuthClient::GetAccountId() { | |
| 108 return SigninManagerFactory::GetForProfile(profile_) | |
| 109 ->GetAuthenticatedAccountId(); | |
| 110 } | |
| 111 | |
| 112 proximity_auth::CryptAuthEnrollmentManager* | |
| 113 ChromeProximityAuthClient::GetCryptAuthEnrollmentManager() { | |
| 114 // TODO(tengs): Return the real manager instance once it is implemented in | |
| 115 // EasyUnlockService. | |
| 116 return nullptr; | |
| 117 } | |
| 118 | |
| 119 proximity_auth::CryptAuthDeviceManager* | |
| 120 ChromeProximityAuthClient::GetCryptAuthDeviceManager() { | |
| 121 // TODO(tengs): Return the real manager instance once it is implemented in | |
| 122 // EasyUnlockService. | |
| 123 return nullptr; | |
| 124 } | |
| OLD | NEW |