Commit 79ecbaa9 authored by nancy's avatar nancy Committed by Commit Bot

Add AppServiceProxy class member variable profile_.

This CL is used to add profile_ as the AppServiceProxy class member
variable, as profile_ will be used to create the Uninstall_dialog,
which is created by crrev.com/c/1833024.

BUG=1009248

Change-Id: I7ec432dafbf4a58a01f5f3d3114dacea19e1fb5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837554Reviewed-by: default avatarNigel Tao <nigeltao@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702688}
parent 386a1c5b
...@@ -75,8 +75,9 @@ AppServiceProxy::AppServiceProxy(Profile* profile) ...@@ -75,8 +75,9 @@ AppServiceProxy::AppServiceProxy(Profile* profile)
: inner_icon_loader_(this), : inner_icon_loader_(this),
icon_coalescer_(&inner_icon_loader_), icon_coalescer_(&inner_icon_loader_),
outer_icon_loader_(&icon_coalescer_, outer_icon_loader_(&icon_coalescer_,
apps::IconCache::GarbageCollectionPolicy::kEager) { apps::IconCache::GarbageCollectionPolicy::kEager),
Initialize(profile); profile_(profile) {
Initialize();
} }
AppServiceProxy::~AppServiceProxy() = default; AppServiceProxy::~AppServiceProxy() = default;
...@@ -87,17 +88,18 @@ void AppServiceProxy::ReInitializeForTesting(Profile* profile) { ...@@ -87,17 +88,18 @@ void AppServiceProxy::ReInitializeForTesting(Profile* profile) {
// after full profile initialization to ensure the App Service implementation // after full profile initialization to ensure the App Service implementation
// has all of profile state it needs. // has all of profile state it needs.
app_service_.reset(); app_service_.reset();
Initialize(profile); profile_ = profile;
Initialize();
} }
void AppServiceProxy::Initialize(Profile* profile) { void AppServiceProxy::Initialize() {
if (!profile) { if (!profile_) {
return; return;
} }
// We only initialize the App Service for regular or guest profiles. Non-guest // We only initialize the App Service for regular or guest profiles. Non-guest
// off-the-record profiles do not get an instance. // off-the-record profiles do not get an instance.
if (profile->IsOffTheRecord() && !profile->IsGuestSession()) { if (profile_->IsOffTheRecord() && !profile_->IsGuestSession()) {
return; return;
} }
...@@ -116,18 +118,18 @@ void AppServiceProxy::Initialize(Profile* profile) { ...@@ -116,18 +118,18 @@ void AppServiceProxy::Initialize(Profile* profile) {
// responsibility isn't intrinsically part of the AppServiceProxy, but doing // responsibility isn't intrinsically part of the AppServiceProxy, but doing
// that here, for each such app type, is as good a place as any. // that here, for each such app type, is as good a place as any.
built_in_chrome_os_apps_ = built_in_chrome_os_apps_ =
std::make_unique<BuiltInChromeOsApps>(app_service_, profile); std::make_unique<BuiltInChromeOsApps>(app_service_, profile_);
crostini_apps_ = std::make_unique<CrostiniApps>(app_service_, profile); crostini_apps_ = std::make_unique<CrostiniApps>(app_service_, profile_);
extension_apps_ = std::make_unique<ExtensionApps>( extension_apps_ = std::make_unique<ExtensionApps>(
app_service_, profile, apps::mojom::AppType::kExtension); app_service_, profile_, apps::mojom::AppType::kExtension);
extension_web_apps_ = std::make_unique<ExtensionApps>( extension_web_apps_ = std::make_unique<ExtensionApps>(
app_service_, profile, apps::mojom::AppType::kWeb); app_service_, profile_, apps::mojom::AppType::kWeb);
// Asynchronously add app icon source, so we don't do too much work in the // Asynchronously add app icon source, so we don't do too much work in the
// constructor. // constructor.
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&AppServiceProxy::AddAppIconSource, FROM_HERE, base::BindOnce(&AppServiceProxy::AddAppIconSource,
weak_ptr_factory_.GetWeakPtr(), profile)); weak_ptr_factory_.GetWeakPtr(), profile_));
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
} }
} }
......
...@@ -143,7 +143,7 @@ class AppServiceProxy : public KeyedService, ...@@ -143,7 +143,7 @@ class AppServiceProxy : public KeyedService,
apps::IconLoader* overriding_icon_loader_for_testing_; apps::IconLoader* overriding_icon_loader_for_testing_;
}; };
void Initialize(Profile* profile); void Initialize();
void AddAppIconSource(Profile* profile); void AddAppIconSource(Profile* profile);
...@@ -179,6 +179,8 @@ class AppServiceProxy : public KeyedService, ...@@ -179,6 +179,8 @@ class AppServiceProxy : public KeyedService,
std::unique_ptr<ExtensionApps> extension_web_apps_; std::unique_ptr<ExtensionApps> extension_web_apps_;
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
Profile* profile_;
base::WeakPtrFactory<AppServiceProxy> weak_ptr_factory_{this}; base::WeakPtrFactory<AppServiceProxy> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AppServiceProxy); DISALLOW_COPY_AND_ASSIGN(AppServiceProxy);
......
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