| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/auth/arc_manual_auth_code_fetcher.h" | 5 #include "chrome/browser/chromeos/arc/auth/arc_manual_auth_code_fetcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/chromeos/arc/arc_auth_context.h" | 10 #include "chrome/browser/chromeos/arc/arc_auth_context.h" |
| 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 12 | 12 |
| 13 namespace arc { | 13 namespace arc { |
| 14 | 14 |
| 15 ArcManualAuthCodeFetcher::ArcManualAuthCodeFetcher(ArcAuthContext* context, | 15 ArcManualAuthCodeFetcher::ArcManualAuthCodeFetcher(ArcAuthContext* context, |
| 16 ArcSupportHost* support_host) | 16 ArcSupportHost* support_host) |
| 17 : context_(context), support_host_(support_host), weak_ptr_factory_(this) { | 17 : context_(context), support_host_(support_host), weak_ptr_factory_(this) { |
| 18 DCHECK(context_); | 18 DCHECK(context_); |
| 19 DCHECK(support_host_); | 19 DCHECK(support_host_); |
| 20 support_host_->AddObserver(this); | 20 support_host_->SetAuthDelegate(this); |
| 21 } | 21 } |
| 22 | 22 |
| 23 ArcManualAuthCodeFetcher::~ArcManualAuthCodeFetcher() { | 23 ArcManualAuthCodeFetcher::~ArcManualAuthCodeFetcher() { |
| 24 support_host_->RemoveObserver(this); | 24 support_host_->SetAuthDelegate(nullptr); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void ArcManualAuthCodeFetcher::Fetch(const FetchCallback& callback) { | 27 void ArcManualAuthCodeFetcher::Fetch(const FetchCallback& callback) { |
| 28 DCHECK(pending_callback_.is_null()); | 28 DCHECK(pending_callback_.is_null()); |
| 29 pending_callback_ = callback; | 29 pending_callback_ = callback; |
| 30 | 30 |
| 31 FetchInternal(); | 31 FetchInternal(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void ArcManualAuthCodeFetcher::FetchInternal() { | 34 void ArcManualAuthCodeFetcher::FetchInternal() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 DCHECK(!pending_callback_.is_null()); | 54 DCHECK(!pending_callback_.is_null()); |
| 55 base::ResetAndReturn(&pending_callback_).Run(true /* success */, auth_code); | 55 base::ResetAndReturn(&pending_callback_).Run(true /* success */, auth_code); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ArcManualAuthCodeFetcher::OnAuthFailed() { | 58 void ArcManualAuthCodeFetcher::OnAuthFailed() { |
| 59 // Don't report via callback. Extension is already showing more detailed | 59 // Don't report via callback. Extension is already showing more detailed |
| 60 // information. Update only UMA here. | 60 // information. Update only UMA here. |
| 61 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 61 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ArcManualAuthCodeFetcher::OnRetryClicked() { | 64 void ArcManualAuthCodeFetcher::OnAuthRetryClicked() { |
| 65 DCHECK(!pending_callback_.is_null()); | 65 DCHECK(!pending_callback_.is_null()); |
| 66 FetchInternal(); | 66 FetchInternal(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace arc | 69 } // namespace arc |
| OLD | NEW |