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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_service.cc

Issue 1878153002: Revert of Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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
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"
33 #include "ipc/ipc_platform_file.h" 32 #include "ipc/ipc_platform_file.h"
34 33
35 using content::BrowserThread; 34 using content::BrowserThread;
36 35
37 // TODO(rlp): I do not like globals, but keeping these for now during 36 // TODO(rlp): I do not like globals, but keeping these for now during
38 // transition. 37 // transition.
39 // An event used by browser tests to receive status events from this class and 38 // An event used by browser tests to receive status events from this class and
40 // its derived classes. 39 // its derived classes.
41 base::WaitableEvent* g_status_event = NULL; 40 base::WaitableEvent* g_status_event = NULL;
42 SpellcheckService::EventType g_status_type = 41 SpellcheckService::EventType g_status_type =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 single_dictionary_pref.SetValue(""); 80 single_dictionary_pref.SetValue("");
82 #endif // defined(USE_BROWSER_SPELLCHECKER) 81 #endif // defined(USE_BROWSER_SPELLCHECKER)
83 82
84 std::string language_code; 83 std::string language_code;
85 std::string country_code; 84 std::string country_code;
86 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( 85 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale(
87 first_of_dictionaries, 86 first_of_dictionaries,
88 &language_code, 87 &language_code,
89 &country_code); 88 &country_code);
90 feedback_sender_.reset(new spellcheck::FeedbackSender( 89 feedback_sender_.reset(new spellcheck::FeedbackSender(
91 content::BrowserContext::GetDefaultStoragePartition(context)-> 90 context->GetRequestContext(), language_code, country_code));
92 GetURLRequestContext(),
93 language_code, country_code));
94 91
95 pref_change_registrar_.Add( 92 pref_change_registrar_.Add(
96 prefs::kSpellCheckDictionaries, 93 prefs::kSpellCheckDictionaries,
97 base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged, 94 base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged,
98 base::Unretained(this))); 95 base::Unretained(this)));
99 pref_change_registrar_.Add( 96 pref_change_registrar_.Add(
100 prefs::kSpellCheckUseSpellingService, 97 prefs::kSpellCheckUseSpellingService,
101 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged, 98 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged,
102 base::Unretained(this))); 99 base::Unretained(this)));
103 pref_change_registrar_.Add( 100 pref_change_registrar_.Add(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 PrefService* prefs = user_prefs::UserPrefs::Get(context_); 219 PrefService* prefs = user_prefs::UserPrefs::Get(context_);
223 DCHECK(prefs); 220 DCHECK(prefs);
224 221
225 const base::ListValue* dictionary_values = 222 const base::ListValue* dictionary_values =
226 prefs->GetList(prefs::kSpellCheckDictionaries); 223 prefs->GetList(prefs::kSpellCheckDictionaries);
227 224
228 for (const base::Value* dictionary_value : *dictionary_values) { 225 for (const base::Value* dictionary_value : *dictionary_values) {
229 std::string dictionary; 226 std::string dictionary;
230 dictionary_value->GetAsString(&dictionary); 227 dictionary_value->GetAsString(&dictionary);
231 hunspell_dictionaries_.push_back(new SpellcheckHunspellDictionary( 228 hunspell_dictionaries_.push_back(new SpellcheckHunspellDictionary(
232 dictionary, 229 dictionary, context_->GetRequestContext(), this));
233 content::BrowserContext::GetDefaultStoragePartition(context_)->
234 GetURLRequestContext(),
235 this));
236 hunspell_dictionaries_.back()->AddObserver(this); 230 hunspell_dictionaries_.back()->AddObserver(this);
237 hunspell_dictionaries_.back()->Load(); 231 hunspell_dictionaries_.back()->Load();
238 } 232 }
239 } 233 }
240 234
241 const ScopedVector<SpellcheckHunspellDictionary>& 235 const ScopedVector<SpellcheckHunspellDictionary>&
242 SpellcheckService::GetHunspellDictionaries() { 236 SpellcheckService::GetHunspellDictionaries() {
243 return hunspell_dictionaries_; 237 return hunspell_dictionaries_;
244 } 238 }
245 239
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( 372 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale(
379 feedback_language, &language_code, &country_code); 373 feedback_language, &language_code, &country_code);
380 feedback_sender_->OnLanguageCountryChange(language_code, country_code); 374 feedback_sender_->OnLanguageCountryChange(language_code, country_code);
381 if (SpellingServiceClient::IsAvailable( 375 if (SpellingServiceClient::IsAvailable(
382 context_, SpellingServiceClient::SPELLCHECK)) { 376 context_, SpellingServiceClient::SPELLCHECK)) {
383 feedback_sender_->StartFeedbackCollection(); 377 feedback_sender_->StartFeedbackCollection();
384 } else { 378 } else {
385 feedback_sender_->StopFeedbackCollection(); 379 feedback_sender_->StopFeedbackCollection();
386 } 380 }
387 } 381 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_fetcher_factory.cc ('k') | chrome/browser/spellchecker/spelling_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698