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

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

Issue 2799083004: Implements ApplyTranslateOptions in compact infobar (Closed)
Patch Set: Review comments addressed 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..077cee9c64d457143b3b1ba17b19b24b9d01703c 100644
--- a/chrome/browser/ui/android/infobars/translate_compact_infobar.cc
+++ b/chrome/browser/ui/android/infobars/translate_compact_infobar.cc
@@ -78,10 +78,45 @@ void TranslateCompactInfoBar::SetJavaInfoBar(
reinterpret_cast<intptr_t>(this));
}
-void TranslateCompactInfoBar::ApplyTranslateOptions(
+void TranslateCompactInfoBar::ApplyStringTranslateOption(
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);
+ } else {
+ DCHECK(false);
+ }
+}
+
+void TranslateCompactInfoBar::ApplyBoolTranslateOption(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ int option,
+ jboolean value) {
+ 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();
+ } else {
+ DCHECK(false);
+ }
}
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