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

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

Issue 2204223005: Blimp OAuth2 token retreival on application start up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some deps only for gn deps check script. Created 4 years, 4 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 "blimp/client/public/blimp_client_context.h" 8 #include "blimp/client/public/blimp_client_context.h"
8 #include "blimp/client/public/blimp_client_context_delegate.h" 9 #include "blimp/client/public/blimp_client_context_delegate.h"
9 #include "blimp/client/public/contents/blimp_contents.h" 10 #include "blimp/client/public/contents/blimp_contents.h"
10 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" 11 #include "chrome/browser/android/blimp/blimp_client_context_factory.h"
11 #include "chrome/browser/android/blimp/blimp_contents_profile_attachment.h" 12 #include "chrome/browser/android/blimp/blimp_contents_profile_attachment.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "components/signin/core/browser/profile_identity_provider.h"
17 #include "components/signin/core/browser/signin_manager.h"
13 18
14 ChromeBlimpClientContextDelegate::ChromeBlimpClientContextDelegate( 19 ChromeBlimpClientContextDelegate::ChromeBlimpClientContextDelegate(
15 Profile* profile) 20 Profile* profile)
16 : profile_(profile), 21 : profile_(profile),
17 blimp_client_context_( 22 blimp_client_context_(
18 BlimpClientContextFactory::GetForBrowserContext(profile)) { 23 BlimpClientContextFactory::GetForBrowserContext(profile)) {
19 blimp_client_context_->SetDelegate(this); 24 blimp_client_context_->SetDelegate(this);
20 } 25 }
21 26
22 ChromeBlimpClientContextDelegate::~ChromeBlimpClientContextDelegate() { 27 ChromeBlimpClientContextDelegate::~ChromeBlimpClientContextDelegate() {
23 blimp_client_context_->SetDelegate(nullptr); 28 blimp_client_context_->SetDelegate(nullptr);
24 } 29 }
25 30
26 void ChromeBlimpClientContextDelegate::AttachBlimpContentsHelpers( 31 void ChromeBlimpClientContextDelegate::AttachBlimpContentsHelpers(
27 blimp::client::BlimpContents* blimp_contents) { 32 blimp::client::BlimpContents* blimp_contents) {
28 AttachProfileToBlimpContents(blimp_contents, profile_); 33 AttachProfileToBlimpContents(blimp_contents, profile_);
29 } 34 }
30 35
31 void ChromeBlimpClientContextDelegate::OnAssignmentConnectionAttempted( 36 void ChromeBlimpClientContextDelegate::OnAssignmentConnectionAttempted(
32 blimp::client::AssignmentRequestResult result, 37 blimp::client::AssignmentRequestResult result,
33 const blimp::client::Assignment& assignment) {} 38 const blimp::client::Assignment& assignment) {}
39
40 std::unique_ptr<IdentityProvider>
41 ChromeBlimpClientContextDelegate::CreateIdentityProvider() {
42 return base::WrapUnique<IdentityProvider>(new ProfileIdentityProvider(
nyquist 2016/08/12 05:47:05 Is it so that MakeUnique can't be used because the
xingliu 2016/08/12 17:58:28 Yes, the reason to use abstract class here is main
43 SigninManagerFactory::GetForProfile(profile_),
44 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
45 base::Closure()));
46 }
47
48 void ChromeBlimpClientContextDelegate::OnError(
49 BlimpClientContextDelegate::BlimpError error) {
50 switch (error) {
nyquist 2016/08/12 05:47:05 Should this have a default statement?
xingliu 2016/08/12 17:58:28 Done.
51 case BlimpError::NOT_SIGNED_IN:
52 // User need to signed in first, on Android it's handled in Java layer
53 // before the connection.
54 VLOG(1) << "User is not signed in before connection to Blimp.";
55 break;
56 case BlimpError::OAUTH_TOKEN_FAIL:
57 // TODO(xingliu): Alert the user in UI.
58 // There is an known issue that ongoing request can be cancelled when
59 // Android layer updates the refresh token.
60 break;
61 }
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698