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 @@
#include "base/memory/singleton.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
......@@ -106,7 +107,8 @@ ArcProvisionNotificationService::GetForBrowserContext(
ArcProvisionNotificationService::ArcProvisionNotificationService(
content::BrowserContext* context,
ArcBridgeService* bridge_service)
: ArcProvisionNotificationService(base::MakeUnique<DelegateImpl>()) {}
: ArcProvisionNotificationService(context,
base::MakeUnique<DelegateImpl>()) {}
ArcProvisionNotificationService::~ArcProvisionNotificationService() {
// Make sure no notification is left being shown.
......@@ -124,14 +126,16 @@ ArcProvisionNotificationService::~ArcProvisionNotificationService() {
// static
std::unique_ptr<ArcProvisionNotificationService>
ArcProvisionNotificationService::CreateForTesting(
content::BrowserContext* context,
std::unique_ptr<Delegate> delegate) {
return base::WrapUnique<ArcProvisionNotificationService>(
new ArcProvisionNotificationService(std::move(delegate)));
new ArcProvisionNotificationService(context, std::move(delegate)));
}
ArcProvisionNotificationService::ArcProvisionNotificationService(
content::BrowserContext* context,
std::unique_ptr<Delegate> delegate)
: delegate_(std::move(delegate)) {
: context_(context), delegate_(std::move(delegate)) {
ArcSessionManager::Get()->AddObserver(this);
}
......@@ -147,7 +151,7 @@ void ArcProvisionNotificationService::OnArcOptInManagementCheckStarted() {
// 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
// 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) &&
AreArcAllOptInPreferencesIgnorableForProfile(profile)) {
delegate_->ShowManagedProvisionNotification();
......
......@@ -49,11 +49,13 @@ class ArcProvisionNotificationService : public KeyedService,
// Constructs an instance with the supplied delegate.
static std::unique_ptr<ArcProvisionNotificationService> CreateForTesting(
content::BrowserContext* context,
std::unique_ptr<Delegate> delegate);
private:
// Constructs with the supplied delegate.
explicit ArcProvisionNotificationService(std::unique_ptr<Delegate> delegate);
ArcProvisionNotificationService(content::BrowserContext* context,
std::unique_ptr<Delegate> delegate);
// ArcSessionManager::Observer:
void OnArcPlayStoreEnabledChanged(bool enabled) override;
......@@ -62,6 +64,7 @@ class ArcProvisionNotificationService : public KeyedService,
void OnArcSessionStopped(ArcStopReason stop_reason) override;
void OnArcErrorShowRequested(ArcSupportHost::Error error) override;
content::BrowserContext* const context_;
std::unique_ptr<Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(ArcProvisionNotificationService);
......
......@@ -78,6 +78,7 @@ class ArcProvisionNotificationServiceTest : public testing::Test {
mock_arc_provision_notification_service_delegate.get();
arc_provision_notification_service_ =
ArcProvisionNotificationService::CreateForTesting(
profile_.get(),
std::move(mock_arc_provision_notification_service_delegate));
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