Chromium Code Reviews| OLD | NEW |
|---|---|
| 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( | |
| 43 SigninManagerFactory::GetForProfile(profile_), | |
| 44 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), | |
| 45 base::Closure())); | |
| 46 } | |
| 47 | |
| 48 void ChromeBlimpClientContextDelegate::OnAuthenticationError( | |
| 49 BlimpClientContextDelegate::AuthError error) { | |
| 50 switch (error) { | |
| 51 case AuthError::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 AuthError::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 default: | |
| 62 VLOG(1) << "Unknown Blimp error."; | |
|
nyquist
2016/08/16 18:38:06
I don't think this should ever happen, so maybe LO
xingliu
2016/08/17 00:32:24
Done.
| |
| 63 } | |
| 64 } | |
| OLD | NEW |