OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "blimp/client/app/android/blimp_client_context_delegate_android.h" | |
6 | |
7 #include "base/memory/ptr_util.h" | |
8 #include "base/strings/string_number_conversions.h" | |
9 #include "base/strings/utf_string_conversions.h" | |
10 #include "blimp/client/public/blimp_client_context.h" | |
11 #include "blimp/client/public/blimp_client_context_delegate.h" | |
12 #include "blimp/client/public/contents/blimp_contents.h" | |
13 #include "blimp/client/public/resources/blimp_strings.h" | |
14 #include "blimp/client/support/resources/blimp_strings.h" | |
15 #include "blimp/client/support/session/blimp_default_identity_provider.h" | |
16 #include "components/signin/core/browser/profile_identity_provider.h" | |
17 #include "components/signin/core/browser/signin_manager.h" | |
18 #include "net/base/net_errors.h" | |
19 #include "ui/base/l10n/l10n_util.h" | |
20 | |
21 namespace blimp { | |
22 namespace client { | |
23 | |
24 BlimpClientContextDelegateAndroid::BlimpClientContextDelegateAndroid( | |
25 BlimpClientContext* blimp_client_context) | |
26 : blimp_client_context_(blimp_client_context) { | |
27 blimp_client_context_->SetDelegate(this); | |
28 } | |
29 | |
30 BlimpClientContextDelegateAndroid::~BlimpClientContextDelegateAndroid() { | |
31 blimp_client_context_->SetDelegate(nullptr); | |
32 } | |
33 | |
34 void BlimpClientContextDelegateAndroid::AttachBlimpContentsHelpers( | |
35 BlimpContents* blimp_contents) {} | |
36 | |
37 void BlimpClientContextDelegateAndroid::OnAssignmentConnectionAttempted( | |
38 AssignmentRequestResult result, | |
39 const Assignment& assignment) { | |
40 if (result == blimp::client::ASSIGNMENT_REQUEST_RESULT_OK) | |
41 return; | |
42 base::string16 message = blimp::string::BlimpPrefix( | |
43 blimp::string::AssignmentResultErrorToString(result)); | |
44 ShowMessage(message); | |
45 } | |
46 | |
47 std::unique_ptr<IdentityProvider> | |
48 BlimpClientContextDelegateAndroid::CreateIdentityProvider() { | |
49 return base::MakeUnique<BlimpDefaultIdentityProvider>(); | |
50 } | |
51 | |
52 void BlimpClientContextDelegateAndroid::OnAuthenticationError( | |
53 const GoogleServiceAuthError& error) { | |
54 LOG(ERROR) << "GoogleAuth error : " << error.ToString(); | |
55 base::string16 message = blimp::string::BlimpPrefix( | |
56 l10n_util::GetStringUTF16(IDS_BLIMP_SIGNIN_GET_TOKEN_FAILED)); | |
57 ShowMessage(message); | |
58 } | |
59 | |
60 void BlimpClientContextDelegateAndroid::OnConnected() { | |
61 base::string16 message = blimp::string::BlimpPrefix( | |
62 l10n_util::GetStringUTF16(IDS_BLIMP_NETWORK_CONNECTED)); | |
63 ShowMessage(message); | |
64 } | |
65 | |
66 void BlimpClientContextDelegateAndroid::OnEngineDisconnected(int result) { | |
67 OnDisconnected(blimp::string::EndConnectionMessageToString(result)); | |
68 } | |
69 | |
70 void BlimpClientContextDelegateAndroid::OnNetworkDisconnected(int result) { | |
71 OnDisconnected(base::UTF8ToUTF16(net::ErrorToShortString(result))); | |
72 } | |
73 | |
74 void BlimpClientContextDelegateAndroid::OnDisconnected( | |
75 const base::string16& reason) { | |
76 ShowMessage(blimp::string::BlimpPrefix( | |
77 l10n_util::GetStringFUTF16(IDS_BLIMP_NETWORK_DISCONNECTED, reason))); | |
78 } | |
79 | |
80 void BlimpClientContextDelegateAndroid::ShowMessage( | |
81 const base::string16& message) { | |
82 VLOG(1) << "ShowMessage: " << message; | |
83 } | |
84 | |
85 } // namespace client | |
86 } // namespace blimp | |
OLD | NEW |