mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-01-20 05:38:03 +01:00
77aa0be191
This includes: - Red underline of misspelled words in html text areas. - Right-click context menu options to correct the misspelled word. - New CefBrowser::ReplaceMisspelling method for accepting a word replacement. - Methods added to CefContextMenuParams for retrieving spelling-related information. - Uses the unified text checker when auto-correct is not enabled to match Google Chrome behavior. - On Windows and Linux a hunspell dictionary file will be downloaded to the "<cache_path>/Dictionaries" directory as needed, or used from the <cache_path> directory if the file already exists there. The dictionary file will be downloaded from http://cache.pack.google.com/edgedl/chrome/dict/<LANG>-3-0.bdic where <LANG> is the language abbreviation. - On OS X the spell checking implementation will use the system NSSpellChecker implementation. The following command-line flags have been added: --disable-spell-checking => Disable spell-checking support (no red underline, no dictionary file download, etc). --enable-spelling-auto-correct => Automatically correct common misspellings while typing (like 'omre' to 'more' on Windows/Linux or 'ehlo' to 'helo' on OS X). --enable-spelling-service => Enable use of the remote Google spelling service (this requires Google API keys). --override-spell-check-lang=<LANG> => Use the specified dictionary language <LANG> instead of the language specified in the locales.pak file. To see the default/supported dictionary languages: https://code.google.com/p/chromium/codesearch#search/&q=IDS_SPELLCHECK_DICTIONARY%20xtb&sq=package:chromium git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1859 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
118 lines
3.9 KiB
C++
118 lines
3.9 KiB
C++
// Copyright (c) 2013 The Chromium Embedded Framework 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 "libcef/browser/browser_pref_store.h"
|
|
|
|
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
|
#include "libcef/common/cef_switches.h"
|
|
|
|
#include "base/command_line.h"
|
|
#include "base/prefs/pref_service.h"
|
|
#include "base/prefs/pref_service_factory.h"
|
|
#include "base/prefs/pref_registry_simple.h"
|
|
#include "base/strings/string_number_conversions.h"
|
|
#include "base/values.h"
|
|
#include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
|
|
#include "chrome/browser/prefs/command_line_pref_store.h"
|
|
#include "chrome/browser/prefs/proxy_config_dictionary.h"
|
|
#include "chrome/common/chrome_switches.h"
|
|
#include "chrome/common/pref_names.h"
|
|
#include "grit/cef_strings.h"
|
|
#include "ui/base/l10n/l10n_util.h"
|
|
|
|
namespace {
|
|
|
|
// A helper function for registering localized values.
|
|
// Based on CreateLocaleDefaultValue from
|
|
// components/pref_registry/pref_registry_syncable.cc.
|
|
void RegisterLocalizedValue(PrefRegistrySimple* registry,
|
|
const char* path,
|
|
base::Value::Type type,
|
|
int message_id) {
|
|
const std::string resource_string = l10n_util::GetStringUTF8(message_id);
|
|
DCHECK(!resource_string.empty());
|
|
switch (type) {
|
|
case base::Value::TYPE_BOOLEAN: {
|
|
if ("true" == resource_string)
|
|
registry->RegisterBooleanPref(path, true);
|
|
else if ("false" == resource_string)
|
|
registry->RegisterBooleanPref(path, false);
|
|
return;
|
|
}
|
|
|
|
case base::Value::TYPE_INTEGER: {
|
|
int val;
|
|
base::StringToInt(resource_string, &val);
|
|
registry->RegisterIntegerPref(path, val);
|
|
return;
|
|
}
|
|
|
|
case base::Value::TYPE_DOUBLE: {
|
|
double val;
|
|
base::StringToDouble(resource_string, &val);
|
|
registry->RegisterDoublePref(path, val);
|
|
return;
|
|
}
|
|
|
|
case base::Value::TYPE_STRING: {
|
|
registry->RegisterStringPref(path, resource_string);
|
|
return;
|
|
}
|
|
|
|
default: {
|
|
NOTREACHED() <<
|
|
"list and dictionary types cannot have default locale values";
|
|
}
|
|
}
|
|
NOTREACHED();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
CefBrowserPrefStore::CefBrowserPrefStore() {
|
|
}
|
|
|
|
scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
|
|
const base::CommandLine* command_line =
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
base::PrefServiceFactory factory;
|
|
factory.set_command_line_prefs(
|
|
new CommandLinePrefStore(command_line));
|
|
factory.set_user_prefs(this);
|
|
|
|
scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple());
|
|
|
|
// Default settings.
|
|
CefMediaCaptureDevicesDispatcher::RegisterPrefs(registry.get());
|
|
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
|
|
|
|
// Print settings.
|
|
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
|
|
|
|
// Spell checking settings.
|
|
std::string spellcheck_lang =
|
|
command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang);
|
|
if (!spellcheck_lang.empty()) {
|
|
registry->RegisterStringPref(prefs::kSpellCheckDictionary, spellcheck_lang);
|
|
} else {
|
|
RegisterLocalizedValue(registry.get(),
|
|
prefs::kSpellCheckDictionary,
|
|
base::Value::TYPE_STRING,
|
|
IDS_SPELLCHECK_DICTIONARY);
|
|
}
|
|
registry->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService,
|
|
command_line->HasSwitch(switches::kEnableSpellingService));
|
|
registry->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, true);
|
|
// The kEnableSpellingAutoCorrect command-line value is also checked in
|
|
// SpellCheckProvider::autoCorrectWord.
|
|
registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect,
|
|
command_line->HasSwitch(switches::kEnableSpellingAutoCorrect));
|
|
|
|
return factory.Create(registry.get());
|
|
}
|
|
|
|
CefBrowserPrefStore::~CefBrowserPrefStore() {
|
|
}
|