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

Side by Side Diff: chrome/browser/android/blimp/chrome_blimp_client_context_delegate.cc

Issue 2406203003: Added blimp support strings. (Closed)
Patch Set: Created 4 years, 2 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 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/android/blimp/chrome_blimp_client_context_delegate.h" 5 #include "chrome/browser/android/blimp/chrome_blimp_client_context_delegate.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "blimp/client/public/blimp_client_context.h" 10 #include "blimp/client/public/blimp_client_context.h"
11 #include "blimp/client/public/blimp_client_context_delegate.h" 11 #include "blimp/client/public/blimp_client_context_delegate.h"
12 #include "blimp/client/public/contents/blimp_contents.h" 12 #include "blimp/client/public/contents/blimp_contents.h"
13 #include "blimp/client/support/resources/blimp_strings.h"
13 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" 14 #include "chrome/browser/android/blimp/blimp_client_context_factory.h"
14 #include "chrome/browser/android/blimp/blimp_contents_profile_attachment.h" 15 #include "chrome/browser/android/blimp/blimp_contents_profile_attachment.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
17 #include "chrome/browser/signin/signin_manager_factory.h" 18 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "components/signin/core/browser/profile_identity_provider.h" 19 #include "components/signin/core/browser/profile_identity_provider.h"
19 #include "components/signin/core/browser/signin_manager.h" 20 #include "components/signin/core/browser/signin_manager.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 #include "ui/base/l10n/l10n_util.h"
21 23
22 ChromeBlimpClientContextDelegate::ChromeBlimpClientContextDelegate( 24 ChromeBlimpClientContextDelegate::ChromeBlimpClientContextDelegate(
23 Profile* profile) 25 Profile* profile)
24 : profile_(profile), 26 : profile_(profile),
25 blimp_client_context_( 27 blimp_client_context_(
26 BlimpClientContextFactory::GetForBrowserContext(profile)) { 28 BlimpClientContextFactory::GetForBrowserContext(profile)) {
27 blimp_client_context_->SetDelegate(this); 29 blimp_client_context_->SetDelegate(this);
28 } 30 }
29 31
30 ChromeBlimpClientContextDelegate::~ChromeBlimpClientContextDelegate() { 32 ChromeBlimpClientContextDelegate::~ChromeBlimpClientContextDelegate() {
31 blimp_client_context_->SetDelegate(nullptr); 33 blimp_client_context_->SetDelegate(nullptr);
32 } 34 }
33 35
34 void ChromeBlimpClientContextDelegate::AttachBlimpContentsHelpers( 36 void ChromeBlimpClientContextDelegate::AttachBlimpContentsHelpers(
35 blimp::client::BlimpContents* blimp_contents) { 37 blimp::client::BlimpContents* blimp_contents) {
36 AttachProfileToBlimpContents(blimp_contents, profile_); 38 AttachProfileToBlimpContents(blimp_contents, profile_);
37 } 39 }
38 40
39 void ChromeBlimpClientContextDelegate::OnAssignmentConnectionAttempted( 41 void ChromeBlimpClientContextDelegate::OnAssignmentConnectionAttempted(
40 blimp::client::AssignmentRequestResult result, 42 blimp::client::AssignmentRequestResult result,
41 const blimp::client::Assignment& assignment) { 43 const blimp::client::Assignment& assignment) {
42 if (result == blimp::client::ASSIGNMENT_REQUEST_RESULT_OK) 44 if (result == blimp::client::ASSIGNMENT_REQUEST_RESULT_OK)
43 return; 45 return;
44 46
45 // TODO(xingliu): All strings shown in the UI should be accessed through grd 47 // TODO(xingliu): All strings shown in the UI should be accessed through grd
46 // files. https://crbug.com/630687 48 // files. https://crbug.com/630687
47 std::stringstream ss; 49 std::stringstream ss;
48 ss << "Blimp: Assignment failed, reason: " << result << "."; 50 ss << "Assignment failed, reason: " << result << ".";
49 ShowMessage(base::UTF8ToUTF16(ss.str()), false); 51 base::string16 message =
52 l10n_util::GetStringFUTF16(IDS_BLIMP_TAG, base::UTF8ToUTF16(ss.str()));
53 ShowMessage(message, false);
50 } 54 }
51 55
52 std::unique_ptr<IdentityProvider> 56 std::unique_ptr<IdentityProvider>
53 ChromeBlimpClientContextDelegate::CreateIdentityProvider() { 57 ChromeBlimpClientContextDelegate::CreateIdentityProvider() {
54 return base::WrapUnique<IdentityProvider>(new ProfileIdentityProvider( 58 return base::WrapUnique<IdentityProvider>(new ProfileIdentityProvider(
55 SigninManagerFactory::GetForProfile(profile_), 59 SigninManagerFactory::GetForProfile(profile_),
56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), 60 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
57 base::Closure())); 61 base::Closure()));
58 } 62 }
59 63
60 void ChromeBlimpClientContextDelegate::OnAuthenticationError( 64 void ChromeBlimpClientContextDelegate::OnAuthenticationError(
61 const GoogleServiceAuthError& error) { 65 const GoogleServiceAuthError& error) {
62 LOG(ERROR) << "GoogleAuth error : " << error.ToString(); 66 LOG(ERROR) << "GoogleAuth error : " << error.ToString();
63 ShowMessage(base::UTF8ToUTF16("Blimp: Failed to get OAuth2 token."), false); 67 base::string16 message = l10n_util::GetStringFUTF16(
68 IDS_BLIMP_TAG,
69 l10n_util::GetStringUTF16(IDS_BLIMP_SIGNIN_GET_TOKEN_FAILED));
70 ShowMessage(message, false);
64 } 71 }
65 72
66 void ChromeBlimpClientContextDelegate::OnConnected() { 73 void ChromeBlimpClientContextDelegate::OnConnected() {
67 ShowMessage(base::UTF8ToUTF16("Blimp: Connected."), true); 74 base::string16 message = l10n_util::GetStringFUTF16(
75 IDS_BLIMP_TAG, l10n_util::GetStringUTF16(IDS_BLIMP_NETWORK_CONNECTED));
76 ShowMessage(message, true);
68 } 77 }
69 78
70 void ChromeBlimpClientContextDelegate::OnEngineDisconnected(int result) { 79 void ChromeBlimpClientContextDelegate::OnEngineDisconnected(int result) {
71 OnDisconnected(base::UTF8ToUTF16(base::IntToString(result))); 80 OnDisconnected(base::UTF8ToUTF16(base::IntToString(result)));
72 } 81 }
73 82
74 void ChromeBlimpClientContextDelegate::OnNetworkDisconnected(int result) { 83 void ChromeBlimpClientContextDelegate::OnNetworkDisconnected(int result) {
75 OnDisconnected(base::UTF8ToUTF16(net::ErrorToShortString(result))); 84 OnDisconnected(base::UTF8ToUTF16(net::ErrorToShortString(result)));
76 } 85 }
77 86
78 void ChromeBlimpClientContextDelegate::ShowMessage( 87 void ChromeBlimpClientContextDelegate::ShowMessage(
79 const base::string16& message, 88 const base::string16& message,
80 bool short_message) {} 89 bool short_message) {}
81 90
82 void ChromeBlimpClientContextDelegate::OnDisconnected( 91 void ChromeBlimpClientContextDelegate::OnDisconnected(
83 const base::string16& reason) { 92 const base::string16& reason) {
84 std::stringstream ss; 93 base::string16 disconnected_str = l10n_util::GetStringFUTF16(
David Trainor- moved to gerrit 2016/10/13 03:59:34 Eh just inline this like the OnConnected string.
xingliu 2016/10/13 18:00:58 Makes sense.
xingliu 2016/10/13 21:00:14 On 2016/10/13 18:00:58, xingliu wrote: > On 2016/1
85 ss << "Blimp: Disconnected(" << reason << ")."; 94 IDS_BLIMP_NETWORK_DISCONNECTED, reason);
86 ShowMessage(base::UTF8ToUTF16(ss.str()), false); 95 base::string16 message = l10n_util::GetStringFUTF16(
96 IDS_BLIMP_TAG, disconnected_str);
97 ShowMessage(message, false);
87 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698