| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/spellchecker/spellcheck_service.h" | 5 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/common/spellcheck_common.h" | 22 #include "chrome/common/spellcheck_common.h" |
| 23 #include "chrome/common/spellcheck_messages.h" | 23 #include "chrome/common/spellcheck_messages.h" |
| 24 #include "components/prefs/pref_member.h" | 24 #include "components/prefs/pref_member.h" |
| 25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 26 #include "components/user_prefs/user_prefs.h" | 26 #include "components/user_prefs/user_prefs.h" |
| 27 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 32 #include "content/public/browser/storage_partition.h" |
| 32 #include "ipc/ipc_platform_file.h" | 33 #include "ipc/ipc_platform_file.h" |
| 33 | 34 |
| 34 using content::BrowserThread; | 35 using content::BrowserThread; |
| 35 | 36 |
| 36 // TODO(rlp): I do not like globals, but keeping these for now during | 37 // TODO(rlp): I do not like globals, but keeping these for now during |
| 37 // transition. | 38 // transition. |
| 38 // An event used by browser tests to receive status events from this class and | 39 // An event used by browser tests to receive status events from this class and |
| 39 // its derived classes. | 40 // its derived classes. |
| 40 base::WaitableEvent* g_status_event = NULL; | 41 base::WaitableEvent* g_status_event = NULL; |
| 41 SpellcheckService::EventType g_status_type = | 42 SpellcheckService::EventType g_status_type = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 single_dictionary_pref.SetValue(""); | 81 single_dictionary_pref.SetValue(""); |
| 81 #endif // defined(USE_BROWSER_SPELLCHECKER) | 82 #endif // defined(USE_BROWSER_SPELLCHECKER) |
| 82 | 83 |
| 83 std::string language_code; | 84 std::string language_code; |
| 84 std::string country_code; | 85 std::string country_code; |
| 85 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( | 86 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( |
| 86 first_of_dictionaries, | 87 first_of_dictionaries, |
| 87 &language_code, | 88 &language_code, |
| 88 &country_code); | 89 &country_code); |
| 89 feedback_sender_.reset(new spellcheck::FeedbackSender( | 90 feedback_sender_.reset(new spellcheck::FeedbackSender( |
| 90 context->GetRequestContext(), language_code, country_code)); | 91 content::BrowserContext::GetDefaultStoragePartition(context)-> |
| 92 GetURLRequestContext(), |
| 93 language_code, country_code)); |
| 91 | 94 |
| 92 pref_change_registrar_.Add( | 95 pref_change_registrar_.Add( |
| 93 prefs::kSpellCheckDictionaries, | 96 prefs::kSpellCheckDictionaries, |
| 94 base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged, | 97 base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged, |
| 95 base::Unretained(this))); | 98 base::Unretained(this))); |
| 96 pref_change_registrar_.Add( | 99 pref_change_registrar_.Add( |
| 97 prefs::kSpellCheckUseSpellingService, | 100 prefs::kSpellCheckUseSpellingService, |
| 98 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged, | 101 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged, |
| 99 base::Unretained(this))); | 102 base::Unretained(this))); |
| 100 pref_change_registrar_.Add( | 103 pref_change_registrar_.Add( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 PrefService* prefs = user_prefs::UserPrefs::Get(context_); | 222 PrefService* prefs = user_prefs::UserPrefs::Get(context_); |
| 220 DCHECK(prefs); | 223 DCHECK(prefs); |
| 221 | 224 |
| 222 const base::ListValue* dictionary_values = | 225 const base::ListValue* dictionary_values = |
| 223 prefs->GetList(prefs::kSpellCheckDictionaries); | 226 prefs->GetList(prefs::kSpellCheckDictionaries); |
| 224 | 227 |
| 225 for (const base::Value* dictionary_value : *dictionary_values) { | 228 for (const base::Value* dictionary_value : *dictionary_values) { |
| 226 std::string dictionary; | 229 std::string dictionary; |
| 227 dictionary_value->GetAsString(&dictionary); | 230 dictionary_value->GetAsString(&dictionary); |
| 228 hunspell_dictionaries_.push_back(new SpellcheckHunspellDictionary( | 231 hunspell_dictionaries_.push_back(new SpellcheckHunspellDictionary( |
| 229 dictionary, context_->GetRequestContext(), this)); | 232 dictionary, |
| 233 content::BrowserContext::GetDefaultStoragePartition(context_)-> |
| 234 GetURLRequestContext(), |
| 235 this)); |
| 230 hunspell_dictionaries_.back()->AddObserver(this); | 236 hunspell_dictionaries_.back()->AddObserver(this); |
| 231 hunspell_dictionaries_.back()->Load(); | 237 hunspell_dictionaries_.back()->Load(); |
| 232 } | 238 } |
| 233 } | 239 } |
| 234 | 240 |
| 235 const ScopedVector<SpellcheckHunspellDictionary>& | 241 const ScopedVector<SpellcheckHunspellDictionary>& |
| 236 SpellcheckService::GetHunspellDictionaries() { | 242 SpellcheckService::GetHunspellDictionaries() { |
| 237 return hunspell_dictionaries_; | 243 return hunspell_dictionaries_; |
| 238 } | 244 } |
| 239 | 245 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( | 378 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( |
| 373 feedback_language, &language_code, &country_code); | 379 feedback_language, &language_code, &country_code); |
| 374 feedback_sender_->OnLanguageCountryChange(language_code, country_code); | 380 feedback_sender_->OnLanguageCountryChange(language_code, country_code); |
| 375 if (SpellingServiceClient::IsAvailable( | 381 if (SpellingServiceClient::IsAvailable( |
| 376 context_, SpellingServiceClient::SPELLCHECK)) { | 382 context_, SpellingServiceClient::SPELLCHECK)) { |
| 377 feedback_sender_->StartFeedbackCollection(); | 383 feedback_sender_->StartFeedbackCollection(); |
| 378 } else { | 384 } else { |
| 379 feedback_sender_->StopFeedbackCollection(); | 385 feedback_sender_->StopFeedbackCollection(); |
| 380 } | 386 } |
| 381 } | 387 } |
| OLD | NEW |