| OLD | NEW |
| 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 package org.chromium.chrome.browser.infobar; | 5 package org.chromium.chrome.browser.infobar; |
| 6 | 6 |
| 7 import android.support.design.widget.TabLayout; | 7 import android.support.design.widget.TabLayout; |
| 8 import android.view.LayoutInflater; | 8 import android.view.LayoutInflater; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.view.View.OnClickListener; | 10 import android.view.View.OnClickListener; |
| 11 import android.view.View.OnLayoutChangeListener; |
| 11 import android.widget.LinearLayout; | 12 import android.widget.LinearLayout; |
| 12 | 13 |
| 13 import org.chromium.base.annotations.CalledByNative; | 14 import org.chromium.base.annotations.CalledByNative; |
| 14 import org.chromium.base.metrics.RecordHistogram; | 15 import org.chromium.base.metrics.RecordHistogram; |
| 15 import org.chromium.chrome.R; | 16 import org.chromium.chrome.R; |
| 16 import org.chromium.chrome.browser.infobar.translate.TranslateMenu; | 17 import org.chromium.chrome.browser.infobar.translate.TranslateMenu; |
| 17 import org.chromium.chrome.browser.infobar.translate.TranslateMenuHelper; | 18 import org.chromium.chrome.browser.infobar.translate.TranslateMenuHelper; |
| 18 import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout; | 19 import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout; |
| 19 import org.chromium.chrome.browser.snackbar.Snackbar; | 20 import org.chromium.chrome.browser.snackbar.Snackbar; |
| 20 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 21 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
| 21 import org.chromium.chrome.browser.widget.TintedImageButton; | 22 import org.chromium.chrome.browser.widget.TintedImageButton; |
| 22 import org.chromium.ui.widget.Toast; | 23 import org.chromium.ui.widget.Toast; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Java version of the compact translate infobar. | 26 * Java version of the compact translate infobar. |
| 26 */ | 27 */ |
| 27 class TranslateCompactInfoBar extends InfoBar implements TabLayout.OnTabSelected
Listener, | 28 class TranslateCompactInfoBar extends InfoBar |
| 28 TranslateMenuHelper.Tra
nslateMenuListener, | 29 implements TabLayout.OnTabSelectedListener, TranslateMenuHelper.Translat
eMenuListener { |
| 29 View.OnLayoutChangeList
ener { | |
| 30 public static final int TRANSLATING_INFOBAR = 1; | 30 public static final int TRANSLATING_INFOBAR = 1; |
| 31 | 31 |
| 32 private static final int SOURCE_TAB_INDEX = 0; | 32 private static final int SOURCE_TAB_INDEX = 0; |
| 33 private static final int TARGET_TAB_INDEX = 1; | 33 private static final int TARGET_TAB_INDEX = 1; |
| 34 | 34 |
| 35 // Action ID for Snackbar. | 35 // Action ID for Snackbar. |
| 36 // Actions performed by clicking on on the overflow menu. | 36 // Actions performed by clicking on on the overflow menu. |
| 37 public static final int ACTION_OVERFLOW_ALWAYS_TRANSLATE = 0; | 37 public static final int ACTION_OVERFLOW_ALWAYS_TRANSLATE = 0; |
| 38 public static final int ACTION_OVERFLOW_NEVER_SITE = 1; | 38 public static final int ACTION_OVERFLOW_NEVER_SITE = 1; |
| 39 public static final int ACTION_OVERFLOW_NEVER_LANGUAGE = 2; | 39 public static final int ACTION_OVERFLOW_NEVER_LANGUAGE = 2; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 private static final int INFOBAR_SNACKBAR_AUTO_NEVER_IMPRESSION = 22; | 95 private static final int INFOBAR_SNACKBAR_AUTO_NEVER_IMPRESSION = 22; |
| 96 private static final int INFOBAR_SNACKBAR_CANCEL_AUTO_ALWAYS = 23; | 96 private static final int INFOBAR_SNACKBAR_CANCEL_AUTO_ALWAYS = 23; |
| 97 private static final int INFOBAR_SNACKBAR_CANCEL_AUTO_NEVER = 24; | 97 private static final int INFOBAR_SNACKBAR_CANCEL_AUTO_NEVER = 24; |
| 98 private static final int INFOBAR_HISTOGRAM_BOUNDARY = 25; | 98 private static final int INFOBAR_HISTOGRAM_BOUNDARY = 25; |
| 99 | 99 |
| 100 // Need 2 instances of TranslateMenuHelper to prevent a race condition bug w
hich happens when | 100 // Need 2 instances of TranslateMenuHelper to prevent a race condition bug w
hich happens when |
| 101 // showing language menu after dismissing overflow menu. | 101 // showing language menu after dismissing overflow menu. |
| 102 private TranslateMenuHelper mOverflowMenuHelper; | 102 private TranslateMenuHelper mOverflowMenuHelper; |
| 103 private TranslateMenuHelper mLanguageMenuHelper; | 103 private TranslateMenuHelper mLanguageMenuHelper; |
| 104 private TintedImageButton mMenuButton; | 104 private TintedImageButton mMenuButton; |
| 105 private boolean mUserInteracted; | 105 |
| 106 private boolean mMenuExpanded; |
| 106 | 107 |
| 107 /** The controller for translate UI snackbars. */ | 108 /** The controller for translate UI snackbars. */ |
| 108 class TranslateSnackbarController implements SnackbarController { | 109 class TranslateSnackbarController implements SnackbarController { |
| 109 private final int mActionId; | 110 private final int mActionId; |
| 110 | 111 |
| 111 public TranslateSnackbarController(int actionId) { | 112 public TranslateSnackbarController(int actionId) { |
| 112 mActionId = actionId; | 113 mActionId = actionId; |
| 113 } | 114 } |
| 114 | 115 |
| 115 @Override | 116 @Override |
| (...skipping 10 matching lines...) Expand all Loading... |
| 126 case ACTION_AUTO_ALWAYS_TRANSLATE: | 127 case ACTION_AUTO_ALWAYS_TRANSLATE: |
| 127 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_AUTO_ALWAYS); | 128 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_AUTO_ALWAYS); |
| 128 return; | 129 return; |
| 129 case ACTION_OVERFLOW_NEVER_LANGUAGE: | 130 case ACTION_OVERFLOW_NEVER_LANGUAGE: |
| 130 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_NEVER); | 131 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_NEVER); |
| 131 return; | 132 return; |
| 132 case ACTION_AUTO_NEVER_LANGUAGE: | 133 case ACTION_AUTO_NEVER_LANGUAGE: |
| 133 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_AUTO_NEVER); | 134 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_AUTO_NEVER); |
| 134 // This snackbar is triggered automatically after a close bu
tton click. Need to | 135 // This snackbar is triggered automatically after a close bu
tton click. Need to |
| 135 // dismiss the infobar even if the user cancels the "Never T
ranslate". | 136 // dismiss the infobar even if the user cancels the "Never T
ranslate". |
| 136 performCloseButtonActionWithoutDeniedCheck(); | 137 closeInfobar(false); |
| 137 return; | 138 return; |
| 138 case ACTION_OVERFLOW_NEVER_SITE: | 139 case ACTION_OVERFLOW_NEVER_SITE: |
| 139 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_NEVER_SITE); | 140 recordInfobarAction(INFOBAR_SNACKBAR_CANCEL_NEVER_SITE); |
| 140 return; | 141 return; |
| 141 default: | 142 default: |
| 142 assert false : "Unsupported Menu Item Id, when handling snac
kbar action"; | 143 assert false : "Unsupported Menu Item Id, when handling snac
kbar action"; |
| 143 return; | 144 return; |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 }; | 147 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 169 return true; | 170 return true; |
| 170 } | 171 } |
| 171 | 172 |
| 172 @Override | 173 @Override |
| 173 protected void createCompactLayoutContent(InfoBarCompactLayout parent) { | 174 protected void createCompactLayoutContent(InfoBarCompactLayout parent) { |
| 174 LinearLayout content = | 175 LinearLayout content = |
| 175 (LinearLayout) LayoutInflater.from(getContext()) | 176 (LinearLayout) LayoutInflater.from(getContext()) |
| 176 .inflate(R.layout.infobar_translate_compact_content, par
ent, false); | 177 .inflate(R.layout.infobar_translate_compact_content, par
ent, false); |
| 177 | 178 |
| 178 mTabLayout = (TranslateTabLayout) content.findViewById(R.id.translate_in
fobar_tabs); | 179 mTabLayout = (TranslateTabLayout) content.findViewById(R.id.translate_in
fobar_tabs); |
| 179 mTabLayout.addOnLayoutChangeListener(this); | |
| 180 mTabLayout.addTabs(mOptions.sourceLanguageName(), mOptions.targetLanguag
eName()); | 180 mTabLayout.addTabs(mOptions.sourceLanguageName(), mOptions.targetLanguag
eName()); |
| 181 | 181 |
| 182 // Set translating status in the beginning for pages translated automati
cally. | 182 // Set translating status in the beginning for pages translated automati
cally. |
| 183 if (mInitialStep == TRANSLATING_INFOBAR) { | 183 if (mInitialStep == TRANSLATING_INFOBAR) { |
| 184 mTabLayout.getTabAt(TARGET_TAB_INDEX).select(); | 184 mTabLayout.getTabAt(TARGET_TAB_INDEX).select(); |
| 185 mTabLayout.showProgressBarOnTab(TARGET_TAB_INDEX); | 185 mTabLayout.showProgressBarOnTab(TARGET_TAB_INDEX); |
| 186 mUserInteracted = true; | |
| 187 } | 186 } |
| 188 | 187 |
| 189 mTabLayout.addOnTabSelectedListener(this); | 188 mTabLayout.addOnTabSelectedListener(this); |
| 190 | 189 |
| 190 // Dismiss all menus when there is layout changed. (which will cause men
u misplacement.) |
| 191 mTabLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() { |
| 192 @Override |
| 193 public void onLayoutChange(View v, int left, int top, int right, int
bottom, |
| 194 int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| 195 dismissMenus(); |
| 196 } |
| 197 }); |
| 198 |
| 191 mMenuButton = (TintedImageButton) content.findViewById(R.id.translate_in
fobar_menu_button); | 199 mMenuButton = (TintedImageButton) content.findViewById(R.id.translate_in
fobar_menu_button); |
| 192 mMenuButton.setOnClickListener(new OnClickListener() { | 200 mMenuButton.setOnClickListener(new OnClickListener() { |
| 193 @Override | 201 @Override |
| 194 public void onClick(View v) { | 202 public void onClick(View v) { |
| 195 recordInfobarAction(INFOBAR_OPTIONS); | 203 recordInfobarAction(INFOBAR_OPTIONS); |
| 196 initMenuHelper(TranslateMenu.MENU_OVERFLOW); | 204 initMenuHelper(TranslateMenu.MENU_OVERFLOW); |
| 197 mOverflowMenuHelper.show(TranslateMenu.MENU_OVERFLOW); | 205 mOverflowMenuHelper.show(TranslateMenu.MENU_OVERFLOW); |
| 206 mMenuExpanded = true; |
| 198 } | 207 } |
| 199 }); | 208 }); |
| 200 | 209 |
| 201 parent.addContent(content, 1.0f); | 210 parent.addContent(content, 1.0f); |
| 202 } | 211 } |
| 203 | 212 |
| 204 private void initMenuHelper(int menuType) { | 213 private void initMenuHelper(int menuType) { |
| 205 switch (menuType) { | 214 switch (menuType) { |
| 206 case TranslateMenu.MENU_OVERFLOW: | 215 case TranslateMenu.MENU_OVERFLOW: |
| 207 if (mOverflowMenuHelper == null) { | 216 if (mOverflowMenuHelper == null) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 219 default: | 228 default: |
| 220 assert false : "Unsupported Menu Item Id"; | 229 assert false : "Unsupported Menu Item Id"; |
| 221 } | 230 } |
| 222 } | 231 } |
| 223 | 232 |
| 224 private void startTranslating(int tabPosition) { | 233 private void startTranslating(int tabPosition) { |
| 225 if (TARGET_TAB_INDEX == tabPosition) { | 234 if (TARGET_TAB_INDEX == tabPosition) { |
| 226 // Already on the target tab. | 235 // Already on the target tab. |
| 227 mTabLayout.showProgressBarOnTab(TARGET_TAB_INDEX); | 236 mTabLayout.showProgressBarOnTab(TARGET_TAB_INDEX); |
| 228 onButtonClicked(ActionType.TRANSLATE); | 237 onButtonClicked(ActionType.TRANSLATE); |
| 229 mUserInteracted = true; | |
| 230 } else { | 238 } else { |
| 231 mTabLayout.getTabAt(TARGET_TAB_INDEX).select(); | 239 mTabLayout.getTabAt(TARGET_TAB_INDEX).select(); |
| 232 } | 240 } |
| 233 } | 241 } |
| 234 | 242 |
| 235 @CalledByNative | 243 @CalledByNative |
| 236 private void onPageTranslated(int errorType) { | 244 private void onPageTranslated(int errorType) { |
| 237 incrementAndRecordTranslationsPerPageCount(); | 245 incrementAndRecordTranslationsPerPageCount(); |
| 238 if (mTabLayout != null) { | 246 if (mTabLayout != null) { |
| 239 mTabLayout.hideProgressBar(); | 247 mTabLayout.hideProgressBar(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 254 mNativeTranslateInfoBarPtr = nativePtr; | 262 mNativeTranslateInfoBarPtr = nativePtr; |
| 255 } | 263 } |
| 256 | 264 |
| 257 @CalledByNative | 265 @CalledByNative |
| 258 private void setAutoAlwaysTranslate() { | 266 private void setAutoAlwaysTranslate() { |
| 259 createAndShowSnackbar(getContext().getString(R.string.translate_snackbar
_always_translate, | 267 createAndShowSnackbar(getContext().getString(R.string.translate_snackbar
_always_translate, |
| 260 mOptions.sourceLanguageName(), mOptions.ta
rgetLanguageName()), | 268 mOptions.sourceLanguageName(), mOptions.ta
rgetLanguageName()), |
| 261 Snackbar.UMA_TRANSLATE_ALWAYS, ACTION_AUTO_ALWAYS_TRANSLATE); | 269 Snackbar.UMA_TRANSLATE_ALWAYS, ACTION_AUTO_ALWAYS_TRANSLATE); |
| 262 } | 270 } |
| 263 | 271 |
| 264 private void setAutoNeverTranslate() { | |
| 265 createAndShowSnackbar(getContext().getString(R.string.translate_snackbar
_language_never, | |
| 266 mOptions.sourceLanguageName()), | |
| 267 Snackbar.UMA_TRANSLATE_NEVER, ACTION_AUTO_NEVER_LANGUAGE); | |
| 268 } | |
| 269 | |
| 270 @Override | 272 @Override |
| 271 protected void onNativeDestroyed() { | 273 protected void onNativeDestroyed() { |
| 272 mNativeTranslateInfoBarPtr = 0; | 274 mNativeTranslateInfoBarPtr = 0; |
| 273 super.onNativeDestroyed(); | 275 super.onNativeDestroyed(); |
| 274 } | 276 } |
| 275 | 277 |
| 276 @Override | 278 private void closeInfobar(boolean explicitly) { |
| 277 public void onCloseButtonClicked() { | 279 // Check if we should trigger the auto "never translate" if infobar is c
losed explicitly. |
| 278 // If mUserInteracted is false, it is regarded as a translation denied. | 280 if (explicitly |
| 279 if (!mUserInteracted) { | 281 && nativeShouldAutoNeverTranslate(mNativeTranslateInfoBarPtr, mM
enuExpanded)) { |
| 280 recordInfobarAction(INFOBAR_DECLINE); | 282 createAndShowSnackbar(getContext().getString(R.string.translate_snac
kbar_language_never, |
| 281 // This will increment the denied count. | 283 mOptions.sourceLanguageName()), |
| 282 onButtonClicked(ActionType.CANCEL); | 284 Snackbar.UMA_TRANSLATE_NEVER, ACTION_AUTO_NEVER_LANGUAGE); |
| 283 | 285 // Postpone the infobar dismiss until the snackbar finished showing.
Otherwise, the |
| 284 // Check if it should trigger the auto "never translate". | 286 // reference to the native infobar is killed and there is no way for
the snackbar to |
| 285 if (!mOptions.neverTranslateLanguageState() | 287 // perform the action. |
| 286 && nativeShouldAutoNeverTranslate(mNativeTranslateInfoBarPtr
)) { | 288 return; |
| 287 setAutoNeverTranslate(); | |
| 288 // Postpone the infobar dismiss until the snackbar finished show
ing. Otherwise, the | |
| 289 // reference to the native infobar is killed and there is no way
for the snackbar to | |
| 290 // perform the action. | |
| 291 return; | |
| 292 } | |
| 293 } | 289 } |
| 294 recordInfobarAction(INFOBAR_CLOSE); | 290 recordInfobarAction(INFOBAR_CLOSE); |
| 295 // This line will dismiss this infobar. | 291 // This line will dismiss this infobar. |
| 296 performCloseButtonActionWithoutDeniedCheck(); | |
| 297 } | |
| 298 | |
| 299 private void performCloseButtonActionWithoutDeniedCheck() { | |
| 300 super.onCloseButtonClicked(); | 292 super.onCloseButtonClicked(); |
| 301 } | 293 } |
| 302 | 294 |
| 303 @Override | 295 @Override |
| 296 public void onCloseButtonClicked() { |
| 297 closeInfobar(true); |
| 298 } |
| 299 |
| 300 @Override |
| 304 public void onTabSelected(TabLayout.Tab tab) { | 301 public void onTabSelected(TabLayout.Tab tab) { |
| 305 switch (tab.getPosition()) { | 302 switch (tab.getPosition()) { |
| 306 case SOURCE_TAB_INDEX: | 303 case SOURCE_TAB_INDEX: |
| 307 incrementAndRecordTranslationsPerPageCount(); | 304 incrementAndRecordTranslationsPerPageCount(); |
| 308 recordInfobarAction(INFOBAR_REVERT); | 305 recordInfobarAction(INFOBAR_REVERT); |
| 309 onButtonClicked(ActionType.TRANSLATE_SHOW_ORIGINAL); | 306 onButtonClicked(ActionType.TRANSLATE_SHOW_ORIGINAL); |
| 310 return; | 307 return; |
| 311 case TARGET_TAB_INDEX: | 308 case TARGET_TAB_INDEX: |
| 312 recordInfobarAction(INFOBAR_TRANSLATE); | 309 recordInfobarAction(INFOBAR_TRANSLATE); |
| 313 recordInfobarLanguageData( | 310 recordInfobarLanguageData( |
| 314 INFOBAR_HISTOGRAM_TRANSLATE_LANGUAGE, mOptions.targetLan
guageCode()); | 311 INFOBAR_HISTOGRAM_TRANSLATE_LANGUAGE, mOptions.targetLan
guageCode()); |
| 315 startTranslating(TARGET_TAB_INDEX); | 312 startTranslating(TARGET_TAB_INDEX); |
| 316 return; | 313 return; |
| 317 default: | 314 default: |
| 318 assert false : "Unexpected Tab Index"; | 315 assert false : "Unexpected Tab Index"; |
| 319 } | 316 } |
| 320 } | 317 } |
| 321 | 318 |
| 322 @Override | 319 @Override |
| 323 public void onTabUnselected(TabLayout.Tab tab) {} | 320 public void onTabUnselected(TabLayout.Tab tab) {} |
| 324 | 321 |
| 325 @Override | 322 @Override |
| 326 public void onTabReselected(TabLayout.Tab tab) {} | 323 public void onTabReselected(TabLayout.Tab tab) {} |
| 327 | 324 |
| 328 @Override | 325 @Override |
| 329 public void onOverflowMenuItemClicked(int itemId) { | 326 public void onOverflowMenuItemClicked(int itemId) { |
| 330 mUserInteracted = true; | |
| 331 switch (itemId) { | 327 switch (itemId) { |
| 332 case TranslateMenu.ID_OVERFLOW_MORE_LANGUAGE: | 328 case TranslateMenu.ID_OVERFLOW_MORE_LANGUAGE: |
| 333 recordInfobarAction(INFOBAR_MORE_LANGUAGES); | 329 recordInfobarAction(INFOBAR_MORE_LANGUAGES); |
| 334 initMenuHelper(TranslateMenu.MENU_TARGET_LANGUAGE); | 330 initMenuHelper(TranslateMenu.MENU_TARGET_LANGUAGE); |
| 335 mLanguageMenuHelper.show(TranslateMenu.MENU_TARGET_LANGUAGE); | 331 mLanguageMenuHelper.show(TranslateMenu.MENU_TARGET_LANGUAGE); |
| 336 return; | 332 return; |
| 337 case TranslateMenu.ID_OVERFLOW_ALWAYS_TRANSLATE: | 333 case TranslateMenu.ID_OVERFLOW_ALWAYS_TRANSLATE: |
| 338 // Only show snackbar when "Always Translate" is enabled. | 334 // Only show snackbar when "Always Translate" is enabled. |
| 339 if (!mOptions.alwaysTranslateLanguageState()) { | 335 if (!mOptions.alwaysTranslateLanguageState()) { |
| 340 recordInfobarAction(INFOBAR_ALWAYS_TRANSLATE); | 336 recordInfobarAction(INFOBAR_ALWAYS_TRANSLATE); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 recordInfobarLanguageData( | 391 recordInfobarLanguageData( |
| 396 INFOBAR_HISTOGRAM_PAGE_NOT_IN_LANGUAGE, mOptions.sourceLangu
ageCode()); | 392 INFOBAR_HISTOGRAM_PAGE_NOT_IN_LANGUAGE, mOptions.sourceLangu
ageCode()); |
| 397 nativeApplyStringTranslateOption( | 393 nativeApplyStringTranslateOption( |
| 398 mNativeTranslateInfoBarPtr, TranslateOption.SOURCE_CODE, cod
e); | 394 mNativeTranslateInfoBarPtr, TranslateOption.SOURCE_CODE, cod
e); |
| 399 // Adjust UI. | 395 // Adjust UI. |
| 400 mTabLayout.replaceTabTitle(SOURCE_TAB_INDEX, mOptions.getRepresentat
ionFromCode(code)); | 396 mTabLayout.replaceTabTitle(SOURCE_TAB_INDEX, mOptions.getRepresentat
ionFromCode(code)); |
| 401 startTranslating(mTabLayout.getSelectedTabPosition()); | 397 startTranslating(mTabLayout.getSelectedTabPosition()); |
| 402 } | 398 } |
| 403 } | 399 } |
| 404 | 400 |
| 405 @Override | |
| 406 public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, | |
| 407 int oldTop, int oldRight, int oldBottom) { | |
| 408 // Dismiss all menus when there is layout changed. (which will cause men
u misplacement.) | |
| 409 dismissMenus(); | |
| 410 } | |
| 411 | |
| 412 // Dismiss all overflow menus that remains open. | 401 // Dismiss all overflow menus that remains open. |
| 413 // This is called when infobar started hiding or layout changed. | 402 // This is called when infobar started hiding or layout changed. |
| 414 private void dismissMenus() { | 403 private void dismissMenus() { |
| 415 if (mOverflowMenuHelper != null) mOverflowMenuHelper.dismiss(); | 404 if (mOverflowMenuHelper != null) mOverflowMenuHelper.dismiss(); |
| 416 if (mLanguageMenuHelper != null) mLanguageMenuHelper.dismiss(); | 405 if (mLanguageMenuHelper != null) mLanguageMenuHelper.dismiss(); |
| 417 } | 406 } |
| 418 | 407 |
| 419 @Override | 408 @Override |
| 420 protected void onStartedHiding() { | 409 protected void onStartedHiding() { |
| 421 dismissMenus(); | 410 dismissMenus(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 496 |
| 508 private void incrementAndRecordTranslationsPerPageCount() { | 497 private void incrementAndRecordTranslationsPerPageCount() { |
| 509 RecordHistogram.recordCountHistogram( | 498 RecordHistogram.recordCountHistogram( |
| 510 INFOBAR_HISTOGRAM_TRANSLATION_COUNT, ++mTotalTranslationCount); | 499 INFOBAR_HISTOGRAM_TRANSLATION_COUNT, ++mTotalTranslationCount); |
| 511 } | 500 } |
| 512 | 501 |
| 513 private native void nativeApplyStringTranslateOption( | 502 private native void nativeApplyStringTranslateOption( |
| 514 long nativeTranslateCompactInfoBar, int option, String value); | 503 long nativeTranslateCompactInfoBar, int option, String value); |
| 515 private native void nativeApplyBoolTranslateOption( | 504 private native void nativeApplyBoolTranslateOption( |
| 516 long nativeTranslateCompactInfoBar, int option, boolean value); | 505 long nativeTranslateCompactInfoBar, int option, boolean value); |
| 517 private native boolean nativeShouldAutoNeverTranslate(long nativeTranslateCo
mpactInfoBar); | 506 private native boolean nativeShouldAutoNeverTranslate( |
| 507 long nativeTranslateCompactInfoBar, boolean menuExpanded); |
| 518 } | 508 } |
| OLD | NEW |