Commit b7ed9196 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] kUseMultiloginEndpoint linked to kWKHTTPSystemCookieStore

kUseMultiloginEndpoint can only be enabled if kWKHTTPSystemCookieStore
is enabled. CookieManager::SetCanonicalCookie() fails to store the
cookies.

Bug: 902584, 892130
Change-Id: If3ba635f031e7de830c87b7a97fd262a9e6e2cee
Reviewed-on: https://chromium-review.googlesource.com/c/1352324
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612157}
parent df04c03b
...@@ -226,6 +226,12 @@ void AccountReconcilor::Initialize(bool start_reconcile_if_tokens_available) { ...@@ -226,6 +226,12 @@ void AccountReconcilor::Initialize(bool start_reconcile_if_tokens_available) {
} }
} }
#if defined(OS_IOS)
void AccountReconcilor::SetIsWKHTTPSystemCookieStoreEnabled(bool is_enabled) {
is_wkhttp_system_cookie_store_enabled_ = is_enabled;
}
#endif // defined(OS_IOS)
void AccountReconcilor::EnableReconcile() { void AccountReconcilor::EnableReconcile() {
DCHECK(delegate_->IsReconcileEnabled()); DCHECK(delegate_->IsReconcileEnabled());
RegisterWithCookieManagerService(); RegisterWithCookieManagerService();
...@@ -568,7 +574,7 @@ void AccountReconcilor::OnGaiaAccountsInCookieUpdated( ...@@ -568,7 +574,7 @@ void AccountReconcilor::OnGaiaAccountsInCookieUpdated(
return; return;
} }
if (base::FeatureList::IsEnabled(kUseMultiloginEndpoint)) { if (IsMultiloginEndpointEnabled()) {
FinishReconcileWithMultiloginEndpoint(primary_account, FinishReconcileWithMultiloginEndpoint(primary_account,
LoadValidAccountsFromTokenService(), LoadValidAccountsFromTokenService(),
std::move(verified_gaia_accounts)); std::move(verified_gaia_accounts));
...@@ -905,3 +911,14 @@ void AccountReconcilor::HandleReconcileTimeout() { ...@@ -905,3 +911,14 @@ void AccountReconcilor::HandleReconcileTimeout() {
AbortReconcile(); AbortReconcile();
DCHECK(!timer_->IsRunning()); DCHECK(!timer_->IsRunning());
} }
bool AccountReconcilor::IsMultiloginEndpointEnabled() const {
#if defined(OS_IOS)
// kUseMultiloginEndpoint feature should not be used if
// kWKHTTPSystemCookieStore feature is disabbled.
// See http://crbug.com/902584.
if (!is_wkhttp_system_cookie_store_enabled_)
return false;
#endif // defined(OS_IOS)
return base::FeatureList::IsEnabled(kUseMultiloginEndpoint);
}
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "build/build_config.h"
#include "components/content_settings/core/browser/content_settings_observer.h" #include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/common/content_settings_pattern.h" #include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -109,6 +110,11 @@ class AccountReconcilor : public KeyedService, ...@@ -109,6 +110,11 @@ class AccountReconcilor : public KeyedService,
// construction. // construction.
void Initialize(bool start_reconcile_if_tokens_available); void Initialize(bool start_reconcile_if_tokens_available);
#if defined(OS_IOS)
// Sets the WKHTTPSystemCookieStore flag value.
void SetIsWKHTTPSystemCookieStoreEnabled(bool is_enabled);
#endif // defined(OS_IOS)
// Enables and disables the reconciliation. // Enables and disables the reconciliation.
void EnableReconcile(); void EnableReconcile();
void DisableReconcile(bool logout_all_gaia_accounts); void DisableReconcile(bool logout_all_gaia_accounts);
...@@ -303,6 +309,9 @@ class AccountReconcilor : public KeyedService, ...@@ -303,6 +309,9 @@ class AccountReconcilor : public KeyedService,
void HandleReconcileTimeout(); void HandleReconcileTimeout();
// Returns true is multilogin endpoint can be enabled.
bool IsMultiloginEndpointEnabled() const;
std::unique_ptr<signin::AccountReconcilorDelegate> delegate_; std::unique_ptr<signin::AccountReconcilorDelegate> delegate_;
// The ProfileOAuth2TokenService associated with this reconcilor. // The ProfileOAuth2TokenService associated with this reconcilor.
...@@ -371,6 +380,11 @@ class AccountReconcilor : public KeyedService, ...@@ -371,6 +380,11 @@ class AccountReconcilor : public KeyedService,
// not invalidate the primary token while this is happening. // not invalidate the primary token while this is happening.
int synced_data_deletion_in_progress_count_ = 0; int synced_data_deletion_in_progress_count_ = 0;
#if defined(OS_IOS)
// Stores the WKHTTPSystemCookieStore flag value.
bool is_wkhttp_system_cookie_store_enabled_ = false;
#endif // defined(OS_IOS)
base::WeakPtrFactory<AccountReconcilor> weak_factory_; base::WeakPtrFactory<AccountReconcilor> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); DISALLOW_COPY_AND_ASSIGN(AccountReconcilor);
......
...@@ -131,6 +131,9 @@ class DummyAccountReconcilorWithDelegate : public AccountReconcilor { ...@@ -131,6 +131,9 @@ class DummyAccountReconcilorWithDelegate : public AccountReconcilor {
CreateAccountReconcilorDelegate(client, CreateAccountReconcilorDelegate(client,
identity_manager, identity_manager,
account_consistency)) { account_consistency)) {
#if defined(OS_IOS)
SetIsWKHTTPSystemCookieStoreEnabled(true);
#endif // defined(OS_IOS)
Initialize(false /* start_reconcile_if_tokens_available */); Initialize(false /* start_reconcile_if_tokens_available */);
} }
...@@ -148,6 +151,9 @@ class DummyAccountReconcilorWithDelegate : public AccountReconcilor { ...@@ -148,6 +151,9 @@ class DummyAccountReconcilorWithDelegate : public AccountReconcilor {
client, client,
cookie_manager_service, cookie_manager_service,
std::unique_ptr<signin::AccountReconcilorDelegate>(delegate)) { std::unique_ptr<signin::AccountReconcilorDelegate>(delegate)) {
#if defined(OS_IOS)
SetIsWKHTTPSystemCookieStoreEnabled(true);
#endif // defined(OS_IOS)
Initialize(false /* start_reconcile_if_tokens_available */); Initialize(false /* start_reconcile_if_tokens_available */);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "build/build_config.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h" #include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/signin/core/browser/account_reconcilor.h" #include "components/signin/core/browser/account_reconcilor.h"
#include "components/signin/core/browser/mirror_account_reconcilor_delegate.h" #include "components/signin/core/browser/mirror_account_reconcilor_delegate.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "ios/chrome/browser/signin/identity_manager_factory.h" #include "ios/chrome/browser/signin/identity_manager_factory.h"
#include "ios/chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "ios/chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "ios/chrome/browser/signin/signin_client_factory.h" #include "ios/chrome/browser/signin/signin_client_factory.h"
#include "ios/web/public/features.h"
#include "services/identity/public/cpp/identity_manager.h" #include "services/identity/public/cpp/identity_manager.h"
namespace ios { namespace ios {
...@@ -57,6 +59,10 @@ std::unique_ptr<KeyedService> AccountReconcilorFactory::BuildServiceInstanceFor( ...@@ -57,6 +59,10 @@ std::unique_ptr<KeyedService> AccountReconcilorFactory::BuildServiceInstanceFor(
GaiaCookieManagerServiceFactory::GetForBrowserState(chrome_browser_state), GaiaCookieManagerServiceFactory::GetForBrowserState(chrome_browser_state),
std::make_unique<signin::MirrorAccountReconcilorDelegate>( std::make_unique<signin::MirrorAccountReconcilorDelegate>(
identity_manager))); identity_manager)));
#if defined(OS_IOS)
reconcilor->SetIsWKHTTPSystemCookieStoreEnabled(
base::FeatureList::IsEnabled(web::features::kWKHTTPSystemCookieStore));
#endif // defined(OS_IOS)
reconcilor->Initialize(true /* start_reconcile_if_tokens_available */); reconcilor->Initialize(true /* start_reconcile_if_tokens_available */);
return reconcilor; return reconcilor;
} }
......
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