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

Side by Side Diff: chrome/browser/ui/webui/options/language_options_handler_common.cc

Issue 159883002: Move TranslatePrefs to the Translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@acceptLanguages
Patch Set: Fix ChromeOS browsertests Created 6 years, 10 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/ui/webui/options/language_options_handler_common.h" 5 #include "chrome/browser/ui/webui/options/language_options_handler_common.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/spellchecker/spellcheck_factory.h" 22 #include "chrome/browser/spellchecker/spellcheck_factory.h"
23 #include "chrome/browser/spellchecker/spellcheck_service.h" 23 #include "chrome/browser/spellchecker/spellcheck_service.h"
24 #include "chrome/browser/translate/translate_manager.h" 24 #include "chrome/browser/translate/translate_manager.h"
25 #include "chrome/browser/translate/translate_prefs.h" 25 #include "chrome/browser/translate/translate_tab_helper.h"
26 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "chrome/common/spellcheck_common.h" 29 #include "chrome/common/spellcheck_common.h"
30 #include "components/translate/core/browser/translate_download_manager.h" 30 #include "components/translate/core/browser/translate_download_manager.h"
31 #include "components/translate/core/browser/translate_prefs.h"
31 #include "content/public/browser/user_metrics.h" 32 #include "content/public/browser/user_metrics.h"
32 #include "content/public/browser/web_ui.h" 33 #include "content/public/browser/web_ui.h"
33 #include "grit/chromium_strings.h" 34 #include "grit/chromium_strings.h"
34 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
35 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
36 37
37 using base::UserMetricsAction; 38 using base::UserMetricsAction;
38 39
39 namespace options { 40 namespace options {
40 41
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 257
257 std::vector<std::string> languages; 258 std::vector<std::string> languages;
258 for (base::ListValue::const_iterator it = language_list->begin(); 259 for (base::ListValue::const_iterator it = language_list->begin();
259 it != language_list->end(); ++it) { 260 it != language_list->end(); ++it) {
260 std::string lang; 261 std::string lang;
261 (*it)->GetAsString(&lang); 262 (*it)->GetAsString(&lang);
262 languages.push_back(lang); 263 languages.push_back(lang);
263 } 264 }
264 265
265 Profile* profile = Profile::FromWebUI(web_ui()); 266 Profile* profile = Profile::FromWebUI(web_ui());
266 PrefService* prefs = profile->GetPrefs(); 267 scoped_ptr<TranslatePrefs> translate_prefs =
267 TranslatePrefs translate_prefs(prefs); 268 TranslateTabHelper::CreateTranslatePrefs(profile->GetPrefs());
268 translate_prefs.UpdateLanguageList(languages); 269 translate_prefs->UpdateLanguageList(languages);
269 } 270 }
270 271
271 void LanguageOptionsHandlerCommon::RetrySpellcheckDictionaryDownload( 272 void LanguageOptionsHandlerCommon::RetrySpellcheckDictionaryDownload(
272 const base::ListValue* args) { 273 const base::ListValue* args) {
273 GetHunspellDictionary()->RetryDownloadDictionary( 274 GetHunspellDictionary()->RetryDownloadDictionary(
274 Profile::FromWebUI(web_ui())->GetRequestContext()); 275 Profile::FromWebUI(web_ui())->GetRequestContext());
275 } 276 }
276 277
277 void LanguageOptionsHandlerCommon::RefreshHunspellDictionary() { 278 void LanguageOptionsHandlerCommon::RefreshHunspellDictionary() {
278 if (hunspell_dictionary_.get()) 279 if (hunspell_dictionary_.get())
279 hunspell_dictionary_->RemoveObserver(this); 280 hunspell_dictionary_->RemoveObserver(this);
280 hunspell_dictionary_.reset(); 281 hunspell_dictionary_.reset();
281 SpellcheckService* service = SpellcheckServiceFactory::GetForContext( 282 SpellcheckService* service = SpellcheckServiceFactory::GetForContext(
282 Profile::FromWebUI(web_ui())); 283 Profile::FromWebUI(web_ui()));
283 hunspell_dictionary_ = service->GetHunspellDictionary()->AsWeakPtr(); 284 hunspell_dictionary_ = service->GetHunspellDictionary()->AsWeakPtr();
284 hunspell_dictionary_->AddObserver(this); 285 hunspell_dictionary_->AddObserver(this);
285 } 286 }
286 287
287 base::WeakPtr<SpellcheckHunspellDictionary>& 288 base::WeakPtr<SpellcheckHunspellDictionary>&
288 LanguageOptionsHandlerCommon::GetHunspellDictionary() { 289 LanguageOptionsHandlerCommon::GetHunspellDictionary() {
289 if (!hunspell_dictionary_.get()) 290 if (!hunspell_dictionary_.get())
290 RefreshHunspellDictionary(); 291 RefreshHunspellDictionary();
291 return hunspell_dictionary_; 292 return hunspell_dictionary_;
292 } 293 }
293 294
294 } // namespace options 295 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698