Commit bd4e1a2e authored by Hidehiko Abe's avatar Hidehiko Abe Committed by Commit Bot

Use passed BrowserContext as Profile.

ArcProvisionNotificationService internally accessed to
ArcSessionManager::profile().
Instead, it will use the given BrowserContext.

BUG=672829
TEST=Ran trybot.

Change-Id: Ic1f60318d4727863a41654cd5aa73b3bd319725d
Reviewed-on: https://chromium-review.googlesource.com/579890Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488329}
parent 736822c1
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h" #include "chrome/grit/theme_resources.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "components/arc/arc_browser_context_keyed_service_factory_base.h"
...@@ -106,7 +107,8 @@ ArcProvisionNotificationService::GetForBrowserContext( ...@@ -106,7 +107,8 @@ ArcProvisionNotificationService::GetForBrowserContext(
ArcProvisionNotificationService::ArcProvisionNotificationService( ArcProvisionNotificationService::ArcProvisionNotificationService(
content::BrowserContext* context, content::BrowserContext* context,
ArcBridgeService* bridge_service) ArcBridgeService* bridge_service)
: ArcProvisionNotificationService(base::MakeUnique<DelegateImpl>()) {} : ArcProvisionNotificationService(context,
base::MakeUnique<DelegateImpl>()) {}
ArcProvisionNotificationService::~ArcProvisionNotificationService() { ArcProvisionNotificationService::~ArcProvisionNotificationService() {
// Make sure no notification is left being shown. // Make sure no notification is left being shown.
...@@ -124,14 +126,16 @@ ArcProvisionNotificationService::~ArcProvisionNotificationService() { ...@@ -124,14 +126,16 @@ ArcProvisionNotificationService::~ArcProvisionNotificationService() {
// static // static
std::unique_ptr<ArcProvisionNotificationService> std::unique_ptr<ArcProvisionNotificationService>
ArcProvisionNotificationService::CreateForTesting( ArcProvisionNotificationService::CreateForTesting(
content::BrowserContext* context,
std::unique_ptr<Delegate> delegate) { std::unique_ptr<Delegate> delegate) {
return base::WrapUnique<ArcProvisionNotificationService>( return base::WrapUnique<ArcProvisionNotificationService>(
new ArcProvisionNotificationService(std::move(delegate))); new ArcProvisionNotificationService(context, std::move(delegate)));
} }
ArcProvisionNotificationService::ArcProvisionNotificationService( ArcProvisionNotificationService::ArcProvisionNotificationService(
content::BrowserContext* context,
std::unique_ptr<Delegate> delegate) std::unique_ptr<Delegate> delegate)
: delegate_(std::move(delegate)) { : context_(context), delegate_(std::move(delegate)) {
ArcSessionManager::Get()->AddObserver(this); ArcSessionManager::Get()->AddObserver(this);
} }
...@@ -147,7 +151,7 @@ void ArcProvisionNotificationService::OnArcOptInManagementCheckStarted() { ...@@ -147,7 +151,7 @@ void ArcProvisionNotificationService::OnArcOptInManagementCheckStarted() {
// This observer is notified at an early phase of the opt-in flow, so start // This observer is notified at an early phase of the opt-in flow, so start
// showing the notification if the opt-in flow happens silently (due to the // showing the notification if the opt-in flow happens silently (due to the
// managed prefs), or ensure that no notification is shown otherwise. // managed prefs), or ensure that no notification is shown otherwise.
const Profile* const profile = ArcSessionManager::Get()->profile(); const Profile* const profile = Profile::FromBrowserContext(context_);
if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile) && if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile) &&
AreArcAllOptInPreferencesIgnorableForProfile(profile)) { AreArcAllOptInPreferencesIgnorableForProfile(profile)) {
delegate_->ShowManagedProvisionNotification(); delegate_->ShowManagedProvisionNotification();
......
...@@ -49,11 +49,13 @@ class ArcProvisionNotificationService : public KeyedService, ...@@ -49,11 +49,13 @@ class ArcProvisionNotificationService : public KeyedService,
// Constructs an instance with the supplied delegate. // Constructs an instance with the supplied delegate.
static std::unique_ptr<ArcProvisionNotificationService> CreateForTesting( static std::unique_ptr<ArcProvisionNotificationService> CreateForTesting(
content::BrowserContext* context,
std::unique_ptr<Delegate> delegate); std::unique_ptr<Delegate> delegate);
private: private:
// Constructs with the supplied delegate. // Constructs with the supplied delegate.
explicit ArcProvisionNotificationService(std::unique_ptr<Delegate> delegate); ArcProvisionNotificationService(content::BrowserContext* context,
std::unique_ptr<Delegate> delegate);
// ArcSessionManager::Observer: // ArcSessionManager::Observer:
void OnArcPlayStoreEnabledChanged(bool enabled) override; void OnArcPlayStoreEnabledChanged(bool enabled) override;
...@@ -62,6 +64,7 @@ class ArcProvisionNotificationService : public KeyedService, ...@@ -62,6 +64,7 @@ class ArcProvisionNotificationService : public KeyedService,
void OnArcSessionStopped(ArcStopReason stop_reason) override; void OnArcSessionStopped(ArcStopReason stop_reason) override;
void OnArcErrorShowRequested(ArcSupportHost::Error error) override; void OnArcErrorShowRequested(ArcSupportHost::Error error) override;
content::BrowserContext* const context_;
std::unique_ptr<Delegate> delegate_; std::unique_ptr<Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(ArcProvisionNotificationService); DISALLOW_COPY_AND_ASSIGN(ArcProvisionNotificationService);
......
...@@ -78,6 +78,7 @@ class ArcProvisionNotificationServiceTest : public testing::Test { ...@@ -78,6 +78,7 @@ class ArcProvisionNotificationServiceTest : public testing::Test {
mock_arc_provision_notification_service_delegate.get(); mock_arc_provision_notification_service_delegate.get();
arc_provision_notification_service_ = arc_provision_notification_service_ =
ArcProvisionNotificationService::CreateForTesting( ArcProvisionNotificationService::CreateForTesting(
profile_.get(),
std::move(mock_arc_provision_notification_service_delegate)); std::move(mock_arc_provision_notification_service_delegate));
const AccountId account_id(AccountId::FromUserEmailGaiaId( const AccountId account_id(AccountId::FromUserEmailGaiaId(
......
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