Commit f79474b9 authored by Jeevan Shikaram's avatar Jeevan Shikaram Committed by Commit Bot

[App Management] Hide App Info for web apps that don't display in the launcher.

This CL hides the App Info context menu item for web apps that are not
displayed in launcher. This is because App Management does not have a
corresponding app entry for apps that are not displayed in the launcher.

Bug: 1001985, 1028073, 1022756
Change-Id: I34dc2743e63402685da9b9cf053c2c79ab35438f
Fixed: 1001985, 1028073
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935628
Commit-Queue: Jeevan Shikaram <jshikaram@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721349}
parent f9ed2f3d
......@@ -324,7 +324,7 @@ std::unique_ptr<developer::ProfileInfo> DeveloperPrivateAPI::CreateProfileInfo(
info->in_developer_mode =
!info->is_supervised &&
prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode);
info->app_info_dialog_enabled = CanShowAppInfoDialog();
info->app_info_dialog_enabled = CanPlatformShowAppInfoDialog();
info->can_load_unpacked =
ExtensionManagementFactory::GetForBrowserContext(profile)
->HasWhitelistedExtension();
......
......@@ -40,7 +40,7 @@ void ShowPermissionsDialogHelper::Show(content::BrowserContext* browser_context,
// Show the new-style extensions dialog when it is available. It is currently
// unavailable by default on Mac.
if (CanShowAppInfoDialog()) {
if (CanPlatformShowAppInfoDialog()) {
if (from_webui) {
UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches",
AppInfoLaunchSource::FROM_EXTENSIONS_PAGE,
......
......@@ -88,7 +88,7 @@ bool AppListControllerDelegate::UninstallAllowed(Profile* profile,
}
bool AppListControllerDelegate::CanDoShowAppInfoFlow() {
return CanShowAppInfoDialog();
return CanPlatformShowAppInfoDialog();
}
void AppListControllerDelegate::DoShowAppInfoFlow(
......
......@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_APPS_APP_INFO_DIALOG_H_
#define CHROME_BROWSER_UI_APPS_APP_INFO_DIALOG_H_
#include <string>
#include "base/callback_forward.h"
#if defined(OS_CHROMEOS)
......@@ -36,7 +38,10 @@ enum AppInfoLaunchSource {
// TODO(tsergeant): Move these methods into a class
// Returns true if the app info dialog is available on the current platform.
bool CanShowAppInfoDialog();
bool CanPlatformShowAppInfoDialog();
// Returns true if the app info dialog is available for an app.
bool CanShowAppInfoDialog(Profile* profile, const std::string& extension_id);
#if defined(OS_CHROMEOS)
// Shows the chrome app information as a frameless window for the given |app|
......
......@@ -869,14 +869,16 @@ AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
return nullptr;
}
bool ChromeLauncherController::CanDoShowAppInfoFlow() {
return CanShowAppInfoDialog();
bool ChromeLauncherController::CanDoShowAppInfoFlow(
Profile* profile,
const std::string& extension_id) {
return CanShowAppInfoDialog(profile, extension_id);
}
void ChromeLauncherController::DoShowAppInfoFlow(
Profile* profile,
const std::string& extension_id) {
DCHECK(CanDoShowAppInfoFlow());
DCHECK(CanPlatformShowAppInfoDialog());
const extensions::Extension* extension = GetExtension(profile, extension_id);
if (!extension)
......
......@@ -271,8 +271,9 @@ class ChromeLauncherController
// to get index of item with id |app_id| or -1 if it's not pinned.
int PinnedItemIndexByAppID(const std::string& app_id);
// Whether the controller supports a Show App Info flow.
bool CanDoShowAppInfoFlow();
// Whether the controller supports a Show App Info flow for a specific
// extension.
bool CanDoShowAppInfoFlow(Profile* profile, const std::string& extension_id);
// Show the dialog with the application's information. Call only if
// CanDoShowAppInfoFlow() returns true.
......
......@@ -109,7 +109,7 @@ void ExtensionShelfContextMenu::GetMenuModel(GetMenuModelCallback callback) {
: IDS_APP_LIST_EXTENSIONS_UNINSTALL);
}
if (controller()->CanDoShowAppInfoFlow() && !is_system_web_app) {
if (controller()->CanDoShowAppInfoFlow(profile, app_id)) {
AddContextMenuOption(menu_model.get(), ash::SHOW_APP_INFO,
IDS_APP_CONTEXT_MENU_SHOW_INFO);
}
......
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
......@@ -22,7 +23,10 @@
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.h"
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/web_contents.h"
......@@ -56,7 +60,7 @@ constexpr gfx::Size kDialogSize = gfx::Size(380, 490);
} // namespace
bool CanShowAppInfoDialog() {
bool CanPlatformShowAppInfoDialog() {
#if defined(OS_MACOSX)
return false;
#else
......@@ -64,6 +68,33 @@ bool CanShowAppInfoDialog() {
#endif
}
bool CanShowAppInfoDialog(Profile* profile, const std::string& extension_id) {
#if defined(OS_CHROMEOS)
bool is_system_web_app = web_app::WebAppProvider::Get(profile)
->system_web_app_manager()
.IsSystemWebApp(extension_id);
if (is_system_web_app) {
return false;
}
const extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(profile);
const extensions::Extension* extension =
registry->GetInstalledExtension(extension_id);
if (!extension) {
return false;
}
// App Management only displays apps that are displayed in the launcher.
if (base::FeatureList::IsEnabled(features::kAppManagement) &&
!extension->ShouldDisplayInAppLauncher()) {
return false;
}
#endif
return CanPlatformShowAppInfoDialog();
}
#if defined(OS_CHROMEOS)
void ShowAppInfoInAppList(gfx::NativeWindow parent,
const gfx::Rect& app_info_bounds,
......
......@@ -499,7 +499,7 @@ void NTPResourceCache::CreateNewTabHTML() {
!prefs->GetBoolean(prefs::kHideWebStoreIcon));
load_time_data.SetBoolean("canShowAppInfoDialog",
CanShowAppInfoDialog());
CanPlatformShowAppInfoDialog());
AppLauncherHandler::GetLocalizedValues(profile_, &load_time_data);
......
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