Commit 18058e87 authored by Pâris MEULEMAN's avatar Pâris MEULEMAN Committed by Commit Bot

Add virtual GetJavaObject on profile_oauth2_token_service_delegate

This makes GetJavaObject from oauth2_token_service_delegate_android
virtual and defined on the base class,
profile_oauth2_token_service_delegate. It is a prerequisite to the
internalization of oauth2_token_service_delegate_android, as
IdentityManager.java will need a reference on OAuth2TokenService.java on
construction. This also avoids the use of a static_cast to
oauth2_token_service_delegate_android in Identity_manager that is not
always valid.

details here:
  https://docs.google.com/document/d/1_ks5kg3qr6TVq7NT6MFg6lh5Yiv-1lic6Rsd9nu5ubI/edit?usp=sharing


Bug: 934688
Change-Id: Ie0c6d3e004dadd36fe21147a55616d782f2939dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1748892
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695970}
parent 8ca32022
...@@ -22,8 +22,6 @@ source_set("identity_manager") { ...@@ -22,8 +22,6 @@ source_set("identity_manager") {
"diagnostics_provider_impl.h", "diagnostics_provider_impl.h",
"gaia_cookie_manager_service.cc", "gaia_cookie_manager_service.cc",
"gaia_cookie_manager_service.h", "gaia_cookie_manager_service.h",
"mutable_profile_oauth2_token_service_delegate.cc",
"mutable_profile_oauth2_token_service_delegate.h",
"oauth2_token_service_delegate_android.cc", "oauth2_token_service_delegate_android.cc",
"oauth2_token_service_delegate_android.h", "oauth2_token_service_delegate_android.h",
"oauth_multilogin_helper.cc", "oauth_multilogin_helper.cc",
...@@ -73,6 +71,11 @@ source_set("identity_manager") { ...@@ -73,6 +71,11 @@ source_set("identity_manager") {
if (is_android) { if (is_android) {
deps += [ "//components/signin/core/browser/android:jni_headers" ] deps += [ "//components/signin/core/browser/android:jni_headers" ]
} else {
sources += [
"mutable_profile_oauth2_token_service_delegate.cc",
"mutable_profile_oauth2_token_service_delegate.h",
]
} }
if (is_chromeos) { if (is_chromeos) {
...@@ -117,7 +120,6 @@ source_set("unit_tests") { ...@@ -117,7 +120,6 @@ source_set("unit_tests") {
"account_info_util_unittest.cc", "account_info_util_unittest.cc",
"account_tracker_service_unittest.cc", "account_tracker_service_unittest.cc",
"gaia_cookie_manager_service_unittest.cc", "gaia_cookie_manager_service_unittest.cc",
"mutable_profile_oauth2_token_service_delegate_unittest.cc",
"oauth2_token_service_delegate_android_unittest.cc", "oauth2_token_service_delegate_android_unittest.cc",
"oauth_multilogin_helper_unittest.cc", "oauth_multilogin_helper_unittest.cc",
"oauth_multilogin_token_fetcher_unittest.cc", "oauth_multilogin_token_fetcher_unittest.cc",
...@@ -167,6 +169,10 @@ source_set("unit_tests") { ...@@ -167,6 +169,10 @@ source_set("unit_tests") {
deps += [ "//components/signin/public/identity_manager/ios:test_support" ] deps += [ "//components/signin/public/identity_manager/ios:test_support" ]
} }
if (!is_android) {
sources += [ "mutable_profile_oauth2_token_service_delegate_unittest.cc" ]
}
} }
# This target contains test support that backs the test support for # This target contains test support that backs the test support for
......
...@@ -168,3 +168,11 @@ void FakeProfileOAuth2TokenServiceDelegate::UpdateAuthError( ...@@ -168,3 +168,11 @@ void FakeProfileOAuth2TokenServiceDelegate::UpdateAuthError(
it->second->error = error; it->second->error = error;
FireAuthErrorChanged(account_id, error); FireAuthErrorChanged(account_id, error);
} }
#if defined(OS_ANDROID)
base::android::ScopedJavaLocalRef<jobject>
FakeProfileOAuth2TokenServiceDelegate::GetJavaObject() {
NOTREACHED();
return base::android::ScopedJavaLocalRef<jobject>();
}
#endif
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "components/signin/internal/identity_manager/profile_oauth2_token_service_delegate.h" #include "components/signin/internal/identity_manager/profile_oauth2_token_service_delegate.h"
#include "google_apis/gaia/google_service_auth_error.h" #include "google_apis/gaia/google_service_auth_error.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
...@@ -73,6 +74,10 @@ class FakeProfileOAuth2TokenServiceDelegate ...@@ -73,6 +74,10 @@ class FakeProfileOAuth2TokenServiceDelegate
void IssueRefreshTokenForUser(const CoreAccountId& account_id, void IssueRefreshTokenForUser(const CoreAccountId& account_id,
const std::string& token); const std::string& token);
#if defined(OS_ANDROID)
base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override;
#endif
// Maps account ids to info. // Maps account ids to info.
std::map<CoreAccountId, std::unique_ptr<AccountInfo>> refresh_tokens_; std::map<CoreAccountId, std::unique_ptr<AccountInfo>> refresh_tokens_;
......
...@@ -38,7 +38,7 @@ class OAuth2TokenServiceDelegateAndroid ...@@ -38,7 +38,7 @@ class OAuth2TokenServiceDelegateAndroid
static OAuth2TokenServiceDelegateAndroid* Create(); static OAuth2TokenServiceDelegateAndroid* Create();
// Returns a reference to the corresponding Java OAuth2TokenService object. // Returns a reference to the corresponding Java OAuth2TokenService object.
base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override;
// Called by the TestingProfile class to disable account validation in // Called by the TestingProfile class to disable account validation in
// tests. This prevents the token service from trying to look up system // tests. This prevents the token service from trying to look up system
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "google_apis/gaia/oauth2_access_token_manager.h" #include "google_apis/gaia/oauth2_access_token_manager.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
#if defined(OS_ANDROID)
#include "base/android/jni_android.h"
#endif
namespace network { namespace network {
class SharedURLLoaderFactory; class SharedURLLoaderFactory;
} }
...@@ -133,6 +137,9 @@ class ProfileOAuth2TokenServiceDelegate { ...@@ -133,6 +137,9 @@ class ProfileOAuth2TokenServiceDelegate {
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Returns a reference to the corresponding Java object.
virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0;
// Triggers platform specific implementation for Android to reload accounts // Triggers platform specific implementation for Android to reload accounts
// from system. // from system.
virtual void ReloadAccountsFromSystem( virtual void ReloadAccountsFromSystem(
......
...@@ -419,10 +419,7 @@ IdentityManager::LegacyGetAccountTrackerServiceJavaObject() { ...@@ -419,10 +419,7 @@ IdentityManager::LegacyGetAccountTrackerServiceJavaObject() {
base::android::ScopedJavaLocalRef<jobject> base::android::ScopedJavaLocalRef<jobject>
IdentityManager::LegacyGetOAuth2TokenServiceJavaObject() { IdentityManager::LegacyGetOAuth2TokenServiceJavaObject() {
OAuth2TokenServiceDelegateAndroid* delegate = return token_service_->GetDelegate()->GetJavaObject();
static_cast<OAuth2TokenServiceDelegateAndroid*>(
token_service_->GetDelegate());
return delegate->GetJavaObject();
} }
base::android::ScopedJavaLocalRef<jobject> IdentityManager::GetJavaObject() { base::android::ScopedJavaLocalRef<jobject> IdentityManager::GetJavaObject() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment