| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h" | 10 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h" |
| 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 12 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 12 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 14 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth.h" | 14 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth.h" |
| 15 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" | 15 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" |
| 16 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 17 #include "chromeos/chromeos_switches.h" | 17 #include "chromeos/chromeos_switches.h" |
| 18 #include "components/arc/arc_bridge_service.h" | 18 #include "components/arc/arc_bridge_service.h" |
| 19 #include "components/arc/arc_features.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 | 21 |
| 21 namespace arc { | 22 namespace arc { |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 ArcAuthService* g_arc_auth_service = nullptr; | 25 ArcAuthService* g_arc_auth_service = nullptr; |
| 25 | 26 |
| 26 constexpr uint32_t kMinVersionForOnAccountInfoReady = 5; | 27 constexpr uint32_t kMinVersionForOnAccountInfoReady = 5; |
| 27 | 28 |
| 28 // Convers mojom::ArcSignInFailureReason into ProvisiningResult. | 29 // Convers mojom::ArcSignInFailureReason into ProvisiningResult. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 218 |
| 218 // In Kiosk mode, use Robot auth code fetching. | 219 // In Kiosk mode, use Robot auth code fetching. |
| 219 if (ArcSessionManager::IsArcKioskMode()) { | 220 if (ArcSessionManager::IsArcKioskMode()) { |
| 220 arc_robot_auth_.reset(new ArcRobotAuth()); | 221 arc_robot_auth_.reset(new ArcRobotAuth()); |
| 221 arc_robot_auth_->FetchRobotAuthCode( | 222 arc_robot_auth_->FetchRobotAuthCode( |
| 222 base::Bind(&ArcAuthService::OnRobotAuthCodeFetched, | 223 base::Bind(&ArcAuthService::OnRobotAuthCodeFetched, |
| 223 weak_ptr_factory_.GetWeakPtr())); | 224 weak_ptr_factory_.GetWeakPtr())); |
| 224 return; | 225 return; |
| 225 } | 226 } |
| 226 | 227 |
| 227 // If endpoint is passed via command line flag, use automatic auth code | 228 // Optionally retrive auth code in silent mode. |
| 228 // fetching. | 229 if (base::FeatureList::IsEnabled(arc::kArcUseAuthEndpointFeature)) { |
| 229 const base::CommandLine* command_line = | |
| 230 base::CommandLine::ForCurrentProcess(); | |
| 231 std::string auth_endpoint; | |
| 232 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { | |
| 233 auth_endpoint = command_line->GetSwitchValueASCII( | |
| 234 chromeos::switches::kArcUseAuthEndpoint); | |
| 235 } | |
| 236 if (!auth_endpoint.empty()) { | |
| 237 DCHECK(!auth_code_fetcher_); | 230 DCHECK(!auth_code_fetcher_); |
| 238 auth_code_fetcher_ = base::MakeUnique<ArcAuthCodeFetcher>( | 231 auth_code_fetcher_ = base::MakeUnique<ArcAuthCodeFetcher>( |
| 239 ArcSessionManager::Get()->profile(), | 232 ArcSessionManager::Get()->profile(), |
| 240 ArcSessionManager::Get()->auth_context(), auth_endpoint); | 233 ArcSessionManager::Get()->auth_context()); |
| 241 auth_code_fetcher_->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched, | 234 auth_code_fetcher_->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched, |
| 242 weak_ptr_factory_.GetWeakPtr())); | 235 weak_ptr_factory_.GetWeakPtr())); |
| 243 return; | 236 return; |
| 244 } | 237 } |
| 245 | 238 |
| 246 // Otherwise, show LSO page to user after HTTP context preparation, and let | 239 // Otherwise, show LSO page to user after HTTP context preparation, and let |
| 247 // them click "Sign in" button. | 240 // them click "Sign in" button. |
| 248 ArcSessionManager::Get()->auth_context()->Prepare(base::Bind( | 241 ArcSessionManager::Get()->auth_context()->Prepare(base::Bind( |
| 249 &ArcAuthService::OnContextPrepared, weak_ptr_factory_.GetWeakPtr())); | 242 &ArcAuthService::OnContextPrepared, weak_ptr_factory_.GetWeakPtr())); |
| 250 } | 243 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 if (support_host->ui_page() == ArcSupportHost::UIPage::ERROR) { | 323 if (support_host->ui_page() == ArcSupportHost::UIPage::ERROR) { |
| 331 // This case is handled by ArcSessionManager::OnRetryClicked(). | 324 // This case is handled by ArcSessionManager::OnRetryClicked(). |
| 332 return; | 325 return; |
| 333 } | 326 } |
| 334 | 327 |
| 335 ArcSessionManager::Get()->auth_context()->Prepare(base::Bind( | 328 ArcSessionManager::Get()->auth_context()->Prepare(base::Bind( |
| 336 &ArcAuthService::OnContextPrepared, weak_ptr_factory_.GetWeakPtr())); | 329 &ArcAuthService::OnContextPrepared, weak_ptr_factory_.GetWeakPtr())); |
| 337 } | 330 } |
| 338 | 331 |
| 339 } // namespace arc | 332 } // namespace arc |
| OLD | NEW |