Commit d6cd4223 authored by nancy's avatar nancy Committed by Commit Bot

Add the close menu item to web apps shelf context menus.

BUG=1038487

Change-Id: If6e135795924159775428b4f10a95101dc506f3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093074Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748075}
parent cde06465
......@@ -138,7 +138,8 @@ void AppServiceProxy::Initialize() {
app_service_, profile_, apps::mojom::AppType::kExtension,
&instance_registry_);
if (base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions)) {
web_apps_ = std::make_unique<WebApps>(app_service_, profile_);
web_apps_ = std::make_unique<WebApps>(app_service_, profile_,
&instance_registry_);
} else {
extension_web_apps_ = std::make_unique<ExtensionApps>(
app_service_, profile_, apps::mojom::AppType::kWeb,
......
......@@ -106,9 +106,12 @@ apps::mojom::InstallSource GetHighestPriorityInstallSource(
namespace apps {
WebApps::WebApps(const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile)
Profile* profile,
apps::InstanceRegistry* instance_registry)
: profile_(profile),
instance_registry_(instance_registry),
app_service_(nullptr) {
DCHECK(instance_registry_);
Initialize(app_service);
}
......@@ -379,6 +382,11 @@ void WebApps::GetMenuModel(const std::string& app_id,
&menu_items);
}
if (menu_type == apps::mojom::MenuType::kShelf &&
!instance_registry_->GetWindows(app_id).empty()) {
AddCommandItem(ash::MENU_CLOSE, IDS_SHELF_CONTEXT_MENU_CLOSE, &menu_items);
}
if (provider_->install_finalizer().CanUserUninstallExternalApp(app_id)) {
AddCommandItem(ash::UNINSTALL, IDS_APP_LIST_UNINSTALL_ITEM, &menu_items);
}
......
......@@ -17,6 +17,7 @@
#include "chrome/browser/web_applications/components/app_registrar_observer.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/services/app_service/public/cpp/instance_registry.h"
#include "chrome/services/app_service/public/mojom/app_service.mojom.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
......@@ -42,7 +43,8 @@ class WebApps : public apps::mojom::Publisher,
public ArcAppListPrefs::Observer {
public:
WebApps(const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile);
Profile* profile,
apps::InstanceRegistry* instance_registry);
WebApps(const WebApps&) = delete;
WebApps& operator=(const WebApps&) = delete;
~WebApps() override;
......@@ -154,6 +156,8 @@ class WebApps : public apps::mojom::Publisher,
apps_util::IncrementingIconKeyFactory icon_key_factory_;
apps::InstanceRegistry* instance_registry_;
PausedApps paused_apps_;
web_app::WebAppProvider* provider_ = nullptr;
......
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