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

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

Issue 14392011: [Translate] Expose whether the user is within a navigation session as part of the infobar delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
« no previous file with comments | « chrome/browser/translate/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // translations when getting a LANGUAGE_DETERMINED from the page, which 106 // translations when getting a LANGUAGE_DETERMINED from the page, which
107 // happens when a load stops. That could happen multiple times, including 107 // happens when a load stops. That could happen multiple times, including
108 // after the user already declined the translation.) 108 // after the user already declined the translation.)
109 TranslateTabHelper* translate_tab_helper = 109 TranslateTabHelper* translate_tab_helper =
110 TranslateTabHelper::FromWebContents(web_contents()); 110 TranslateTabHelper::FromWebContents(web_contents());
111 translate_tab_helper->language_state().set_translation_declined(true); 111 translate_tab_helper->language_state().set_translation_declined(true);
112 112
113 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1); 113 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1);
114 } 114 }
115 115
116 bool TranslateInfoBarDelegate::InTranslateNavigation() {
117 TranslateTabHelper* translate_tab_helper =
118 TranslateTabHelper::FromWebContents(web_contents());
119 if (!translate_tab_helper)
120 return false;
121 return translate_tab_helper->language_state().InTranslateNavigation();
122 }
123
116 bool TranslateInfoBarDelegate::IsLanguageBlacklisted() { 124 bool TranslateInfoBarDelegate::IsLanguageBlacklisted() {
117 return prefs_.IsLanguageBlacklisted(original_language_code()); 125 return prefs_.IsLanguageBlacklisted(original_language_code());
118 } 126 }
119 127
120 void TranslateInfoBarDelegate::ToggleLanguageBlacklist() { 128 void TranslateInfoBarDelegate::ToggleLanguageBlacklist() {
121 const std::string& original_lang = original_language_code(); 129 const std::string& original_lang = original_language_code();
122 if (prefs_.IsLanguageBlacklisted(original_lang)) { 130 if (prefs_.IsLanguageBlacklisted(original_lang)) {
123 prefs_.RemoveLanguageFromBlacklist(original_lang); 131 prefs_.RemoveLanguageFromBlacklist(original_lang);
124 } else { 132 } else {
125 prefs_.BlacklistLanguage(original_lang); 133 prefs_.BlacklistLanguage(original_lang);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 380
373 TranslateInfoBarDelegate* 381 TranslateInfoBarDelegate*
374 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 382 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
375 return this; 383 return this;
376 } 384 }
377 385
378 std::string TranslateInfoBarDelegate::GetPageHost() { 386 std::string TranslateInfoBarDelegate::GetPageHost() {
379 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); 387 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry();
380 return entry ? entry->GetURL().HostNoBrackets() : std::string(); 388 return entry ? entry->GetURL().HostNoBrackets() : std::string();
381 } 389 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698