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

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

Issue 378253002: Fix translate namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing android build errors Created 6 years, 5 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>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 enable_spelling_auto_correct); 125 enable_spelling_auto_correct);
126 126
127 Profile* profile = Profile::FromWebUI(web_ui()); 127 Profile* profile = Profile::FromWebUI(web_ui());
128 PrefService* prefs = profile->GetPrefs(); 128 PrefService* prefs = profile->GetPrefs();
129 std::string default_target_language = 129 std::string default_target_language =
130 TranslateService::GetTargetLanguage(prefs); 130 TranslateService::GetTargetLanguage(prefs);
131 localized_strings->SetString("defaultTargetLanguage", 131 localized_strings->SetString("defaultTargetLanguage",
132 default_target_language); 132 default_target_language);
133 133
134 std::vector<std::string> languages; 134 std::vector<std::string> languages;
135 TranslateDownloadManager::GetSupportedLanguages(&languages); 135 translate::TranslateDownloadManager::GetSupportedLanguages(&languages);
136 136
137 base::ListValue* languages_list = new base::ListValue(); 137 base::ListValue* languages_list = new base::ListValue();
138 for (std::vector<std::string>::iterator it = languages.begin(); 138 for (std::vector<std::string>::iterator it = languages.begin();
139 it != languages.end(); ++it) { 139 it != languages.end(); ++it) {
140 languages_list->Append(new base::StringValue(*it)); 140 languages_list->Append(new base::StringValue(*it));
141 } 141 }
142 142
143 localized_strings->Set("translateSupportedLanguages", languages_list); 143 localized_strings->Set("translateSupportedLanguages", languages_list);
144 } 144 }
145 145
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 std::vector<std::string> languages; 260 std::vector<std::string> languages;
261 for (base::ListValue::const_iterator it = language_list->begin(); 261 for (base::ListValue::const_iterator it = language_list->begin();
262 it != language_list->end(); ++it) { 262 it != language_list->end(); ++it) {
263 std::string lang; 263 std::string lang;
264 (*it)->GetAsString(&lang); 264 (*it)->GetAsString(&lang);
265 languages.push_back(lang); 265 languages.push_back(lang);
266 } 266 }
267 267
268 Profile* profile = Profile::FromWebUI(web_ui()); 268 Profile* profile = Profile::FromWebUI(web_ui());
269 scoped_ptr<TranslatePrefs> translate_prefs = 269 scoped_ptr<translate::TranslatePrefs> translate_prefs =
270 ChromeTranslateClient::CreateTranslatePrefs(profile->GetPrefs()); 270 ChromeTranslateClient::CreateTranslatePrefs(profile->GetPrefs());
271 translate_prefs->UpdateLanguageList(languages); 271 translate_prefs->UpdateLanguageList(languages);
272 } 272 }
273 273
274 void LanguageOptionsHandlerCommon::RetrySpellcheckDictionaryDownload( 274 void LanguageOptionsHandlerCommon::RetrySpellcheckDictionaryDownload(
275 const base::ListValue* args) { 275 const base::ListValue* args) {
276 GetHunspellDictionary()->RetryDownloadDictionary( 276 GetHunspellDictionary()->RetryDownloadDictionary(
277 Profile::FromWebUI(web_ui())->GetRequestContext()); 277 Profile::FromWebUI(web_ui())->GetRequestContext());
278 } 278 }
279 279
280 void LanguageOptionsHandlerCommon::RefreshHunspellDictionary() { 280 void LanguageOptionsHandlerCommon::RefreshHunspellDictionary() {
281 if (hunspell_dictionary_.get()) 281 if (hunspell_dictionary_.get())
282 hunspell_dictionary_->RemoveObserver(this); 282 hunspell_dictionary_->RemoveObserver(this);
283 hunspell_dictionary_.reset(); 283 hunspell_dictionary_.reset();
284 SpellcheckService* service = SpellcheckServiceFactory::GetForContext( 284 SpellcheckService* service = SpellcheckServiceFactory::GetForContext(
285 Profile::FromWebUI(web_ui())); 285 Profile::FromWebUI(web_ui()));
286 hunspell_dictionary_ = service->GetHunspellDictionary()->AsWeakPtr(); 286 hunspell_dictionary_ = service->GetHunspellDictionary()->AsWeakPtr();
287 hunspell_dictionary_->AddObserver(this); 287 hunspell_dictionary_->AddObserver(this);
288 } 288 }
289 289
290 base::WeakPtr<SpellcheckHunspellDictionary>& 290 base::WeakPtr<SpellcheckHunspellDictionary>&
291 LanguageOptionsHandlerCommon::GetHunspellDictionary() { 291 LanguageOptionsHandlerCommon::GetHunspellDictionary() {
292 if (!hunspell_dictionary_.get()) 292 if (!hunspell_dictionary_.get())
293 RefreshHunspellDictionary(); 293 RefreshHunspellDictionary();
294 return hunspell_dictionary_; 294 return hunspell_dictionary_;
295 } 295 }
296 296
297 } // namespace options 297 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698