Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1787)

Unified Diff: chrome/browser/spellchecker/spellcheck_service.cc

Issue 2244083002: Componentize spellcheck [4]: spellcheck/browser and android java-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/spellchecker/spellcheck_service.cc
diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc
index b60944f5234e9ebaa3030a9793d0dcd57851035b..36cafef0254ff2c1bdd72bd140301a6c11cacef2 100644
--- a/chrome/browser/spellchecker/spellcheck_service.cc
+++ b/chrome/browser/spellchecker/spellcheck_service.cc
@@ -11,15 +11,16 @@
#include "base/supports_user_data.h"
#include "base/synchronization/waitable_event.h"
#include "build/build_config.h"
-#include "chrome/browser/spellchecker/feedback_sender.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
-#include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
-#include "chrome/browser/spellchecker/spellcheck_platform.h"
-#include "chrome/browser/spellchecker/spelling_service_client.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
+#include "components/spellcheck/browser/feedback_sender.h"
+#include "components/spellcheck/browser/pref_names.h"
+#include "components/spellcheck/browser/spellcheck_host_metrics.h"
+#include "components/spellcheck/browser/spellcheck_platform.h"
+#include "components/spellcheck/browser/spelling_service_client.h"
#include "components/spellcheck/common/spellcheck_bdict_language.h"
#include "components/spellcheck/common/spellcheck_common.h"
#include "components/spellcheck/common/spellcheck_messages.h"
@@ -49,7 +50,7 @@ SpellcheckService::SpellcheckService(content::BrowserContext* context)
PrefService* prefs = user_prefs::UserPrefs::Get(context);
pref_change_registrar_.Init(prefs);
StringListPrefMember dictionaries_pref;
- dictionaries_pref.Init(prefs::kSpellCheckDictionaries, prefs);
+ dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, prefs);
std::string first_of_dictionaries;
#if defined(USE_BROWSER_SPELLCHECKER)
@@ -66,7 +67,7 @@ SpellcheckService::SpellcheckService(content::BrowserContext* context)
#else
// Migrate preferences from single-language to multi-language schema.
StringPrefMember single_dictionary_pref;
- single_dictionary_pref.Init(prefs::kSpellCheckDictionary, prefs);
+ single_dictionary_pref.Init(spellcheck::prefs::kSpellCheckDictionary, prefs);
std::string single_dictionary = single_dictionary_pref.GetValue();
if (!dictionaries_pref.GetValue().empty())
@@ -91,21 +92,20 @@ SpellcheckService::SpellcheckService(content::BrowserContext* context)
language_code, country_code));
pref_change_registrar_.Add(
- prefs::kSpellCheckDictionaries,
+ spellcheck::prefs::kSpellCheckDictionaries,
base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged,
base::Unretained(this)));
pref_change_registrar_.Add(
- prefs::kSpellCheckUseSpellingService,
+ spellcheck::prefs::kSpellCheckUseSpellingService,
base::Bind(&SpellcheckService::OnUseSpellingServiceChanged,
base::Unretained(this)));
pref_change_registrar_.Add(
prefs::kAcceptLanguages,
base::Bind(&SpellcheckService::OnAcceptLanguagesChanged,
base::Unretained(this)));
- pref_change_registrar_.Add(
- prefs::kEnableContinuousSpellcheck,
- base::Bind(&SpellcheckService::InitForAllRenderers,
- base::Unretained(this)));
+ pref_change_registrar_.Add(spellcheck::prefs::kEnableContinuousSpellcheck,
+ base::Bind(&SpellcheckService::InitForAllRenderers,
+ base::Unretained(this)));
custom_dictionary_.reset(new SpellcheckCustomDictionary(context_->GetPath()));
custom_dictionary_->AddObserver(this);
@@ -134,7 +134,8 @@ void SpellcheckService::GetDictionaries(base::SupportsUserData* browser_context,
std::vector<Dictionary>* dictionaries) {
PrefService* prefs = user_prefs::UserPrefs::Get(browser_context);
std::set<std::string> spellcheck_dictionaries;
- for (const auto& value : *prefs->GetList(prefs::kSpellCheckDictionaries)) {
+ for (const auto& value :
+ *prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries)) {
std::string dictionary;
if (value->GetAsString(&dictionary))
spellcheck_dictionaries.insert(dictionary);
@@ -197,8 +198,9 @@ void SpellcheckService::InitForRenderer(content::RenderProcessHost* process) {
: IPC::InvalidPlatformFileForTransit();
}
- bool enabled = prefs->GetBoolean(prefs::kEnableContinuousSpellcheck) &&
- !bdict_languages.empty();
+ bool enabled =
+ prefs->GetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck) &&
+ !bdict_languages.empty();
process->Send(new SpellCheckMsg_Init(
bdict_languages,
enabled ? custom_dictionary_->GetWords() : std::set<std::string>()));
@@ -220,7 +222,7 @@ void SpellcheckService::LoadHunspellDictionaries() {
DCHECK(prefs);
const base::ListValue* dictionary_values =
- prefs->GetList(prefs::kSpellCheckDictionaries);
+ prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries);
for (const auto& dictionary_value : *dictionary_values) {
std::string dictionary;
@@ -333,7 +335,7 @@ void SpellcheckService::OnSpellCheckDictionariesChanged() {
void SpellcheckService::OnUseSpellingServiceChanged() {
bool enabled = pref_change_registrar_.prefs()->GetBoolean(
- prefs::kSpellCheckUseSpellingService);
+ spellcheck::prefs::kSpellCheckUseSpellingService);
if (metrics_)
metrics_->RecordSpellingServiceStats(enabled);
UpdateFeedbackSenderState();
@@ -349,7 +351,7 @@ void SpellcheckService::OnAcceptLanguagesChanged() {
&spellcheck::GetCorrespondingSpellCheckLanguage);
StringListPrefMember dictionaries_pref;
- dictionaries_pref.Init(prefs::kSpellCheckDictionaries, prefs);
+ dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, prefs);
std::vector<std::string> dictionaries = dictionaries_pref.GetValue();
std::vector<std::string> filtered_dictionaries;

Powered by Google App Engine
This is Rietveld 408576698