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

Unified Diff: chrome/browser/ui/android/infobars/translate_compact_infobar.cc

Issue 2799083004: Implements ApplyTranslateOptions in compact infobar (Closed)
Patch Set: a Created 3 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/ui/android/infobars/translate_compact_infobar.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/android/infobars/translate_compact_infobar.cc
diff --git a/chrome/browser/ui/android/infobars/translate_compact_infobar.cc b/chrome/browser/ui/android/infobars/translate_compact_infobar.cc
index 2e08dfe5e1d749a7d5bec4dfe63781998416c049..148747a83174ae3ba61226110e381fb7f3130a0e 100644
--- a/chrome/browser/ui/android/infobars/translate_compact_infobar.cc
+++ b/chrome/browser/ui/android/infobars/translate_compact_infobar.cc
@@ -78,10 +78,41 @@ void TranslateCompactInfoBar::SetJavaInfoBar(
reinterpret_cast<intptr_t>(this));
}
-void TranslateCompactInfoBar::ApplyTranslateOptions(
+void TranslateCompactInfoBar::ApplyStringTranslateOptions(
gone 2017/04/12 16:16:07 You're only applying one option. Don't pluralize
ramyasharma 2017/04/13 04:04:07 Done.
JNIEnv* env,
- const JavaParamRef<jobject>& obj) {
- // TODO(ramyasharma): Implement.
+ const JavaParamRef<jobject>& obj,
+ int option,
+ const JavaParamRef<jstring>& value) {
+ translate::TranslateInfoBarDelegate* delegate = GetDelegate();
+ if (option == TranslateUtils::OPTION_SOURCE_CODE) {
+ std::string source_code =
+ base::android::ConvertJavaStringToUTF8(env, value);
+ if (delegate->original_language_code().compare(source_code) != 0)
+ delegate->UpdateOriginalLanguage(source_code);
+ } else if (option == TranslateUtils::OPTION_TARGET_CODE) {
+ std::string target_code =
+ base::android::ConvertJavaStringToUTF8(env, value);
+ if (delegate->target_language_code().compare(target_code) != 0)
+ delegate->UpdateTargetLanguage(target_code);
+ }
gone 2017/04/12 16:16:08 DCHECK in the else clause to prevent this function
ramyasharma 2017/04/13 04:04:07 Done.
+}
+
+void TranslateCompactInfoBar::ApplyBoolTranslateOptions(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ int option,
+ bool value) {
gone 2017/04/12 16:16:08 I think this is supposed to be a jboolean, for con
ramyasharma 2017/04/13 04:04:07 Done.
+ translate::TranslateInfoBarDelegate* delegate = GetDelegate();
+ if (option == TranslateUtils::OPTION_ALWAYS_TRANSLATE) {
+ if (delegate->ShouldAlwaysTranslate() != value)
+ delegate->ToggleAlwaysTranslate();
+ } else if (option == TranslateUtils::OPTION_NEVER_TRANSLATE) {
+ if (value && delegate->IsTranslatableLanguageByPrefs())
+ delegate->ToggleTranslatableLanguageByPrefs();
+ } else if (option == TranslateUtils::OPTION_NEVER_TRANSLATE_SITE) {
+ if (value && !delegate->IsSiteBlacklisted())
+ delegate->ToggleSiteBlacklist();
+ }
gone 2017/04/12 16:16:08 Ditto about else clause.
ramyasharma 2017/04/13 04:04:07 Thanks good idea. Done.
}
void TranslateCompactInfoBar::OnPageTranslated(
« no previous file with comments | « chrome/browser/ui/android/infobars/translate_compact_infobar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698