|
@@ -0,0 +1,64 @@
|
|
|
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
+From: Samuel Attard <[email protected]>
|
|
|
+Date: Sun, 1 Mar 2020 16:33:55 -0800
|
|
|
+Subject: feat: allow embedders to add observers on created hunspell
|
|
|
+ dictionaries
|
|
|
+
|
|
|
+
|
|
|
+diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc
|
|
|
+index 0dc509bafcfab2637aab4ea55769cd06ad3492c9..3b1f02e354c5c5a85e9193859ca8e7497f02cf86 100644
|
|
|
+--- a/chrome/browser/spellchecker/spellcheck_service.cc
|
|
|
++++ b/chrome/browser/spellchecker/spellcheck_service.cc
|
|
|
+@@ -284,6 +284,9 @@ void SpellcheckService::LoadHunspellDictionaries() {
|
|
|
+ std::make_unique<SpellcheckHunspellDictionary>(dictionary, context_,
|
|
|
+ this));
|
|
|
+ hunspell_dictionaries_.back()->AddObserver(this);
|
|
|
++ if (hunspell_observer_) {
|
|
|
++ hunspell_dictionaries_.back()->AddObserver(hunspell_observer_);
|
|
|
++ }
|
|
|
+ hunspell_dictionaries_.back()->Load();
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -297,6 +300,20 @@ SpellcheckService::GetHunspellDictionaries() {
|
|
|
+ return hunspell_dictionaries_;
|
|
|
+ }
|
|
|
+
|
|
|
++void SpellcheckService::SetHunspellObserver(SpellcheckHunspellDictionary::Observer* observer) {
|
|
|
++ if (hunspell_observer_) {
|
|
|
++ for (auto& dict : hunspell_dictionaries_) {
|
|
|
++ dict->RemoveObserver(hunspell_observer_);
|
|
|
++ }
|
|
|
++ }
|
|
|
++ if (observer) {
|
|
|
++ for (auto& dict : hunspell_dictionaries_) {
|
|
|
++ dict->AddObserver(observer);
|
|
|
++ }
|
|
|
++ }
|
|
|
++ hunspell_observer_ = observer;
|
|
|
++}
|
|
|
++
|
|
|
+ bool SpellcheckService::LoadExternalDictionary(std::string language,
|
|
|
+ std::string locale,
|
|
|
+ std::string path,
|
|
|
+diff --git a/chrome/browser/spellchecker/spellcheck_service.h b/chrome/browser/spellchecker/spellcheck_service.h
|
|
|
+index 557a0a2a91821a595181481f92b2a2a06dcb1f50..59e24da4be927303df8c4aac87f50778c1c208b0 100644
|
|
|
+--- a/chrome/browser/spellchecker/spellcheck_service.h
|
|
|
++++ b/chrome/browser/spellchecker/spellcheck_service.h
|
|
|
+@@ -116,6 +116,8 @@ class SpellcheckService : public KeyedService,
|
|
|
+ const std::vector<std::unique_ptr<SpellcheckHunspellDictionary>>&
|
|
|
+ GetHunspellDictionaries();
|
|
|
+
|
|
|
++ void SetHunspellObserver(SpellcheckHunspellDictionary::Observer* observer);
|
|
|
++
|
|
|
+ // 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,
|
|
|
+@@ -213,6 +215,8 @@ class SpellcheckService : public KeyedService,
|
|
|
+ // A pointer to the BrowserContext which this service refers to.
|
|
|
+ content::BrowserContext* context_;
|
|
|
+
|
|
|
++ SpellcheckHunspellDictionary::Observer* hunspell_observer_ = nullptr;
|
|
|
++
|
|
|
+ std::unique_ptr<SpellCheckHostMetrics> metrics_;
|
|
|
+
|
|
|
+ std::unique_ptr<SpellcheckCustomDictionary> custom_dictionary_;
|