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

Side by Side Diff: chrome/browser/ui/android/infobars/translate_compact_infobar.cc

Issue 2838833003: Introduces snackbar enum, & other snackbar classes on android for translate (Closed)
Patch Set: Created 3 years, 7 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/android/translate_utils.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/ui/android/infobars/translate_compact_infobar.h" 5 #include "chrome/browser/ui/android/infobars/translate_compact_infobar.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 } 100 }
101 101
102 void TranslateCompactInfoBar::ApplyBoolTranslateOption( 102 void TranslateCompactInfoBar::ApplyBoolTranslateOption(
103 JNIEnv* env, 103 JNIEnv* env,
104 const JavaParamRef<jobject>& obj, 104 const JavaParamRef<jobject>& obj,
105 int option, 105 int option,
106 jboolean value) { 106 jboolean value) {
107 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); 107 translate::TranslateInfoBarDelegate* delegate = GetDelegate();
108 if (option == TranslateUtils::OPTION_ALWAYS_TRANSLATE) { 108 if (option == TranslateUtils::OPTION_ALWAYS_TRANSLATE) {
109 if (delegate->ShouldAlwaysTranslate() != value) 109 if (delegate->ShouldAlwaysTranslate() != value) {
110 delegate->ToggleAlwaysTranslate(); 110 delegate->ToggleAlwaysTranslate();
111 }
111 } else if (option == TranslateUtils::OPTION_NEVER_TRANSLATE) { 112 } else if (option == TranslateUtils::OPTION_NEVER_TRANSLATE) {
112 if (value && delegate->IsTranslatableLanguageByPrefs()) 113 if (value && delegate->IsTranslatableLanguageByPrefs()) {
113 delegate->ToggleTranslatableLanguageByPrefs(); 114 delegate->ToggleTranslatableLanguageByPrefs();
115 }
114 } else if (option == TranslateUtils::OPTION_NEVER_TRANSLATE_SITE) { 116 } else if (option == TranslateUtils::OPTION_NEVER_TRANSLATE_SITE) {
115 if (value && !delegate->IsSiteBlacklisted()) 117 if (value && !delegate->IsSiteBlacklisted()) {
116 delegate->ToggleSiteBlacklist(); 118 delegate->ToggleSiteBlacklist();
119 }
117 } else { 120 } else {
118 DCHECK(false); 121 DCHECK(false);
119 } 122 }
120 } 123 }
121 124
122 void TranslateCompactInfoBar::OnPageTranslated( 125 void TranslateCompactInfoBar::OnPageTranslated(
123 const std::string& original_lang, 126 const std::string& original_lang,
124 const std::string& translated_lang, 127 const std::string& translated_lang,
125 translate::TranslateErrors::Type error_type) { 128 translate::TranslateErrors::Type error_type) {
126 if (!owner()) 129 if (!owner())
127 return; // We're closing; don't call anything, it might access the owner. 130 return; // We're closing; don't call anything, it might access the owner.
128 131
129 DCHECK(translate_driver_); 132 DCHECK(translate_driver_);
130 JNIEnv* env = base::android::AttachCurrentThread(); 133 JNIEnv* env = base::android::AttachCurrentThread();
131 Java_TranslateCompactInfoBar_onPageTranslated(env, GetJavaInfoBar(), 134 Java_TranslateCompactInfoBar_onPageTranslated(env, GetJavaInfoBar(),
132 error_type); 135 error_type);
133 } 136 }
134 137
135 translate::TranslateInfoBarDelegate* TranslateCompactInfoBar::GetDelegate() { 138 translate::TranslateInfoBarDelegate* TranslateCompactInfoBar::GetDelegate() {
136 return delegate()->AsTranslateInfoBarDelegate(); 139 return delegate()->AsTranslateInfoBarDelegate();
137 } 140 }
138 141
139 // Native JNI methods --------------------------------------------------------- 142 // Native JNI methods ---------------------------------------------------------
140 143
141 // static 144 // static
142 bool RegisterTranslateCompactInfoBar(JNIEnv* env) { 145 bool RegisterTranslateCompactInfoBar(JNIEnv* env) {
143 return RegisterNativesImpl(env); 146 return RegisterNativesImpl(env);
144 } 147 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/android/translate_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698