Remove lock screen app action support
This is a split from crrev.com/c/5986568. This also adds a feature flag to disable ActionData API. I'll disable it in a separate CL. Bug: 376354347 Change-Id: I3684fa9dc26c317248eeacc63f9edc2af7c51485 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6022058 Reviewed-by: Toni Barzic <tbarzic@google.com> Commit-Queue: Mitsuru Oshima <oshima@chromium.org> Reviewed-by: Finnur Thorarinsson <finnur@chromium.org> Cr-Commit-Position: refs/heads/main@{#1383878}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
8ba60787b1
commit
94b526295f
apps
chrome/browser/chromeos/extensions/action_handlers
extensions/common
@ -52,10 +52,12 @@
|
||||
#include "net/base/filename_util.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
#include "base/feature_list.h"
|
||||
#include "components/app_restore/app_launch_info.h"
|
||||
#include "components/app_restore/full_restore_utils.h"
|
||||
#include "components/user_manager/user_manager.h"
|
||||
#include "extensions/common/extension_features.h"
|
||||
#endif
|
||||
|
||||
namespace app_runtime = extensions::api::app_runtime;
|
||||
@ -129,7 +131,12 @@ class PlatformAppPathLauncher
|
||||
PlatformAppPathLauncher& operator=(const PlatformAppPathLauncher&) = delete;
|
||||
|
||||
void set_action_data(std::optional<app_runtime::ActionData> action_data) {
|
||||
action_data_ = std::move(action_data);
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
if (base::FeatureList::IsEnabled(
|
||||
extensions_features::kApiRuntimeActionData)) {
|
||||
action_data_ = std::move(action_data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_launch_source(extensions::AppLaunchSource launch_source) {
|
||||
|
@ -3,11 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "apps/launcher.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/path_service.h"
|
||||
#include "chrome/browser/extensions/extension_apitest.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "content/public/test/browser_test.h"
|
||||
#include "extensions/common/extension_features.h"
|
||||
#include "extensions/common/manifest_handlers/action_handlers_handler.h"
|
||||
#include "extensions/test/extension_test_message_listener.h"
|
||||
|
||||
@ -16,6 +18,10 @@ namespace app_runtime = extensions::api::app_runtime;
|
||||
using ActionHandlersBrowserTest = extensions::ExtensionApiTest;
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(ActionHandlersBrowserTest, LaunchAppWithNewNote) {
|
||||
if (!base::FeatureList::IsEnabled(
|
||||
extensions_features::kApiRuntimeActionData)) {
|
||||
return;
|
||||
}
|
||||
// Load the app. Make sure to wait until it is done loading.
|
||||
ExtensionTestMessageListener loader("loaded");
|
||||
base::FilePath path =
|
||||
|
@ -288,16 +288,6 @@ namespace app.window {
|
||||
// If true, and supported by the platform, the window will be visible on all
|
||||
// workspaces.
|
||||
boolean? visibleOnAllWorkspaces;
|
||||
|
||||
// <p>If set, the action that is intended to be handled by the window on
|
||||
// lockscreen. This has to be set to create an app window visible on the
|
||||
// lock screen. The app window should be created only in response to an
|
||||
// app launch request for handling an action from the lock screen. App
|
||||
// window creation will fail if the app was not launched to handle the
|
||||
// action.
|
||||
// </p>
|
||||
// <p>This is <b>Chrome OS only</b>.</p>
|
||||
[nodoc] app.runtime.ActionType? lockScreenAction;
|
||||
};
|
||||
|
||||
// Called in the creating window (parent) before the load event is called in
|
||||
|
@ -23,6 +23,10 @@ BASE_FEATURE(kApiEnterpriseKioskInput,
|
||||
"ApiEnterpriseKioskInput",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
||||
BASE_FEATURE(kApiRuntimeActionData,
|
||||
"ApiRuntimeActionData",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
||||
BASE_FEATURE(kApiPermissionsSiteAccessRequests,
|
||||
"ApiPermissionsSiteAccessRequests",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
@ -45,6 +45,10 @@ BASE_DECLARE_FEATURE(kApiContentSettingsClipboard);
|
||||
// Controls the availability of the enterprise.kioskInput API.
|
||||
BASE_DECLARE_FEATURE(kApiEnterpriseKioskInput);
|
||||
|
||||
// Controls the availability of the runtime.actionData API.
|
||||
// TODO(crbug.com/376354347): Remove this when the experiment is finished.
|
||||
BASE_DECLARE_FEATURE(kApiRuntimeActionData);
|
||||
|
||||
// Controls the availability of adding and removing site access requests with
|
||||
// the permissions API.
|
||||
BASE_DECLARE_FEATURE(kApiPermissionsSiteAccessRequests);
|
||||
|
@ -183,8 +183,6 @@ inline constexpr char kFileSystemProviderCapabilities[] =
|
||||
"file_system_provider_capabilities";
|
||||
inline constexpr char kActionHandlers[] = "action_handlers";
|
||||
inline constexpr char kActionHandlerActionKey[] = "action";
|
||||
inline constexpr char kActionHandlerEnabledOnLockScreenKey[] =
|
||||
"enabled_on_lock_screen";
|
||||
#endif
|
||||
|
||||
} // namespace manifest_keys
|
||||
|
@ -26,14 +26,6 @@ bool ActionHandlersInfo::HasActionHandler(
|
||||
return info && info->action_handlers.count(action_type) > 0;
|
||||
}
|
||||
|
||||
bool ActionHandlersInfo::HasLockScreenActionHandler(
|
||||
const Extension* extension,
|
||||
api::app_runtime::ActionType action_type) {
|
||||
ActionHandlersInfo* info = static_cast<ActionHandlersInfo*>(
|
||||
extension->GetManifestData(keys::kActionHandlers));
|
||||
return info && info->lock_screen_action_handlers.count(action_type) > 0;
|
||||
}
|
||||
|
||||
ActionHandlersInfo::ActionHandlersInfo() = default;
|
||||
|
||||
ActionHandlersInfo::~ActionHandlersInfo() = default;
|
||||
@ -52,7 +44,6 @@ bool ActionHandlersHandler::Parse(Extension* extension, std::u16string* error) {
|
||||
auto info = std::make_unique<ActionHandlersInfo>();
|
||||
for (const base::Value& wrapped_value : entries->GetList()) {
|
||||
std::string value;
|
||||
bool enabled_on_lock_screen = false;
|
||||
if (wrapped_value.is_dict()) {
|
||||
const base::Value::Dict& wrapped_dict = wrapped_value.GetDict();
|
||||
const std::string* action =
|
||||
@ -62,11 +53,6 @@ bool ActionHandlersHandler::Parse(Extension* extension, std::u16string* error) {
|
||||
return false;
|
||||
}
|
||||
value = *action;
|
||||
std::optional<bool> enabled =
|
||||
wrapped_dict.FindBool(keys::kActionHandlerEnabledOnLockScreenKey);
|
||||
if (enabled) {
|
||||
enabled_on_lock_screen = *enabled;
|
||||
}
|
||||
} else if (wrapped_value.is_string()) {
|
||||
value = wrapped_value.GetString();
|
||||
} else {
|
||||
@ -87,8 +73,6 @@ bool ActionHandlersHandler::Parse(Extension* extension, std::u16string* error) {
|
||||
return false;
|
||||
}
|
||||
info->action_handlers.insert(action_type);
|
||||
if (enabled_on_lock_screen)
|
||||
info->lock_screen_action_handlers.insert(action_type);
|
||||
}
|
||||
|
||||
extension->SetManifestData(keys::kActionHandlers, std::move(info));
|
||||
|
@ -20,15 +20,11 @@ struct ActionHandlersInfo : public Extension::ManifestData {
|
||||
// |action_type|.
|
||||
static bool HasActionHandler(const Extension* extension,
|
||||
api::app_runtime::ActionType action_type);
|
||||
static bool HasLockScreenActionHandler(
|
||||
const Extension* extension,
|
||||
api::app_runtime::ActionType action_type);
|
||||
|
||||
ActionHandlersInfo();
|
||||
~ActionHandlersInfo() override;
|
||||
|
||||
std::set<api::app_runtime::ActionType> action_handlers;
|
||||
std::set<api::app_runtime::ActionType> lock_screen_action_handlers;
|
||||
};
|
||||
|
||||
// Parses the "action_handlers" manifest key.
|
||||
|
@ -43,15 +43,6 @@ class ActionHandlersManifestTest : public ManifestTest {
|
||||
extension->GetManifestData(manifest_keys::kActionHandlers));
|
||||
return info ? info->action_handlers : std::set<app_runtime::ActionType>();
|
||||
}
|
||||
|
||||
// Returns all action handlers associated with |extension|.
|
||||
std::set<app_runtime::ActionType> GetLockScreenActionHandlers(
|
||||
const Extension* extension) {
|
||||
ActionHandlersInfo* info = static_cast<ActionHandlersInfo*>(
|
||||
extension->GetManifestData(manifest_keys::kActionHandlers));
|
||||
return info ? info->lock_screen_action_handlers
|
||||
: std::set<app_runtime::ActionType>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -67,8 +58,6 @@ TEST_F(ActionHandlersManifestTest, InvalidType) {
|
||||
manifest_errors::kInvalidActionHandlersActionType);
|
||||
LoadAndExpectError(CreateManifest("[{}]"),
|
||||
manifest_errors::kInvalidActionHandlerDictionary);
|
||||
LoadAndExpectError(CreateManifest(R"([{"enabled_on_lock_screen": false}])"),
|
||||
manifest_errors::kInvalidActionHandlerDictionary);
|
||||
LoadAndExpectError(CreateManifest(R"([{"action": "invalid_handler"}])"),
|
||||
manifest_errors::kInvalidActionHandlersActionType);
|
||||
}
|
||||
@ -79,60 +68,27 @@ TEST_F(ActionHandlersManifestTest, VerifyParse) {
|
||||
|
||||
EXPECT_FALSE(ActionHandlersInfo::HasActionHandler(
|
||||
none.get(), app_runtime::ActionType::kNewNote));
|
||||
EXPECT_FALSE(ActionHandlersInfo::HasLockScreenActionHandler(
|
||||
none.get(), app_runtime::ActionType::kNewNote));
|
||||
|
||||
scoped_refptr<Extension> new_note =
|
||||
LoadAndExpectSuccess(CreateManifest("[\"new_note\"]"));
|
||||
EXPECT_EQ(
|
||||
std::set<app_runtime::ActionType>{app_runtime::ActionType::kNewNote},
|
||||
GetActionHandlers(new_note.get()));
|
||||
EXPECT_TRUE(GetLockScreenActionHandlers(new_note.get()).empty());
|
||||
EXPECT_TRUE(ActionHandlersInfo::HasActionHandler(
|
||||
new_note.get(), app_runtime::ActionType::kNewNote));
|
||||
EXPECT_FALSE(ActionHandlersInfo::HasLockScreenActionHandler(
|
||||
new_note.get(), app_runtime::ActionType::kNewNote));
|
||||
}
|
||||
|
||||
TEST_F(ActionHandlersManifestTest, ParseDictionaryActionValues) {
|
||||
scoped_refptr<Extension> no_enabled_on_lock_screen_key =
|
||||
scoped_refptr<Extension> new_note_key =
|
||||
LoadAndExpectSuccess(CreateManifest(R"([{"action": "new_note"}])"));
|
||||
EXPECT_EQ(
|
||||
std::set<app_runtime::ActionType>{app_runtime::ActionType::kNewNote},
|
||||
GetActionHandlers(no_enabled_on_lock_screen_key.get()));
|
||||
EXPECT_TRUE(
|
||||
GetLockScreenActionHandlers(no_enabled_on_lock_screen_key.get()).empty());
|
||||
GetActionHandlers(new_note_key.get()));
|
||||
EXPECT_TRUE(ActionHandlersInfo::HasActionHandler(
|
||||
no_enabled_on_lock_screen_key.get(), app_runtime::ActionType::kNewNote));
|
||||
EXPECT_FALSE(ActionHandlersInfo::HasLockScreenActionHandler(
|
||||
no_enabled_on_lock_screen_key.get(), app_runtime::ActionType::kNewNote));
|
||||
|
||||
scoped_refptr<Extension> enabled_on_lock_screen_false =
|
||||
LoadAndExpectSuccess(CreateManifest(
|
||||
R"([{"action": "new_note", "enabled_on_lock_screen": false}])"));
|
||||
EXPECT_EQ(
|
||||
std::set<app_runtime::ActionType>{app_runtime::ActionType::kNewNote},
|
||||
GetActionHandlers(enabled_on_lock_screen_false.get()));
|
||||
EXPECT_TRUE(
|
||||
GetLockScreenActionHandlers(enabled_on_lock_screen_false.get()).empty());
|
||||
EXPECT_TRUE(ActionHandlersInfo::HasActionHandler(
|
||||
enabled_on_lock_screen_false.get(), app_runtime::ActionType::kNewNote));
|
||||
EXPECT_FALSE(ActionHandlersInfo::HasLockScreenActionHandler(
|
||||
enabled_on_lock_screen_false.get(), app_runtime::ActionType::kNewNote));
|
||||
|
||||
scoped_refptr<Extension> enabled_on_lock_screen_true =
|
||||
LoadAndExpectSuccess(CreateManifest(
|
||||
R"([{"action": "new_note", "enabled_on_lock_screen": true}])"));
|
||||
EXPECT_EQ(
|
||||
std::set<app_runtime::ActionType>{app_runtime::ActionType::kNewNote},
|
||||
GetActionHandlers(enabled_on_lock_screen_true.get()));
|
||||
EXPECT_EQ(
|
||||
std::set<app_runtime::ActionType>{app_runtime::ActionType::kNewNote},
|
||||
GetLockScreenActionHandlers(enabled_on_lock_screen_true.get()));
|
||||
EXPECT_TRUE(ActionHandlersInfo::HasActionHandler(
|
||||
enabled_on_lock_screen_true.get(), app_runtime::ActionType::kNewNote));
|
||||
EXPECT_TRUE(ActionHandlersInfo::HasLockScreenActionHandler(
|
||||
enabled_on_lock_screen_true.get(), app_runtime::ActionType::kNewNote));
|
||||
new_note_key.get(), app_runtime::ActionType::kNewNote));
|
||||
scoped_refptr<Extension> no_new_note_key =
|
||||
LoadAndExpectSuccess(CreateManifest(R"([])"));
|
||||
EXPECT_TRUE(GetActionHandlers(no_new_note_key.get()).empty());
|
||||
}
|
||||
|
||||
TEST_F(ActionHandlersManifestTest, DuplicateHandlers) {
|
||||
@ -141,13 +97,6 @@ TEST_F(ActionHandlersManifestTest, DuplicateHandlers) {
|
||||
LoadAndExpectError(CreateManifest(
|
||||
R"(["new_note", {
|
||||
"action": "new_note",
|
||||
"enabled_on_lock_screen": true
|
||||
}])"),
|
||||
manifest_errors::kDuplicateActionHandlerFound);
|
||||
LoadAndExpectError(CreateManifest(
|
||||
R"(["new_note", {
|
||||
"action": "new_note",
|
||||
"enabled_on_lock_screen": false
|
||||
}])"),
|
||||
manifest_errors::kDuplicateActionHandlerFound);
|
||||
LoadAndExpectError(CreateManifest(
|
||||
@ -155,16 +104,6 @@ TEST_F(ActionHandlersManifestTest, DuplicateHandlers) {
|
||||
"action": "new_note"
|
||||
}, {
|
||||
"action": "new_note",
|
||||
"enabled_on_lock_screen": false
|
||||
}])"),
|
||||
manifest_errors::kDuplicateActionHandlerFound);
|
||||
LoadAndExpectError(CreateManifest(
|
||||
R"([{
|
||||
"action": "new_note",
|
||||
"enabled_on_lock_screen": true
|
||||
}, {
|
||||
"action": "new_note",
|
||||
"enabled_on_lock_screen": false
|
||||
}])"),
|
||||
manifest_errors::kDuplicateActionHandlerFound);
|
||||
}
|
||||
|
Reference in New Issue
Block a user