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

Side by Side Diff: chrome/browser/translate/translate_infobar_delegate.cc

Issue 23923007: Bug fix: Append a language to the list after blocking it for Translate on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 7 years, 3 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/translate/translate_infobar_delegate.h" 5 #include "chrome/browser/translate/translate_infobar_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/string_compare.h" 9 #include "base/i18n/string_compare.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 void TranslateInfoBarDelegate::AlwaysTranslatePageLanguage() { 204 void TranslateInfoBarDelegate::AlwaysTranslatePageLanguage() {
205 const std::string& original_lang = original_language_code(); 205 const std::string& original_lang = original_language_code();
206 const std::string& target_lang = target_language_code(); 206 const std::string& target_lang = target_language_code();
207 DCHECK(!prefs_.IsLanguagePairWhitelisted(original_lang, target_lang)); 207 DCHECK(!prefs_.IsLanguagePairWhitelisted(original_lang, target_lang));
208 prefs_.WhitelistLanguagePair(original_lang, target_lang); 208 prefs_.WhitelistLanguagePair(original_lang, target_lang);
209 Translate(); 209 Translate();
210 } 210 }
211 211
212 void TranslateInfoBarDelegate::NeverTranslatePageLanguage() { 212 void TranslateInfoBarDelegate::NeverTranslatePageLanguage() {
213 std::string original_lang = original_language_code(); 213 std::string original_lang = original_language_code();
214 DCHECK(!prefs_.IsBlockedLanguage(original_lang)); 214
215 // Don't use DCHECK(...) to check if the language is listed in the blocked
Evan Stade 2013/09/12 22:53:41 this comment seems pretty long to explain why a th
hajimehoshi 2013/09/13 01:39:19 Ok, I'll write the explanation at the description
216 // language list here because the language might already be listed. For
217 // example:
218 // 1. After the user add the language, he/she removes the language from
219 // chrome://settings/languages. In this case, Translate infobar will
220 // appear.
221 // 2. While the Translate infobar is shown, the user can change if Translate
222 // should be offered in the language. In this case, the user can push
223 // "Never Translate (language)" button while the language is already
224 // blocked.
215 prefs_.BlockLanguage(original_lang); 225 prefs_.BlockLanguage(original_lang);
216 RemoveSelf(); 226 RemoveSelf();
217 } 227 }
218 228
219 string16 TranslateInfoBarDelegate::GetMessageInfoBarText() { 229 string16 TranslateInfoBarDelegate::GetMessageInfoBarText() {
220 if (infobar_type_ == TRANSLATING) { 230 if (infobar_type_ == TRANSLATING) {
221 return l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_TRANSLATING_TO, 231 return l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_TRANSLATING_TO,
222 language_name_at(target_language_index_)); 232 language_name_at(target_language_index_));
223 } 233 }
224 234
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 435
426 TranslateInfoBarDelegate* 436 TranslateInfoBarDelegate*
427 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 437 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
428 return this; 438 return this;
429 } 439 }
430 440
431 std::string TranslateInfoBarDelegate::GetPageHost() { 441 std::string TranslateInfoBarDelegate::GetPageHost() {
432 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); 442 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry();
433 return entry ? entry->GetURL().HostNoBrackets() : std::string(); 443 return entry ? entry->GetURL().HostNoBrackets() : std::string();
434 } 444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698