Commit 1bdcf632 authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

Migrate RendererUpdater to IdentityManager

It's currently observer SigninManager but it could instead observe
IdentityManager. This will allow RenderUpdater to eventually use the
identity service.

Bug: 887453
Change-Id: I588bcdaa1e0c5fe02207ad4fabff552193c49766
Reviewed-on: https://chromium-review.googlesource.com/c/1268339
Commit-Queue: Sergio Villar <svillar@igalia.com>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607556}
parent 6f961aae
......@@ -8,7 +8,7 @@
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/renderer_configuration.mojom.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
......@@ -52,9 +52,10 @@ void GetGuestViewDefaultContentSettingRules(
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
} // namespace
RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
signin_manager_ = SigninManagerFactory::GetForProfile(profile_);
signin_manager_->AddObserver(this);
RendererUpdater::RendererUpdater(Profile* profile)
: profile_(profile), identity_manager_observer_(this) {
identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
identity_manager_observer_.Add(identity_manager_);
variations_http_header_provider_ =
variations::VariationsHttpHeaderProvider::GetInstance();
variations_http_header_provider_->AddObserver(this);
......@@ -86,12 +87,12 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
}
RendererUpdater::~RendererUpdater() {
DCHECK(!signin_manager_);
DCHECK(!identity_manager_);
}
void RendererUpdater::Shutdown() {
signin_manager_->RemoveObserver(this);
signin_manager_ = nullptr;
identity_manager_observer_.RemoveAll();
identity_manager_ = nullptr;
variations_http_header_provider_->RemoveObserver(this);
variations_http_header_provider_ = nullptr;
}
......@@ -152,11 +153,11 @@ RendererUpdater::GetRendererConfiguration(
return renderer_configuration;
}
void RendererUpdater::GoogleSigninSucceeded(const AccountInfo& account_info) {
void RendererUpdater::OnPrimaryAccountSet(const AccountInfo& account_info) {
UpdateAllRenderers();
}
void RendererUpdater::GoogleSignedOut(const AccountInfo& account_info) {
void RendererUpdater::OnPrimaryAccountCleared(const AccountInfo& account_info) {
UpdateAllRenderers();
}
......@@ -181,7 +182,7 @@ void RendererUpdater::UpdateRenderer(
force_google_safesearch_.GetValue(),
force_youtube_restrict_.GetValue(),
allowed_domains_for_apps_.GetValue(),
signin_manager_->IsAuthenticated()
identity_manager_->HasPrimaryAccount()
? cached_variation_ids_header_signed_in_
: cached_variation_ids_header_));
}
......@@ -8,12 +8,13 @@
#include <string>
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/common/renderer_configuration.mojom.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_member.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/variations/variations_http_header_provider.h"
#include "services/identity/public/cpp/identity_manager.h"
class Profile;
......@@ -24,7 +25,7 @@ class RenderProcessHost;
// The RendererUpdater is responsible for updating renderers about state change.
class RendererUpdater
: public KeyedService,
public SigninManagerBase::Observer,
public identity::IdentityManager::Observer,
public variations::VariationsHttpHeaderProvider::Observer {
public:
explicit RendererUpdater(Profile* profile);
......@@ -43,9 +44,9 @@ class RendererUpdater
chrome::mojom::RendererConfigurationAssociatedPtr GetRendererConfiguration(
content::RenderProcessHost* render_process_host);
// SigninManagerBase::Observer:
void GoogleSigninSucceeded(const AccountInfo& account_info) override;
void GoogleSignedOut(const AccountInfo& account_info) override;
// IdentityManager::Observer:
void OnPrimaryAccountSet(const AccountInfo& account_info) override;
void OnPrimaryAccountCleared(const AccountInfo& account_info) override;
// VariationsHttpHeaderProvider::Observer:
void VariationIdsHeaderUpdated(
......@@ -61,7 +62,6 @@ class RendererUpdater
Profile* profile_;
PrefChangeRegistrar pref_change_registrar_;
SigninManagerBase* signin_manager_;
variations::VariationsHttpHeaderProvider* variations_http_header_provider_;
// Prefs that we sync to the renderers.
......@@ -72,6 +72,10 @@ class RendererUpdater
std::string cached_variation_ids_header_;
std::string cached_variation_ids_header_signed_in_;
ScopedObserver<identity::IdentityManager, identity::IdentityManager::Observer>
identity_manager_observer_;
identity::IdentityManager* identity_manager_;
DISALLOW_COPY_AND_ASSIGN(RendererUpdater);
};
......
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