Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2599673005: arc: Use GET_INTERFACE_FOR_METHOD macro (Closed)
Patch Set: Added a conversion I missed Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "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_auth_code_fetcher.h" 14 #include "chrome/browser/chromeos/arc/auth/arc_auth_code_fetcher.h"
15 #include "chrome/browser/chromeos/arc/auth/arc_background_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_manual_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_robot_auth_code_fetcher.h" 17 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth_code_fetcher.h"
18 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" 18 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h"
19 #include "chrome/browser/lifetime/application_lifetime.h" 19 #include "chrome/browser/lifetime/application_lifetime.h"
20 #include "chromeos/chromeos_switches.h" 20 #include "chromeos/chromeos_switches.h"
21 #include "components/arc/arc_bridge_service.h" 21 #include "components/arc/arc_bridge_service.h"
22 #include "components/arc/arc_features.h" 22 #include "components/arc/arc_features.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 24
25 namespace arc { 25 namespace arc {
26 namespace { 26 namespace {
27 27
28 ArcAuthService* g_arc_auth_service = nullptr; 28 ArcAuthService* g_arc_auth_service = nullptr;
29 29
30 constexpr uint32_t kMinVersionForOnAccountInfoReady = 5;
31
32 // Convers mojom::ArcSignInFailureReason into ProvisiningResult. 30 // Convers mojom::ArcSignInFailureReason into ProvisiningResult.
33 ProvisioningResult ConvertArcSignInFailureReasonToProvisioningResult( 31 ProvisioningResult ConvertArcSignInFailureReasonToProvisioningResult(
34 mojom::ArcSignInFailureReason reason) { 32 mojom::ArcSignInFailureReason reason) {
35 using ArcSignInFailureReason = mojom::ArcSignInFailureReason; 33 using ArcSignInFailureReason = mojom::ArcSignInFailureReason;
36 34
37 #define MAP_PROVISIONING_RESULT(name) \ 35 #define MAP_PROVISIONING_RESULT(name) \
38 case ArcSignInFailureReason::name: \ 36 case ArcSignInFailureReason::name: \
39 return ProvisioningResult::name 37 return ProvisioningResult::name
40 38
41 switch (reason) { 39 switch (reason) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 g_arc_auth_service = nullptr; 136 g_arc_auth_service = nullptr;
139 } 137 }
140 138
141 // static 139 // static
142 ArcAuthService* ArcAuthService::GetForTest() { 140 ArcAuthService* ArcAuthService::GetForTest() {
143 DCHECK(g_arc_auth_service); 141 DCHECK(g_arc_auth_service);
144 return g_arc_auth_service; 142 return g_arc_auth_service;
145 } 143 }
146 144
147 void ArcAuthService::OnInstanceReady() { 145 void ArcAuthService::OnInstanceReady() {
148 auto* instance = arc_bridge_service()->auth()->GetInstanceForMethod("Init"); 146 auto* instance = GET_INSTANCE_FOR_METHOD(arc_bridge_service()->auth(), Init);
149 DCHECK(instance); 147 DCHECK(instance);
150 instance->Init(binding_.CreateInterfacePtrAndBind()); 148 instance->Init(binding_.CreateInterfacePtrAndBind());
151 } 149 }
152 150
153 void ArcAuthService::OnInstanceClosed() { 151 void ArcAuthService::OnInstanceClosed() {
154 fetcher_.reset(); 152 fetcher_.reset();
155 notifier_.reset(); 153 notifier_.reset();
156 } 154 }
157 155
158 void ArcAuthService::OnSignInComplete() { 156 void ArcAuthService::OnSignInComplete() {
159 ArcSessionManager::Get()->OnProvisioningFinished(ProvisioningResult::SUCCESS); 157 ArcSessionManager::Get()->OnProvisioningFinished(ProvisioningResult::SUCCESS);
160 } 158 }
161 159
162 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) { 160 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) {
163 ArcSessionManager::Get()->OnProvisioningFinished( 161 ArcSessionManager::Get()->OnProvisioningFinished(
164 ConvertArcSignInFailureReasonToProvisioningResult(reason)); 162 ConvertArcSignInFailureReasonToProvisioningResult(reason));
165 } 163 }
166 164
167 void ArcAuthService::RequestAccountInfo() { 165 void ArcAuthService::RequestAccountInfo() {
168 RequestAccountInfoInternal( 166 RequestAccountInfoInternal(
169 base::MakeUnique<ArcAuthService::AccountInfoNotifier>( 167 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(
170 base::Bind(&ArcAuthService::OnAccountInfoReady, 168 base::Bind(&ArcAuthService::OnAccountInfoReady,
171 weak_ptr_factory_.GetWeakPtr()))); 169 weak_ptr_factory_.GetWeakPtr())));
172 } 170 }
173 171
174 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) { 172 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) {
175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 173 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
176 auto* instance = arc_bridge_service()->auth()->GetInstanceForMethod( 174 auto* instance =
177 "OnAccountInfoReady", kMinVersionForOnAccountInfoReady); 175 GET_INSTANCE_FOR_METHOD(arc_bridge_service()->auth(), OnAccountInfoReady);
178 DCHECK(instance); 176 DCHECK(instance);
179 instance->OnAccountInfoReady(std::move(account_info)); 177 instance->OnAccountInfoReady(std::move(account_info));
180 } 178 }
181 179
182 void ArcAuthService::GetAuthCodeDeprecated0( 180 void ArcAuthService::GetAuthCodeDeprecated0(
183 const GetAuthCodeDeprecated0Callback& callback) { 181 const GetAuthCodeDeprecated0Callback& callback) {
184 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 182 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
185 NOTREACHED() << "GetAuthCodeDeprecated0() should no longer be callable"; 183 NOTREACHED() << "GetAuthCodeDeprecated0() should no longer be callable";
186 } 184 }
187 185
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 257 }
260 258
261 notifier_->Notify( 259 notifier_->Notify(
262 !ArcSessionManager::IsOptInVerificationDisabled(), auth_code, 260 !ArcSessionManager::IsOptInVerificationDisabled(), auth_code,
263 GetAccountType(), 261 GetAccountType(),
264 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); 262 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile()));
265 notifier_.reset(); 263 notifier_.reset();
266 } 264 }
267 265
268 } // namespace arc 266 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698