Commit 2141f5a1 authored by Karandeep Bhatia's avatar Karandeep Bhatia Committed by Chromium LUCI CQ

Extensions: Remove the "spellcheck" manifest key.

This manifest key was never completely implemented and there are no
plans to do so as well. Remove the key and associated code.

TODO: Also remove this key from
https://developer.chrome.com/docs/extensions/mv2/manifest/.

BUG=135628, 1164954

Change-Id: Ia6b11e04f68ca80ea4c91fe1d7a67266f14743b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2621972Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842162}
parent fbca46e5
......@@ -223,8 +223,8 @@ const char* const kSafeManifestEntries[] = {
// Network access.
emk::kSockets,
// Just provides dictionaries, no access to content.
emk::kSpellcheck,
// Deprecated manifest key.
// "spellcheck",
// (Note: Using string literal since extensions::manifest_keys only has
// constants for sub-keys.)
......
......@@ -342,8 +342,6 @@ static_library("extensions") {
"api/signed_in_devices/signed_in_devices_api.h",
"api/signed_in_devices/signed_in_devices_manager.cc",
"api/signed_in_devices/signed_in_devices_manager.h",
"api/spellcheck/spellcheck_api.cc",
"api/spellcheck/spellcheck_api.h",
"api/storage/managed_value_store_cache.cc",
"api/storage/managed_value_store_cache.h",
"api/storage/policy_value_store.cc",
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h"
#include "base/lazy_instance.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h"
#include "extensions/common/manifest_constants.h"
namespace extensions {
namespace {
SpellcheckDictionaryInfo* GetSpellcheckDictionaryInfo(
const Extension* extension) {
SpellcheckDictionaryInfo *spellcheck_info =
static_cast<SpellcheckDictionaryInfo*>(
extension->GetManifestData(manifest_keys::kSpellcheck));
return spellcheck_info;
}
SpellcheckService::DictionaryFormat GetDictionaryFormat(
const std::string& format) {
if (format == "hunspell") {
return SpellcheckService::DICT_HUNSPELL;
} else if (format == "text") {
return SpellcheckService::DICT_TEXT;
} else {
return SpellcheckService::DICT_UNKNOWN;
}
}
} // namespace
SpellcheckAPI::SpellcheckAPI(content::BrowserContext* context) {
extension_registry_observer_.Add(ExtensionRegistry::Get(context));
}
SpellcheckAPI::~SpellcheckAPI() = default;
static base::LazyInstance<BrowserContextKeyedAPIFactory<SpellcheckAPI>>::
DestructorAtExit g_spellcheck_api_factory = LAZY_INSTANCE_INITIALIZER;
// static
BrowserContextKeyedAPIFactory<SpellcheckAPI>*
SpellcheckAPI::GetFactoryInstance() {
return g_spellcheck_api_factory.Pointer();
}
void SpellcheckAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
const Extension* extension) {
SpellcheckDictionaryInfo* spellcheck_info =
GetSpellcheckDictionaryInfo(extension);
if (spellcheck_info) {
// TODO(rlp): Handle load failure. =
SpellcheckService* spellcheck =
SpellcheckServiceFactory::GetForContext(browser_context);
spellcheck->LoadExternalDictionary(
spellcheck_info->language,
spellcheck_info->locale,
spellcheck_info->path,
GetDictionaryFormat(spellcheck_info->format));
}
}
void SpellcheckAPI::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) {
SpellcheckDictionaryInfo* spellcheck_info =
GetSpellcheckDictionaryInfo(extension);
if (spellcheck_info) {
// TODO(rlp): Handle unload failure.
SpellcheckService* spellcheck =
SpellcheckServiceFactory::GetForContext(browser_context);
spellcheck->UnloadExternalDictionary(spellcheck_info->path);
}
}
template <>
void
BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() {
DependsOn(SpellcheckServiceFactory::GetInstance());
}
} // namespace extensions
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
namespace extensions {
class SpellcheckAPI : public BrowserContextKeyedAPI,
public ExtensionRegistryObserver {
public:
explicit SpellcheckAPI(content::BrowserContext* context);
~SpellcheckAPI() override;
// BrowserContextKeyedAPI implementation.
static BrowserContextKeyedAPIFactory<SpellcheckAPI>* GetFactoryInstance();
private:
friend class BrowserContextKeyedAPIFactory<SpellcheckAPI>;
// ExtensionRegistryObserver implementation.
void OnExtensionLoaded(content::BrowserContext* browser_context,
const Extension* extension) override;
void OnExtensionUnloaded(content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) override;
// BrowserContextKeyedAPI implementation.
static const char* service_name() {
return "SpellcheckAPI";
}
// Listen to extension load, unloaded notifications.
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
extension_registry_observer_{this};
DISALLOW_COPY_AND_ASSIGN(SpellcheckAPI);
};
template <>
void BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies();
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_
......@@ -49,7 +49,6 @@
#include "chrome/browser/extensions/warning_badge_service_factory.h"
#include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include "chrome/common/buildflags.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h"
#include "extensions/browser/api/networking_private/networking_private_delegate_factory.h"
#include "ppapi/buildflags/buildflags.h"
......@@ -67,10 +66,6 @@
#include "chrome/browser/extensions/api/mdns/mdns_api.h"
#endif
#if BUILDFLAG(ENABLE_SPELLCHECK)
#include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h"
#endif
#if BUILDFLAG(ENABLE_AUTOFILL_ASSISTANT_API)
#include "chrome/browser/extensions/api/autofill_assistant_private/autofill_assistant_private_api.h"
#endif
......@@ -130,9 +125,6 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
extensions::SettingsPrivateEventRouterFactory::GetInstance();
extensions::SettingsOverridesAPI::GetFactoryInstance();
extensions::SignedInDevicesManager::GetFactoryInstance();
#if BUILDFLAG(ENABLE_SPELLCHECK)
extensions::SpellcheckAPI::GetFactoryInstance();
#endif
extensions::SystemIndicatorManagerFactory::GetInstance();
extensions::TabCaptureRegistry::GetFactoryInstance();
extensions::TabsWindowsAPI::GetFactoryInstance();
......
......@@ -527,18 +527,6 @@ bool SpellcheckService::IsSpellcheckEnabled() const {
(!hunspell_dictionaries_.empty() || enable_if_uninitialized);
}
bool SpellcheckService::LoadExternalDictionary(std::string language,
std::string locale,
std::string path,
DictionaryFormat format) {
return false;
}
bool SpellcheckService::UnloadExternalDictionary(
const std::string& /* path */) {
return false;
}
void SpellcheckService::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
......
......@@ -62,13 +62,6 @@ class SpellcheckService : public KeyedService,
BDICT_CORRUPTED,
};
// Dictionary format used for loading an external dictionary.
enum DictionaryFormat {
DICT_HUNSPELL,
DICT_TEXT,
DICT_UNKNOWN,
};
// A dictionary that can be used for spellcheck.
struct Dictionary {
// The shortest unambiguous identifier for a language from
......@@ -141,17 +134,6 @@ class SpellcheckService : public KeyedService,
// dictionaries available.
bool IsSpellcheckEnabled() const;
// Load a dictionary from a given path. Format specifies how the dictionary
// is stored. Return value is true if successful.
bool LoadExternalDictionary(std::string language,
std::string locale,
std::string path,
DictionaryFormat format);
// Unload a dictionary. The path is given to identify the dictionary.
// Return value is true if successful.
bool UnloadExternalDictionary(const std::string& /* path */);
// NotificationProfile implementation.
void Observe(int type,
const content::NotificationSource& source,
......
......@@ -261,8 +261,6 @@ static_library("common") {
"extensions/api/omnibox/omnibox_handler.h",
"extensions/api/speech/tts_engine_manifest_handler.cc",
"extensions/api/speech/tts_engine_manifest_handler.h",
"extensions/api/spellcheck/spellcheck_handler.cc",
"extensions/api/spellcheck/spellcheck_handler.h",
"extensions/api/storage/storage_schema_manifest_handler.cc",
"extensions/api/storage/storage_schema_manifest_handler.h",
"extensions/api/system_indicator/system_indicator_handler.cc",
......
......@@ -213,10 +213,6 @@
"channel": "stable",
"extension_types": "all"
},
"spellcheck": {
"channel": "dev",
"extension_types": ["extension"]
},
"storage": {
"channel": "stable",
"extension_types": [
......
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// 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/spellcheck/spellcheck_handler.h"
#include <memory>
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/manifest_constants.h"
namespace extensions {
namespace keys = manifest_keys;
namespace errors = manifest_errors;
SpellcheckDictionaryInfo::SpellcheckDictionaryInfo() {
}
SpellcheckDictionaryInfo::~SpellcheckDictionaryInfo() {
}
SpellcheckHandler::SpellcheckHandler() {
}
SpellcheckHandler::~SpellcheckHandler() {
}
bool SpellcheckHandler::Parse(Extension* extension, base::string16* error) {
const base::DictionaryValue* spellcheck_value = NULL;
if (!extension->manifest()->GetDictionary(keys::kSpellcheck,
&spellcheck_value)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheck);
return false;
}
std::unique_ptr<SpellcheckDictionaryInfo> spellcheck_info(
new SpellcheckDictionaryInfo);
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLanguage) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryLanguage,
&spellcheck_info->language)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryLanguage);
return false;
}
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLocale) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryLocale,
&spellcheck_info->locale)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryLocale);
return false;
}
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryFormat) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryFormat,
&spellcheck_info->format)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryFormat);
return false;
}
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryPath) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryPath,
&spellcheck_info->path)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryPath);
return false;
}
extension->SetManifestData(keys::kSpellcheck, std::move(spellcheck_info));
return true;
}
base::span<const char* const> SpellcheckHandler::Keys() const {
static constexpr const char* kKeys[] = {keys::kSpellcheck};
return kKeys;
}
} // namespace extensions
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// 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_SPELLCHECK_SPELLCHECK_HANDLER_H_
#define CHROME_COMMON_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_HANDLER_H_
#include "base/macros.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handler.h"
namespace extensions {
// This structure holds the information parsed by the SpellcheckHandler to be
// used in the SpellcheckAPI functions. It is stored on the extension.
struct SpellcheckDictionaryInfo : public extensions::Extension::ManifestData {
SpellcheckDictionaryInfo();
~SpellcheckDictionaryInfo() override;
std::string language;
std::string locale;
std::string path;
std::string format;
};
// Parses the "spellcheck" manifest key.
class SpellcheckHandler : public ManifestHandler {
public:
SpellcheckHandler();
~SpellcheckHandler() override;
bool Parse(Extension* extension, base::string16* error) override;
private:
base::span<const char* const> Keys() const override;
DISALLOW_COPY_AND_ASSIGN(SpellcheckHandler);
};
} // namespace extensions
#endif // CHROME_COMMON_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_HANDLER_H_
......@@ -11,7 +11,6 @@
#include "chrome/common/extensions/api/commands/commands_handler.h"
#include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
#include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h"
#include "chrome/common/extensions/api/storage/storage_schema_manifest_handler.h"
#include "chrome/common/extensions/api/system_indicator/system_indicator_handler.h"
#include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h"
......@@ -60,7 +59,6 @@ void RegisterChromeManifestHandlers() {
registry->RegisterHandler(std::make_unique<OmniboxHandler>());
registry->RegisterHandler(std::make_unique<OptionsPageManifestHandler>());
registry->RegisterHandler(std::make_unique<SettingsOverridesHandler>());
registry->RegisterHandler(std::make_unique<SpellcheckHandler>());
registry->RegisterHandler(std::make_unique<StorageSchemaManifestHandler>());
registry->RegisterHandler(std::make_unique<SystemIndicatorHandler>());
registry->RegisterHandler(std::make_unique<ThemeHandler>());
......
......@@ -137,11 +137,6 @@ const char kSharedModuleLegacyAllowlist[] = "whitelist";
const char kShortName[] = "short_name";
const char kSignature[] = "signature";
const char kSockets[] = "sockets";
const char kSpellcheck[] = "spellcheck";
const char kSpellcheckDictionaryFormat[] = "dictionary_format";
const char kSpellcheckDictionaryLanguage[] = "dictionary_language";
const char kSpellcheckDictionaryLocale[] = "dictionary_locale";
const char kSpellcheckDictionaryPath[] = "dictionary_path";
const char kStorageManagedSchema[] = "storage.managed_schema";
const char kSuggestedKey[] = "suggested_key";
const char kSystemIndicator[] = "system_indicator";
......@@ -594,16 +589,6 @@ const char kInvalidShortName[] =
"Invalid value for 'short_name'.";
const char kInvalidSignature[] =
"Value 'signature' is missing or invalid.";
const char kInvalidSpellcheck[] =
"Invalid value for 'spellcheck'.";
const char kInvalidSpellcheckDictionaryFormat[] =
"Invalid value for spellcheck dictionary format.";
const char kInvalidSpellcheckDictionaryLanguage[] =
"Invalid value for spellcheck dictionary language.";
const char kInvalidSpellcheckDictionaryLocale[] =
"Invalid value for spellcheck dictionary locale.";
const char kInvalidSpellcheckDictionaryPath[] =
"Invalid value for spellcheck dictionary path.";
const char kInvalidStartupOverrideURL[] =
"Invalid value for overriding startup URL: '[*]'.";
const char kInvalidSystemIndicator[] =
......
......@@ -139,11 +139,6 @@ extern const char kSharedModuleLegacyAllowlist[];
extern const char kShortName[];
extern const char kSignature[];
extern const char kSockets[];
extern const char kSpellcheck[];
extern const char kSpellcheckDictionaryFormat[];
extern const char kSpellcheckDictionaryLanguage[];
extern const char kSpellcheckDictionaryLocale[];
extern const char kSpellcheckDictionaryPath[];
extern const char kStorageManagedSchema[];
extern const char kSuggestedKey[];
extern const char kSystemIndicator[];
......@@ -423,11 +418,6 @@ extern const char kInvalidSearchEngineMissingKeys[];
extern const char kInvalidSearchEngineURL[];
extern const char kInvalidShortName[];
extern const char kInvalidSignature[];
extern const char kInvalidSpellcheck[];
extern const char kInvalidSpellcheckDictionaryFormat[];
extern const char kInvalidSpellcheckDictionaryLanguage[];
extern const char kInvalidSpellcheckDictionaryLocale[];
extern const char kInvalidSpellcheckDictionaryPath[];
extern const char kInvalidStartupOverrideURL[];
extern const char kInvalidSystemIndicator[];
extern const char kInvalidTheme[];
......
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