| 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/chromeos/arc/arc_auth_service.h" | 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/time/time.h" |
| 12 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 13 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 14 #include "chrome/browser/chromeos/arc/auth/arc_auth_code_fetcher.h" | 15 #include "chrome/browser/chromeos/arc/auth/arc_auth_code_fetcher.h" |
| 15 #include "chrome/browser/chromeos/arc/auth/arc_background_auth_code_fetcher.h" | 16 #include "chrome/browser/chromeos/arc/auth/arc_background_auth_code_fetcher.h" |
| 16 #include "chrome/browser/chromeos/arc/auth/arc_manual_auth_code_fetcher.h" | 17 #include "chrome/browser/chromeos/arc/auth/arc_manual_auth_code_fetcher.h" |
| 17 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth_code_fetcher.h" | 18 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth_code_fetcher.h" |
| 18 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" | 19 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chromeos/chromeos_switches.h" | 21 #include "chromeos/chromeos_switches.h" |
| 21 #include "components/arc/arc_bridge_service.h" | 22 #include "components/arc/arc_bridge_service.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 ConvertArcSignInFailureReasonToProvisioningResult(reason)); | 164 ConvertArcSignInFailureReasonToProvisioningResult(reason)); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void ArcAuthService::RequestAccountInfo() { | 167 void ArcAuthService::RequestAccountInfo() { |
| 167 RequestAccountInfoInternal( | 168 RequestAccountInfoInternal( |
| 168 base::MakeUnique<ArcAuthService::AccountInfoNotifier>( | 169 base::MakeUnique<ArcAuthService::AccountInfoNotifier>( |
| 169 base::Bind(&ArcAuthService::OnAccountInfoReady, | 170 base::Bind(&ArcAuthService::OnAccountInfoReady, |
| 170 weak_ptr_factory_.GetWeakPtr()))); | 171 weak_ptr_factory_.GetWeakPtr()))); |
| 171 } | 172 } |
| 172 | 173 |
| 174 void ArcAuthService::ReportMetrics(mojom::MetricsType metrics_type, |
| 175 int32_t value) { |
| 176 switch (metrics_type) { |
| 177 case mojom::MetricsType::NETWORK_WAITING_TIME_MILLISECONDS: |
| 178 UpdateAuthTiming("ArcAuth.NetworkWaitTime", |
| 179 base::TimeDelta::FromMilliseconds(value)); |
| 180 break; |
| 181 case mojom::MetricsType::CHECKIN_ATTEMPTS: |
| 182 UpdateAuthCheckinAttempts(value); |
| 183 break; |
| 184 case mojom::MetricsType::CHECKIN_TIME_MILLISECONDS: |
| 185 UpdateAuthTiming("ArcAuth.CheckinTime", |
| 186 base::TimeDelta::FromMilliseconds(value)); |
| 187 break; |
| 188 case mojom::MetricsType::SIGNIN_TIME_MILLISECONDS: |
| 189 UpdateAuthTiming("ArcAuth.SignInTime", |
| 190 base::TimeDelta::FromMilliseconds(value)); |
| 191 break; |
| 192 } |
| 193 } |
| 194 |
| 173 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) { | 195 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) { |
| 174 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 196 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 175 auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->auth(), | 197 auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->auth(), |
| 176 OnAccountInfoReady); | 198 OnAccountInfoReady); |
| 177 DCHECK(instance); | 199 DCHECK(instance); |
| 178 instance->OnAccountInfoReady(std::move(account_info)); | 200 instance->OnAccountInfoReady(std::move(account_info)); |
| 179 } | 201 } |
| 180 | 202 |
| 181 void ArcAuthService::GetAuthCodeDeprecated0( | 203 void ArcAuthService::GetAuthCodeDeprecated0( |
| 182 const GetAuthCodeDeprecated0Callback& callback) { | 204 const GetAuthCodeDeprecated0Callback& callback) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 280 } |
| 259 | 281 |
| 260 notifier_->Notify( | 282 notifier_->Notify( |
| 261 !ArcSessionManager::IsOptInVerificationDisabled(), auth_code, | 283 !ArcSessionManager::IsOptInVerificationDisabled(), auth_code, |
| 262 GetAccountType(), | 284 GetAccountType(), |
| 263 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); | 285 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); |
| 264 notifier_.reset(); | 286 notifier_.reset(); |
| 265 } | 287 } |
| 266 | 288 |
| 267 } // namespace arc | 289 } // namespace arc |
| OLD | NEW |