Commit e32d705e authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Prevent file-manager's gallery, video, audio apps from being pinned to the shelf.

These file manager apps have a shelf presence, but can only be launched
when provided a filename to open. Pinning them creates an item that does
nothing.

Bug: 955396
Test: ChromeLauncherControllerTest.UnpinnableComponentApps
Change-Id: Id157a74606c774c10afef97afe02cbca73026764
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661315
Auto-Submit: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670310}
parent cd365c96
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/crostini/crostini_test_helper.h" #include "chrome/browser/chromeos/crostini/crostini_test_helper.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h" #include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_mode_test_helper.h" #include "chrome/browser/chromeos/login/demo_mode/demo_mode_test_helper.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
...@@ -4509,3 +4510,16 @@ TEST_F(ChromeLauncherControllerTest, CrostiniBrowserWindowsRecogniseShelfItem) { ...@@ -4509,3 +4510,16 @@ TEST_F(ChromeLauncherControllerTest, CrostiniBrowserWindowsRecogniseShelfItem) {
.app_id, .app_id,
item.id.app_id); item.id.app_id);
} }
// Tests behavior for ensuring some component apps can be marked unpinnable.
TEST_F(ChromeLauncherControllerTest, UnpinnableComponentApps) {
InitLauncherController();
const char* kPinnableApp = file_manager::kFileManagerAppId;
const char* kUnpinnableApp = file_manager::kGalleryAppId;
EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE,
GetPinnableForAppID(kPinnableApp, profile()));
EXPECT_EQ(AppListControllerDelegate::NO_PIN,
GetPinnableForAppID(kUnpinnableApp, profile()));
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h" #include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
...@@ -27,6 +29,17 @@ const extensions::Extension* GetExtensionForAppID(const std::string& app_id, ...@@ -27,6 +29,17 @@ const extensions::Extension* GetExtensionForAppID(const std::string& app_id,
AppListControllerDelegate::Pinnable GetPinnableForAppID( AppListControllerDelegate::Pinnable GetPinnableForAppID(
const std::string& app_id, const std::string& app_id,
Profile* profile) { Profile* profile) {
// These file manager apps have a shelf presence, but can only be launched
// when provided a filename to open. Pinning them creates an item that does
// nothing.
const char* kUnpinnableAppIds[] = {
file_manager::kVideoPlayerAppId,
file_manager::kGalleryAppId,
file_manager::kAudioPlayerAppId,
};
if (base::Contains(kUnpinnableAppIds, app_id))
return AppListControllerDelegate::NO_PIN;
const base::ListValue* pref = const base::ListValue* pref =
profile->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps); profile->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps);
if (!pref) if (!pref)
......
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