summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc')
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
index b6ebae0b7aa..a115023dc3a 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
@@ -19,8 +19,10 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
+#ifndef TOOLKIT_QT
#include "chrome/common/chrome_paths.h"
#include "components/data_use_measurement/core/data_use_user_data.h"
+#endif
#include "components/spellcheck/browser/spellcheck_platform.h"
#include "components/spellcheck/common/spellcheck_common.h"
#include "components/spellcheck/spellcheck_build_features.h"
@@ -59,7 +61,7 @@ bool SaveDictionaryData(std::unique_ptr<std::string> data,
bool success = false;
#if defined(OS_WIN)
base::FilePath dict_dir;
- PathService::Get(chrome::DIR_USER_DATA, &dict_dir);
+ PathService::Get(base::DIR_USER_DATA, &dict_dir);
base::FilePath fallback_file_path =
dict_dir.Append(path.BaseName());
bytes_written =
@@ -277,8 +279,10 @@ void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) {
fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this,
traffic_annotation);
+#ifndef TOOLKIT_QT
data_use_measurement::DataUseUserData::AttachToFetcher(
fetcher_.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER);
+#endif
fetcher_->SetRequestContext(request_context_getter_);
fetcher_->SetLoadFlags(
net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
@@ -305,7 +309,7 @@ SpellcheckHunspellDictionary::OpenDictionaryFile(const base::FilePath& path) {
// Check if the dictionary exists in the fallback location. If so, use it
// rather than downloading anew.
base::FilePath user_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_dir);
+ PathService::Get(base::DIR_USER_DATA, &user_dir);
base::FilePath fallback = user_dir.Append(path.BaseName());
if (!base::PathExists(path) && base::PathExists(fallback))
dictionary.path = fallback;
@@ -334,14 +338,16 @@ SpellcheckHunspellDictionary::OpenDictionaryFile(const base::FilePath& path) {
dictionary.file.Initialize(dictionary.path,
base::File::FLAG_READ | base::File::FLAG_OPEN);
} else {
+#ifndef TOOLKIT_QT
base::DeleteFile(dictionary.path, false);
+#endif
}
return dictionary;
}
// The default place where the spellcheck dictionary resides is
-// chrome::DIR_APP_DICTIONARIES.
+// base::DIR_APP_DICTIONARIES.
//
// static
SpellcheckHunspellDictionary::DictionaryFile
@@ -353,7 +359,7 @@ SpellcheckHunspellDictionary::InitializeDictionaryLocation(
// sequence because it checks if there is a "Dictionaries" directory and
// create it.
base::FilePath dict_dir;
- PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir);
+ PathService::Get(base::DIR_APP_DICTIONARIES, &dict_dir);
base::FilePath dict_path =
spellcheck::GetVersionedFileName(language, dict_dir);
@@ -364,7 +370,7 @@ void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete(
DictionaryFile file) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
dictionary_file_ = std::move(file);
-
+#ifndef TOOLKIT_QT
if (!dictionary_file_.file.IsValid()) {
// Notify browser tests that this dictionary is corrupted. Skip downloading
// the dictionary in browser tests.
@@ -383,6 +389,13 @@ void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete(
}
InformListenersOfInitialization();
+#else
+ if (!dictionary_file_.file.IsValid())
+ // We never download, so safe to reuse this handler
+ InformListenersOfDownloadFailure();
+ else
+ InformListenersOfInitialization();
+#endif
}
void SpellcheckHunspellDictionary::SaveDictionaryDataComplete(