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

Unified Diff: chrome/browser/tab_contents/language_state.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/language_state.cc
diff --git a/chrome/browser/tab_contents/language_state.cc b/chrome/browser/tab_contents/language_state.cc
index d57c959de39aab62ecbd858abcda7802eb18073a..037980e77169dc481a069fd87c679d346bbb92d0 100644
--- a/chrome/browser/tab_contents/language_state.cc
+++ b/chrome/browser/tab_contents/language_state.cc
@@ -59,20 +59,26 @@ void LanguageState::LanguageDetermined(const std::string& page_language,
current_lang_ = page_language;
}
-std::string LanguageState::AutoTranslateTo() const {
- // Only auto-translate if:
- // - no translation is pending
- // - this page is in the same language as the previous page
- // - the previous page had been translated
- // - this page is not already translated
- // - the new page was navigated through a link.
- if (!translation_pending_ &&
+bool LanguageState::InTranslateNavigation() const {
+ // The user is in the same translate session if
+ // - no translation is pending
+ // - this page is in the same language as the previous page
+ // - the previous page had been translated
+ // - the new page was navigated through a link.
+ return
+ !translation_pending_ &&
prev_original_lang_ == original_lang_ &&
prev_original_lang_ != prev_current_lang_ &&
- original_lang_ == current_lang_ &&
navigation_controller_->GetActiveEntry() &&
navigation_controller_->GetActiveEntry()->GetTransitionType() ==
- content::PAGE_TRANSITION_LINK) {
+ content::PAGE_TRANSITION_LINK;
+}
+
+
+std::string LanguageState::AutoTranslateTo() const {
+ if (InTranslateNavigation() &&
+ // - this page is not already translated
MAD 2013/04/25 15:25:36 missing a period ('.') at the end of the sentence.
Miguel Garcia 2013/04/25 16:17:11 Done.
+ original_lang_ == current_lang_ ) {
return prev_current_lang_;
}

Powered by Google App Engine
This is Rietveld 408576698