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_impl.h" | 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 namespace arc { | 9 namespace arc { |
10 | 10 |
11 ArcAuthServiceImpl::ArcAuthServiceImpl() : binding_(this) {} | 11 ArcAuthService::ArcAuthService(ArcBridgeService* arc_bridge) : binding_(this) { |
12 arc_bridge->AddObserver(this); | |
12 | 13 |
13 ArcAuthServiceImpl::~ArcAuthServiceImpl() { | 14 // If AuthInstance was ready before we AddObserver(), we won't get |
15 // OnAuthInstanceReady events. For such case, we have to call it explicitly. | |
16 if (arc_bridge->auth_instance()) | |
17 OnAuthInstanceReady(); | |
18 } | |
19 | |
20 ArcAuthService::~ArcAuthService() { | |
14 ArcBridgeService::Get()->RemoveObserver(this); | 21 ArcBridgeService::Get()->RemoveObserver(this); |
hidehiko
2016/01/18 01:26:44
For consistency, could you keep the |arc_bridge| p
Luis Héctor Chávez
2016/01/19 17:43:54
Done.
| |
15 } | 22 } |
16 | 23 |
17 void ArcAuthServiceImpl::StartObservingBridgeServiceChanges() { | 24 void ArcAuthService::OnAuthInstanceReady() { |
18 ArcBridgeService::Get()->AddObserver(this); | |
19 } | |
20 | |
21 void ArcAuthServiceImpl::OnAuthInstanceReady() { | |
22 arc::AuthHostPtr host; | 25 arc::AuthHostPtr host; |
23 binding_.Bind(GetProxy(&host)); | 26 binding_.Bind(GetProxy(&host)); |
24 ArcBridgeService::Get()->auth_instance()->Init(std::move(host)); | 27 ArcBridgeService::Get()->auth_instance()->Init(std::move(host)); |
25 } | 28 } |
26 | 29 |
27 void ArcAuthServiceImpl::GetAuthCode(const GetAuthCodeCallback& callback) { | 30 void ArcAuthService::GetAuthCode(const GetAuthCodeCallback& callback) { |
28 // TODO(victorhsieh): request auth code from LSO (crbug.com/571146). | 31 // TODO(victorhsieh): request auth code from LSO (crbug.com/571146). |
29 callback.Run(mojo::String("fake auth code from ArcAuthService in Chrome")); | 32 callback.Run(mojo::String("fake auth code from ArcAuthService in Chrome")); |
30 } | 33 } |
31 | 34 |
32 } // namespace arc | 35 } // namespace arc |
OLD | NEW |