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

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
« no previous file with comments | « chrome/browser/tab_contents/language_state.h ('k') | chrome/browser/translate/translate_infobar_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..00fd388fa828a716451ddd43c91b3ab71b4bc667 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() &&
+ // The page is not yet translated.
+ original_lang_ == current_lang_ ) {
return prev_current_lang_;
}
« no previous file with comments | « chrome/browser/tab_contents/language_state.h ('k') | chrome/browser/translate/translate_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698