[Extensions] Move manifest handlers to extensions/ (part 2)
Move some manifest handlers, associated metadata, and tests from chrome/ to extensions/. Bug: 324534603 Change-Id: Ic054221ccd84965066e93a91a0adaffc49ba2edb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5331700 Reviewed-by: Justin Lulejian <jlulejian@chromium.org> Commit-Queue: Devlin Cronin <rdevlin.cronin@chromium.org> Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/heads/main@{#1269919}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
50cb444eea
commit
71ecbb928d
chrome
browser
extensions
api
input_ime
common
test
extensions
common
test
data
manifest_tests
homepage_url_bad_schema.jsonhomepage_url_empty.jsonhomepage_url_externally_hosted.jsonhomepage_url_google_hosted.jsonhomepage_url_invalid.jsonhomepage_url_valid.jsonupdate_url_invalid_1.jsonupdate_url_invalid_2.jsonupdate_url_invalid_3.jsonupdate_url_valid_1.jsonupdate_url_valid_2.jsonupdate_url_valid_3.jsonupdate_url_valid_4.json
@ -11,8 +11,8 @@
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "chrome/browser/ash/input_method/input_method_engine.h"
|
||||
#include "chrome/common/extensions/api/input_ime/input_components_handler.h"
|
||||
#include "extensions/browser/extension_function.h"
|
||||
#include "extensions/common/manifest_handlers/input_components_handler.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
|
@ -376,10 +376,6 @@ static_library("common_lib") {
|
||||
}
|
||||
if (is_chromeos_ash) {
|
||||
assert(enable_extensions)
|
||||
sources += [
|
||||
"extensions/api/input_ime/input_components_handler.cc",
|
||||
"extensions/api/input_ime/input_components_handler.h",
|
||||
]
|
||||
public_deps += [ "//ash/keyboard/ui" ]
|
||||
deps += [ "//ash/constants" ]
|
||||
} else if (is_chromeos_lacros) {
|
||||
|
@ -63,20 +63,6 @@
|
||||
"extension", "legacy_packaged_app", "hosted_app"
|
||||
]
|
||||
},
|
||||
"event_rules": {
|
||||
"channel": "stable",
|
||||
// "event_rules" does not grant any capabilities, it's just
|
||||
// an optimisation for any API which uses events, so it's safe
|
||||
// to expose to all extension types.
|
||||
"extension_types": [
|
||||
"extension",
|
||||
"legacy_packaged_app",
|
||||
"platform_app",
|
||||
"hosted_app",
|
||||
"shared_module",
|
||||
"theme"
|
||||
]
|
||||
},
|
||||
"devtools_page": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
@ -133,14 +119,6 @@
|
||||
"58B0C2968C335964D5433E89CA4D86628A0E3D4B" // http://crbug.com/673004
|
||||
]
|
||||
}],
|
||||
"homepage_url": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
},
|
||||
"input_components": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
},
|
||||
"minimum_chrome_version": {
|
||||
"channel": "stable",
|
||||
"extension_types": [
|
||||
@ -165,23 +143,10 @@
|
||||
"chromeos_system_extension"
|
||||
]
|
||||
},
|
||||
"options_page": {
|
||||
"channel": "stable",
|
||||
"extension_types": [
|
||||
"extension",
|
||||
"legacy_packaged_app",
|
||||
"hosted_app",
|
||||
"chromeos_system_extension"
|
||||
]
|
||||
},
|
||||
"platforms": {
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"short_name": {
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"side_panel": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension"],
|
||||
@ -218,10 +183,6 @@
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
},
|
||||
"update_url": {
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"url_handlers": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["platform_app"]
|
||||
|
@ -20,17 +20,12 @@
|
||||
#include "chrome/common/extensions/manifest_handlers/natively_connectable_handler.h"
|
||||
#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h"
|
||||
#include "chrome/common/extensions/manifest_handlers/theme_handler.h"
|
||||
#include "extensions/common/manifest_handlers/options_page_info.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
#include "chrome/common/extensions/api/file_browser_handlers/file_browser_handler.h"
|
||||
#include "chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chrome/common/extensions/api/input_ime/input_components_handler.h"
|
||||
#endif
|
||||
|
||||
namespace extensions {
|
||||
|
||||
void RegisterChromeManifestHandlers() {
|
||||
@ -42,7 +37,6 @@ void RegisterChromeManifestHandlers() {
|
||||
registry->RegisterHandler(std::make_unique<MinimumChromeVersionChecker>());
|
||||
registry->RegisterHandler(std::make_unique<NativelyConnectableHandler>());
|
||||
registry->RegisterHandler(std::make_unique<OmniboxHandler>());
|
||||
registry->RegisterHandler(std::make_unique<OptionsPageManifestHandler>());
|
||||
registry->RegisterHandler(std::make_unique<SettingsOverridesHandler>());
|
||||
registry->RegisterHandler(std::make_unique<SidePanelManifestHandler>());
|
||||
registry->RegisterHandler(std::make_unique<StorageSchemaManifestHandler>());
|
||||
@ -57,10 +51,6 @@ void RegisterChromeManifestHandlers() {
|
||||
registry->RegisterHandler(
|
||||
std::make_unique<FileSystemProviderCapabilitiesHandler>());
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
registry->RegisterHandler(std::make_unique<InputComponentsHandler>());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace extensions
|
||||
|
@ -9152,7 +9152,6 @@ test("unit_tests") {
|
||||
"../common/extensions/manifest_tests/extension_manifests_default_extent_path_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_experimental_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_icons_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_kiosk_unittest.cc",
|
||||
@ -9168,7 +9167,6 @@ test("unit_tests") {
|
||||
"../common/extensions/manifest_tests/extension_manifests_sample_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_side_panel_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_ui_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_update_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_validapp_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc",
|
||||
"../common/extensions/manifest_tests/extension_manifests_web_unittest.cc",
|
||||
|
@ -531,6 +531,12 @@ static_library("common") {
|
||||
"manifest_handlers/action_handlers_handler.h",
|
||||
]
|
||||
}
|
||||
if (is_chromeos_ash) {
|
||||
sources += [
|
||||
"manifest_handlers/input_components_handler.cc",
|
||||
"manifest_handlers/input_components_handler.h",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
# NOTE: This is separate from ":common" because it depends on
|
||||
@ -612,6 +618,7 @@ source_set("unit_tests") {
|
||||
"manifest_handlers/extension_action_handler_unittest.cc",
|
||||
"manifest_handlers/extension_action_page_action_unittest.cc",
|
||||
"manifest_handlers/externally_connectable_unittest.cc",
|
||||
"manifest_handlers/homepage_url_unittest.cc",
|
||||
"manifest_handlers/icons_handler_unittest.cc",
|
||||
"manifest_handlers/incognito_manifest_unittest.cc",
|
||||
"manifest_handlers/kiosk_mode_info_unittest.cc",
|
||||
@ -623,6 +630,7 @@ source_set("unit_tests") {
|
||||
"manifest_handlers/requirements_unittest.cc",
|
||||
"manifest_handlers/shared_module_manifest_unittest.cc",
|
||||
"manifest_handlers/trial_tokens_unittest.cc",
|
||||
"manifest_handlers/update_url_unittest.cc",
|
||||
"manifest_unittest.cc",
|
||||
"message_bundle_unittest.cc",
|
||||
"mojom/message_port_mojom_traits_unittest.cc",
|
||||
|
@ -173,6 +173,20 @@
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"event_rules": {
|
||||
"channel": "stable",
|
||||
// "event_rules" does not grant any capabilities, it's just
|
||||
// an optimisation for any API which uses events, so it's safe
|
||||
// to expose to all extension types.
|
||||
"extension_types": [
|
||||
"extension",
|
||||
"legacy_packaged_app",
|
||||
"platform_app",
|
||||
"hosted_app",
|
||||
"shared_module",
|
||||
"theme"
|
||||
]
|
||||
},
|
||||
"export": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["shared_module"]
|
||||
@ -216,6 +230,10 @@
|
||||
"platforms": ["chromeos", "lacros"]
|
||||
}
|
||||
],
|
||||
"homepage_url": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
},
|
||||
"host_permissions": [{
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension"],
|
||||
@ -231,6 +249,10 @@
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"input_components": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
},
|
||||
"import": {
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
@ -371,6 +393,15 @@
|
||||
"extension_types": ["extension"],
|
||||
"min_manifest_version": 3
|
||||
},
|
||||
"options_page": {
|
||||
"channel": "stable",
|
||||
"extension_types": [
|
||||
"extension",
|
||||
"legacy_packaged_app",
|
||||
"hosted_app",
|
||||
"chromeos_system_extension"
|
||||
]
|
||||
},
|
||||
"options_ui": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["extension", "legacy_packaged_app"]
|
||||
@ -407,6 +438,10 @@
|
||||
"extension", "platform_app", "legacy_packaged_app"
|
||||
]
|
||||
},
|
||||
"short_name": {
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"sockets": [
|
||||
{
|
||||
"channel": "stable",
|
||||
@ -431,6 +466,10 @@
|
||||
"channel": "canary",
|
||||
"extension_types": ["extension"]
|
||||
},
|
||||
"update_url": {
|
||||
"channel": "stable",
|
||||
"extension_types": "all"
|
||||
},
|
||||
"usb_printers": {
|
||||
"channel": "stable",
|
||||
"extension_types": ["platform_app"]
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "extensions/common/manifest_handlers/nacl_modules_handler.h"
|
||||
#include "extensions/common/manifest_handlers/oauth2_manifest_handler.h"
|
||||
#include "extensions/common/manifest_handlers/offline_enabled_info.h"
|
||||
#include "extensions/common/manifest_handlers/options_page_info.h"
|
||||
#include "extensions/common/manifest_handlers/replacement_apps.h"
|
||||
#include "extensions/common/manifest_handlers/requirements_info.h"
|
||||
#include "extensions/common/manifest_handlers/sandboxed_page_info.h"
|
||||
@ -44,6 +45,7 @@
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "extensions/common/manifest_handlers/action_handlers_handler.h"
|
||||
#include "extensions/common/manifest_handlers/input_components_handler.h"
|
||||
#endif
|
||||
|
||||
namespace extensions {
|
||||
@ -75,6 +77,9 @@ void RegisterCommonManifestHandlers() {
|
||||
registry->RegisterHandler(std::make_unique<HomepageURLHandler>());
|
||||
registry->RegisterHandler(std::make_unique<IconsHandler>());
|
||||
registry->RegisterHandler(std::make_unique<IncognitoHandler>());
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
registry->RegisterHandler(std::make_unique<InputComponentsHandler>());
|
||||
#endif
|
||||
registry->RegisterHandler(std::make_unique<KioskModeHandler>());
|
||||
registry->RegisterHandler(std::make_unique<MimeTypesHandlerParser>());
|
||||
#if BUILDFLAG(ENABLE_NACL)
|
||||
@ -82,6 +87,7 @@ void RegisterCommonManifestHandlers() {
|
||||
#endif
|
||||
registry->RegisterHandler(std::make_unique<OAuth2ManifestHandler>());
|
||||
registry->RegisterHandler(std::make_unique<OfflineEnabledHandler>());
|
||||
registry->RegisterHandler(std::make_unique<OptionsPageHandler>());
|
||||
registry->RegisterHandler(std::make_unique<ReplacementAppsHandler>());
|
||||
registry->RegisterHandler(std::make_unique<RequirementsHandler>());
|
||||
registry->RegisterHandler(std::make_unique<SandboxedPageHandler>());
|
||||
|
@ -3,45 +3,49 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/strings/string_util.h"
|
||||
#include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
|
||||
#include "extensions/common/extension.h"
|
||||
#include "extensions/common/manifest_constants.h"
|
||||
#include "extensions/common/manifest_test.h"
|
||||
#include "extensions/common/manifest_url_handlers.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extensions::manifest_errors;
|
||||
namespace extensions {
|
||||
|
||||
using HomepageURLManifestTest = ChromeManifestTest;
|
||||
namespace errors = manifest_errors;
|
||||
|
||||
using HomepageURLManifestTest = ManifestTest;
|
||||
|
||||
TEST_F(HomepageURLManifestTest, ParseHomepageURLs) {
|
||||
scoped_refptr<extensions::Extension> extension(
|
||||
LoadAndExpectSuccess("homepage_valid.json"));
|
||||
scoped_refptr<Extension> extension(
|
||||
LoadAndExpectSuccess("homepage_url_valid.json"));
|
||||
|
||||
Testcase testcases[] = {
|
||||
Testcase("homepage_empty.json",
|
||||
Testcase("homepage_url_empty.json",
|
||||
errors::kInvalidHomepageURL),
|
||||
Testcase("homepage_invalid.json",
|
||||
Testcase("homepage_url_invalid.json",
|
||||
errors::kInvalidHomepageURL),
|
||||
Testcase("homepage_bad_schema.json",
|
||||
Testcase("homepage_url_bad_schema.json",
|
||||
errors::kInvalidHomepageURL)
|
||||
};
|
||||
RunTestcases(testcases, std::size(testcases), EXPECT_TYPE_ERROR);
|
||||
}
|
||||
|
||||
TEST_F(HomepageURLManifestTest, GetHomepageURL) {
|
||||
scoped_refptr<extensions::Extension> extension(
|
||||
LoadAndExpectSuccess("homepage_valid.json"));
|
||||
scoped_refptr<Extension> extension(
|
||||
LoadAndExpectSuccess("homepage_url_valid.json"));
|
||||
EXPECT_EQ(GURL("http://foo.com#bar"),
|
||||
extensions::ManifestURL::GetHomepageURL(extension.get()));
|
||||
ManifestURL::GetHomepageURL(extension.get()));
|
||||
|
||||
// The Google Gallery URL ends with the id, which depends on the path, which
|
||||
// can be different in testing, so we just check the part before id.
|
||||
extension = LoadAndExpectSuccess("homepage_google_hosted.json");
|
||||
extension = LoadAndExpectSuccess("homepage_url_google_hosted.json");
|
||||
EXPECT_TRUE(base::StartsWith(
|
||||
extensions::ManifestURL::GetHomepageURL(extension.get()).spec(),
|
||||
ManifestURL::GetHomepageURL(extension.get()).spec(),
|
||||
"https://chrome.google.com/webstore/detail/",
|
||||
base::CompareCase::INSENSITIVE_ASCII));
|
||||
|
||||
extension = LoadAndExpectSuccess("homepage_externally_hosted.json");
|
||||
EXPECT_EQ(GURL(), extensions::ManifestURL::GetHomepageURL(extension.get()));
|
||||
extension = LoadAndExpectSuccess("homepage_url_externally_hosted.json");
|
||||
EXPECT_EQ(GURL(), ManifestURL::GetHomepageURL(extension.get()));
|
||||
}
|
||||
|
||||
} // namespace extensions
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/extensions/api/input_ime/input_components_handler.h"
|
||||
#include "extensions/common/manifest_handlers/input_components_handler.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_COMMON_EXTENSIONS_API_INPUT_IME_INPUT_COMPONENTS_HANDLER_H_
|
||||
#define CHROME_COMMON_EXTENSIONS_API_INPUT_IME_INPUT_COMPONENTS_HANDLER_H_
|
||||
#ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_INPUT_COMPONENTS_HANDLER_H_
|
||||
#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_INPUT_COMPONENTS_HANDLER_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
@ -62,4 +62,4 @@ class InputComponentsHandler : public ManifestHandler {
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CHROME_COMMON_EXTENSIONS_API_INPUT_IME_INPUT_COMPONENTS_HANDLER_H_
|
||||
#endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_INPUT_COMPONENTS_HANDLER_H_
|
@ -158,14 +158,11 @@ std::unique_ptr<OptionsPageInfo> OptionsPageInfo::Create(
|
||||
open_in_tab);
|
||||
}
|
||||
|
||||
OptionsPageManifestHandler::OptionsPageManifestHandler() {
|
||||
}
|
||||
OptionsPageHandler::OptionsPageHandler() {}
|
||||
|
||||
OptionsPageManifestHandler::~OptionsPageManifestHandler() {
|
||||
}
|
||||
OptionsPageHandler::~OptionsPageHandler() {}
|
||||
|
||||
bool OptionsPageManifestHandler::Parse(Extension* extension,
|
||||
std::u16string* error) {
|
||||
bool OptionsPageHandler::Parse(Extension* extension, std::u16string* error) {
|
||||
std::vector<InstallWarning> install_warnings;
|
||||
const Manifest* manifest = extension->manifest();
|
||||
|
||||
@ -193,10 +190,9 @@ bool OptionsPageManifestHandler::Parse(Extension* extension,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OptionsPageManifestHandler::Validate(
|
||||
const Extension* extension,
|
||||
std::string* error,
|
||||
std::vector<InstallWarning>* warnings) const {
|
||||
bool OptionsPageHandler::Validate(const Extension* extension,
|
||||
std::string* error,
|
||||
std::vector<InstallWarning>* warnings) const {
|
||||
// Validate path to the options page. Don't check the URL for hosted apps,
|
||||
// because they are expected to refer to an external URL.
|
||||
if (!OptionsPageInfo::HasOptionsPage(extension) || extension->is_hosted_app())
|
||||
@ -213,7 +209,7 @@ bool OptionsPageManifestHandler::Validate(
|
||||
return true;
|
||||
}
|
||||
|
||||
base::span<const char* const> OptionsPageManifestHandler::Keys() const {
|
||||
base::span<const char* const> OptionsPageHandler::Keys() const {
|
||||
static constexpr const char* kKeys[] = {keys::kOptionsPage, keys::kOptionsUI};
|
||||
return kKeys;
|
||||
}
|
||||
|
@ -68,15 +68,14 @@ class OptionsPageInfo : public Extension::ManifestData {
|
||||
};
|
||||
|
||||
// Parses the "options_ui" manifest key and the legacy "options_page" key.
|
||||
class OptionsPageManifestHandler : public ManifestHandler {
|
||||
class OptionsPageHandler : public ManifestHandler {
|
||||
public:
|
||||
OptionsPageManifestHandler();
|
||||
OptionsPageHandler();
|
||||
|
||||
OptionsPageManifestHandler(const OptionsPageManifestHandler&) = delete;
|
||||
OptionsPageManifestHandler& operator=(const OptionsPageManifestHandler&) =
|
||||
delete;
|
||||
OptionsPageHandler(const OptionsPageHandler&) = delete;
|
||||
OptionsPageHandler& operator=(const OptionsPageHandler&) = delete;
|
||||
|
||||
~OptionsPageManifestHandler() override;
|
||||
~OptionsPageHandler() override;
|
||||
|
||||
bool Parse(Extension* extension, std::u16string* error) override;
|
||||
bool Validate(const Extension* extension,
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
|
||||
#include "extensions/common/manifest_constants.h"
|
||||
#include "extensions/common/manifest_test.h"
|
||||
#include "extensions/common/manifest_url_handlers.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -12,7 +12,7 @@ using extensions::mojom::ManifestLocation;
|
||||
|
||||
namespace errors = extensions::manifest_errors;
|
||||
|
||||
using UpdateURLManifestTest = ChromeManifestTest;
|
||||
using UpdateURLManifestTest = extensions::ManifestTest;
|
||||
|
||||
TEST_F(UpdateURLManifestTest, UpdateUrls) {
|
||||
// Test several valid update urls
|
Reference in New Issue
Block a user