Commit 74610c85 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Have App Service serve non-ready extensions

Currently, the App Service's extension-backed app publisher only serves
enabled (i.e. ready) extensions. Also serving disabled and terminated
extensions matches AppListControllerDelegate::GetApps in
app_list_controller_delegate.cc and ExtensionDataSource::AddApps in
app_search_provider.cc.

For example, disabled apps might still be shown in the UI, but with a
grayed out icon.

BUG=826982

Change-Id: I896d33cf574d4016a73b372003445329ae895e8e
Reviewed-on: https://chromium-review.googlesource.com/c/1367071
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615821}
parent 8e3a1035
...@@ -78,15 +78,16 @@ void ExtensionApps::Connect(apps::mojom::SubscriberPtr subscriber, ...@@ -78,15 +78,16 @@ void ExtensionApps::Connect(apps::mojom::SubscriberPtr subscriber,
apps::mojom::ConnectOptionsPtr opts) { apps::mojom::ConnectOptionsPtr opts) {
std::vector<apps::mojom::AppPtr> apps; std::vector<apps::mojom::AppPtr> apps;
if (profile_) { if (profile_) {
// TODO(crbug.com/826982): consider disabled and terminated extensions, not extensions::ExtensionRegistry* registry =
// just enabled ones, as per AppListControllerDelegate::GetApps in extensions::ExtensionRegistry::Get(profile_);
// https://cs.chromium.org/chromium/src/chrome/browser/ui/app_list/app_list_controller_delegate.cc?g=0&l=193 ConvertVector(registry->enabled_extensions(),
for (const auto& extension : apps::mojom::Readiness::kReady, &apps);
extensions::ExtensionRegistry::Get(profile_)->enabled_extensions()) { ConvertVector(registry->disabled_extensions(),
if (extension->is_app()) { apps::mojom::Readiness::kDisabledByUser, &apps);
apps.push_back(Convert(extension.get())); ConvertVector(registry->terminated_extensions(),
} apps::mojom::Readiness::kTerminated, &apps);
} // blacklisted_extensions and blocked_extensions, corresponding to
// kDisabledByBlacklist and kDisabledByPolicy, are deliberately ignored.
} }
subscriber->OnApps(std::move(apps)); subscriber->OnApps(std::move(apps));
subscribers_.AddPtr(std::move(subscriber)); subscribers_.AddPtr(std::move(subscriber));
...@@ -144,12 +145,13 @@ void ExtensionApps::Launch(const std::string& app_id, ...@@ -144,12 +145,13 @@ void ExtensionApps::Launch(const std::string& app_id,
} }
apps::mojom::AppPtr ExtensionApps::Convert( apps::mojom::AppPtr ExtensionApps::Convert(
const extensions::Extension* extension) { const extensions::Extension* extension,
apps::mojom::Readiness readiness) {
apps::mojom::AppPtr app = apps::mojom::App::New(); apps::mojom::AppPtr app = apps::mojom::App::New();
app->app_type = apps::mojom::AppType::kExtension; app->app_type = apps::mojom::AppType::kExtension;
app->app_id = extension->id(); app->app_id = extension->id();
app->readiness = apps::mojom::Readiness::kReady; app->readiness = readiness;
app->name = extension->name(); app->name = extension->name();
app->icon_key = apps::mojom::IconKey::New(); app->icon_key = apps::mojom::IconKey::New();
...@@ -166,6 +168,16 @@ apps::mojom::AppPtr ExtensionApps::Convert( ...@@ -166,6 +168,16 @@ apps::mojom::AppPtr ExtensionApps::Convert(
return app; return app;
} }
void ExtensionApps::ConvertVector(const extensions::ExtensionSet& extensions,
apps::mojom::Readiness readiness,
std::vector<apps::mojom::AppPtr>* apps_out) {
for (const auto& extension : extensions) {
if (extension->is_app()) {
apps_out->push_back(Convert(extension.get(), readiness));
}
}
}
bool ExtensionApps::RunExtensionEnableFlow(const std::string& app_id) { bool ExtensionApps::RunExtensionEnableFlow(const std::string& app_id) {
if (extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) { if (extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) {
return false; return false;
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
class Profile; class Profile;
namespace extensions {
class ExtensionSet;
}
namespace apps { namespace apps {
// An app publisher (in the App Service sense) of extension-backed apps, // An app publisher (in the App Service sense) of extension-backed apps,
...@@ -54,7 +58,11 @@ class ExtensionApps : public apps::mojom::Publisher, ...@@ -54,7 +58,11 @@ class ExtensionApps : public apps::mojom::Publisher,
// running. // running.
bool RunExtensionEnableFlow(const std::string& app_id); bool RunExtensionEnableFlow(const std::string& app_id);
apps::mojom::AppPtr Convert(const extensions::Extension* extension); apps::mojom::AppPtr Convert(const extensions::Extension* extension,
apps::mojom::Readiness readiness);
void ConvertVector(const extensions::ExtensionSet& extensions,
apps::mojom::Readiness readiness,
std::vector<apps::mojom::AppPtr>* apps_out);
mojo::Binding<apps::mojom::Publisher> binding_; mojo::Binding<apps::mojom::Publisher> binding_;
Profile* profile_; Profile* profile_;
......
...@@ -43,6 +43,7 @@ enum Readiness { ...@@ -43,6 +43,7 @@ enum Readiness {
kDisabledByBlacklist, // Disabled by SafeBrowsing. kDisabledByBlacklist, // Disabled by SafeBrowsing.
kDisabledByPolicy, // Disabled by admin policy. kDisabledByPolicy, // Disabled by admin policy.
kDisabledByUser, // Disabled by explicit user action. kDisabledByUser, // Disabled by explicit user action.
kTerminated, // Renderer process crashed.
kUninstalledByUser, kUninstalledByUser,
}; };
......
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