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 @@ ...@@ -8,7 +8,7 @@
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.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/pref_names.h"
#include "chrome/common/renderer_configuration.mojom.h" #include "chrome/common/renderer_configuration.mojom.h"
#include "components/content_settings/core/browser/content_settings_utils.h" #include "components/content_settings/core/browser/content_settings_utils.h"
...@@ -52,9 +52,10 @@ void GetGuestViewDefaultContentSettingRules( ...@@ -52,9 +52,10 @@ void GetGuestViewDefaultContentSettingRules(
#endif // BUILDFLAG(ENABLE_EXTENSIONS) #endif // BUILDFLAG(ENABLE_EXTENSIONS)
} // namespace } // namespace
RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) { RendererUpdater::RendererUpdater(Profile* profile)
signin_manager_ = SigninManagerFactory::GetForProfile(profile_); : profile_(profile), identity_manager_observer_(this) {
signin_manager_->AddObserver(this); identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
identity_manager_observer_.Add(identity_manager_);
variations_http_header_provider_ = variations_http_header_provider_ =
variations::VariationsHttpHeaderProvider::GetInstance(); variations::VariationsHttpHeaderProvider::GetInstance();
variations_http_header_provider_->AddObserver(this); variations_http_header_provider_->AddObserver(this);
...@@ -86,12 +87,12 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) { ...@@ -86,12 +87,12 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
} }
RendererUpdater::~RendererUpdater() { RendererUpdater::~RendererUpdater() {
DCHECK(!signin_manager_); DCHECK(!identity_manager_);
} }
void RendererUpdater::Shutdown() { void RendererUpdater::Shutdown() {
signin_manager_->RemoveObserver(this); identity_manager_observer_.RemoveAll();
signin_manager_ = nullptr; identity_manager_ = nullptr;
variations_http_header_provider_->RemoveObserver(this); variations_http_header_provider_->RemoveObserver(this);
variations_http_header_provider_ = nullptr; variations_http_header_provider_ = nullptr;
} }
...@@ -152,11 +153,11 @@ RendererUpdater::GetRendererConfiguration( ...@@ -152,11 +153,11 @@ RendererUpdater::GetRendererConfiguration(
return renderer_configuration; return renderer_configuration;
} }
void RendererUpdater::GoogleSigninSucceeded(const AccountInfo& account_info) { void RendererUpdater::OnPrimaryAccountSet(const AccountInfo& account_info) {
UpdateAllRenderers(); UpdateAllRenderers();
} }
void RendererUpdater::GoogleSignedOut(const AccountInfo& account_info) { void RendererUpdater::OnPrimaryAccountCleared(const AccountInfo& account_info) {
UpdateAllRenderers(); UpdateAllRenderers();
} }
...@@ -181,7 +182,7 @@ void RendererUpdater::UpdateRenderer( ...@@ -181,7 +182,7 @@ void RendererUpdater::UpdateRenderer(
force_google_safesearch_.GetValue(), force_google_safesearch_.GetValue(),
force_youtube_restrict_.GetValue(), force_youtube_restrict_.GetValue(),
allowed_domains_for_apps_.GetValue(), allowed_domains_for_apps_.GetValue(),
signin_manager_->IsAuthenticated() identity_manager_->HasPrimaryAccount()
? cached_variation_ids_header_signed_in_ ? cached_variation_ids_header_signed_in_
: cached_variation_ids_header_)); : cached_variation_ids_header_));
} }
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
#include <string> #include <string>
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/common/renderer_configuration.mojom.h" #include "chrome/common/renderer_configuration.mojom.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/variations/variations_http_header_provider.h" #include "components/variations/variations_http_header_provider.h"
#include "services/identity/public/cpp/identity_manager.h"
class Profile; class Profile;
...@@ -24,7 +25,7 @@ class RenderProcessHost; ...@@ -24,7 +25,7 @@ class RenderProcessHost;
// The RendererUpdater is responsible for updating renderers about state change. // The RendererUpdater is responsible for updating renderers about state change.
class RendererUpdater class RendererUpdater
: public KeyedService, : public KeyedService,
public SigninManagerBase::Observer, public identity::IdentityManager::Observer,
public variations::VariationsHttpHeaderProvider::Observer { public variations::VariationsHttpHeaderProvider::Observer {
public: public:
explicit RendererUpdater(Profile* profile); explicit RendererUpdater(Profile* profile);
...@@ -43,9 +44,9 @@ class RendererUpdater ...@@ -43,9 +44,9 @@ class RendererUpdater
chrome::mojom::RendererConfigurationAssociatedPtr GetRendererConfiguration( chrome::mojom::RendererConfigurationAssociatedPtr GetRendererConfiguration(
content::RenderProcessHost* render_process_host); content::RenderProcessHost* render_process_host);
// SigninManagerBase::Observer: // IdentityManager::Observer:
void GoogleSigninSucceeded(const AccountInfo& account_info) override; void OnPrimaryAccountSet(const AccountInfo& account_info) override;
void GoogleSignedOut(const AccountInfo& account_info) override; void OnPrimaryAccountCleared(const AccountInfo& account_info) override;
// VariationsHttpHeaderProvider::Observer: // VariationsHttpHeaderProvider::Observer:
void VariationIdsHeaderUpdated( void VariationIdsHeaderUpdated(
...@@ -61,7 +62,6 @@ class RendererUpdater ...@@ -61,7 +62,6 @@ class RendererUpdater
Profile* profile_; Profile* profile_;
PrefChangeRegistrar pref_change_registrar_; PrefChangeRegistrar pref_change_registrar_;
SigninManagerBase* signin_manager_;
variations::VariationsHttpHeaderProvider* variations_http_header_provider_; variations::VariationsHttpHeaderProvider* variations_http_header_provider_;
// Prefs that we sync to the renderers. // Prefs that we sync to the renderers.
...@@ -72,6 +72,10 @@ class RendererUpdater ...@@ -72,6 +72,10 @@ class RendererUpdater
std::string cached_variation_ids_header_; std::string cached_variation_ids_header_;
std::string cached_variation_ids_header_signed_in_; 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); 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