| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/policy/user_policy_identity_strategy.h" | 5 #include "chrome/browser/policy/user_policy_identity_strategy.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_signin.h" | 7 #include "chrome/browser/browser_signin.h" |
| 8 #include "chrome/browser/net/gaia/token_service.h" | 8 #include "chrome/browser/net/gaia/token_service.h" |
| 9 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 9 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 10 #include "chrome/browser/policy/proto/device_management_constants.h" | 10 #include "chrome/browser/policy/proto/device_management_constants.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 NotificationService::AllSources()); | 42 NotificationService::AllSources()); |
| 43 #else | 43 #else |
| 44 registrar_.Add(this, | 44 registrar_.Add(this, |
| 45 NotificationType::GOOGLE_SIGNIN_SUCCESSFUL, | 45 NotificationType::GOOGLE_SIGNIN_SUCCESSFUL, |
| 46 Source<Profile>(profile_)); | 46 Source<Profile>(profile_)); |
| 47 #endif | 47 #endif |
| 48 } | 48 } |
| 49 | 49 |
| 50 UserPolicyIdentityStrategy::~UserPolicyIdentityStrategy() {} | 50 UserPolicyIdentityStrategy::~UserPolicyIdentityStrategy() {} |
| 51 | 51 |
| 52 void UserPolicyIdentityStrategy::LoadTokenCache() { | |
| 53 cache_->Load(); | |
| 54 } | |
| 55 | |
| 56 std::string UserPolicyIdentityStrategy::GetDeviceToken() { | 52 std::string UserPolicyIdentityStrategy::GetDeviceToken() { |
| 57 return device_token_; | 53 return device_token_; |
| 58 } | 54 } |
| 59 | 55 |
| 60 std::string UserPolicyIdentityStrategy::GetDeviceID() { | 56 std::string UserPolicyIdentityStrategy::GetDeviceID() { |
| 61 return device_id_; | 57 return device_id_; |
| 62 } | 58 } |
| 63 | 59 |
| 64 std::string UserPolicyIdentityStrategy::GetMachineID() { | 60 std::string UserPolicyIdentityStrategy::GetMachineID() { |
| 65 return std::string(); | 61 return std::string(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 } | 84 } |
| 89 | 85 |
| 90 void UserPolicyIdentityStrategy::OnDeviceTokenAvailable( | 86 void UserPolicyIdentityStrategy::OnDeviceTokenAvailable( |
| 91 const std::string& token) { | 87 const std::string& token) { |
| 92 DCHECK(!device_id_.empty()); | 88 DCHECK(!device_id_.empty()); |
| 93 device_token_ = token; | 89 device_token_ = token; |
| 94 cache_->Store(device_token_, device_id_); | 90 cache_->Store(device_token_, device_id_); |
| 95 NotifyDeviceTokenChanged(); | 91 NotifyDeviceTokenChanged(); |
| 96 } | 92 } |
| 97 | 93 |
| 94 void UserPolicyIdentityStrategy::LoadTokenCache() { |
| 95 cache_->Load(); |
| 96 } |
| 97 |
| 98 std::string UserPolicyIdentityStrategy::GetCurrentUser() { | 98 std::string UserPolicyIdentityStrategy::GetCurrentUser() { |
| 99 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
| 100 // TODO(mnissler) On CrOS it seems impossible to figure out what user belongs | 100 // TODO(mnissler) On CrOS it seems impossible to figure out what user belongs |
| 101 // to a profile. Revisit after multi-profile support landed. | 101 // to a profile. Revisit after multi-profile support landed. |
| 102 return chromeos::UserManager::Get()->logged_in_user().email(); | 102 return chromeos::UserManager::Get()->logged_in_user().email(); |
| 103 #else | 103 #else |
| 104 return profile_->GetBrowserSignin()->GetSignedInUsername(); | 104 return profile_->GetBrowserSignin()->GetSignedInUsername(); |
| 105 #endif | 105 #endif |
| 106 } | 106 } |
| 107 | 107 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } else if (type == NotificationType::GOOGLE_SIGNIN_SUCCESSFUL) { | 150 } else if (type == NotificationType::GOOGLE_SIGNIN_SUCCESSFUL) { |
| 151 if (profile_ == Source<Profile>(source).ptr()) | 151 if (profile_ == Source<Profile>(source).ptr()) |
| 152 CheckAndTriggerFetch(); | 152 CheckAndTriggerFetch(); |
| 153 #endif | 153 #endif |
| 154 } else { | 154 } else { |
| 155 NOTREACHED(); | 155 NOTREACHED(); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace policy | 159 } // namespace policy |
| OLD | NEW |