OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.graphics.drawable.Drawable; | 9 import android.graphics.drawable.Drawable; |
10 import android.os.Handler; | 10 import android.os.Handler; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 if (pendingEntry == null) return false; | 438 if (pendingEntry == null) return false; |
439 | 439 |
440 return !NewTabPage.isNTPUrl(pendingEntry.getUrl()); | 440 return !NewTabPage.isNTPUrl(pendingEntry.getUrl()); |
441 } | 441 } |
442 | 442 |
443 @Override | 443 @Override |
444 public void onContextualActionBarVisibilityChanged(Tab tab, boolean
visible) { | 444 public void onContextualActionBarVisibilityChanged(Tab tab, boolean
visible) { |
445 if (visible) RecordUserAction.record("MobileActionBarShown"); | 445 if (visible) RecordUserAction.record("MobileActionBarShown"); |
446 ActionBar actionBar = mActionBarDelegate.getSupportActionBar(); | 446 ActionBar actionBar = mActionBarDelegate.getSupportActionBar(); |
447 if (!visible && actionBar != null) actionBar.hide(); | 447 if (!visible && actionBar != null) actionBar.hide(); |
448 if (DeviceFormFactor.isTablet(activity)) { | 448 if (DeviceFormFactor.isTablet()) { |
449 if (visible) { | 449 if (visible) { |
450 mActionModeController.startShowAnimation(); | 450 mActionModeController.startShowAnimation(); |
451 } else { | 451 } else { |
452 mActionModeController.startHideAnimation(); | 452 mActionModeController.startHideAnimation(); |
453 } | 453 } |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 @Override | 457 @Override |
458 public void onDidStartNavigation(Tab tab, String url, boolean isInMa
inFrame, | 458 public void onDidStartNavigation(Tab tab, String url, boolean isInMa
inFrame, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 507 } |
508 | 508 |
509 private void handleIPHForSuccessfulPageLoad(final Tab tab) { | 509 private void handleIPHForSuccessfulPageLoad(final Tab tab) { |
510 if (mTextBubble != null) { | 510 if (mTextBubble != null) { |
511 mTextBubble.dismiss(); | 511 mTextBubble.dismiss(); |
512 mTextBubble = null; | 512 mTextBubble = null; |
513 return; | 513 return; |
514 } | 514 } |
515 | 515 |
516 // TODO(shaktisahu): Find out if the download menu button is ena
bled (crbug/712438). | 516 // TODO(shaktisahu): Find out if the download menu button is ena
bled (crbug/712438). |
517 if (!(activity instanceof ChromeTabbedActivity) | 517 if (!(activity instanceof ChromeTabbedActivity) || DeviceFormFac
tor.isTablet() |
518 || DeviceFormFactor.isTablet(mToolbar.getContext()) | |
519 || activity.isInOverviewMode() | 518 || activity.isInOverviewMode() |
520 || !DownloadUtils.isAllowedToDownloadPage(tab)) { | 519 || !DownloadUtils.isAllowedToDownloadPage(tab)) { |
521 return; | 520 return; |
522 } | 521 } |
523 | 522 |
524 final FeatureEngagementTracker tracker = | 523 final FeatureEngagementTracker tracker = |
525 FeatureEngagementTrackerFactory.getFeatureEngagementTrac
kerForProfile( | 524 FeatureEngagementTrackerFactory.getFeatureEngagementTrac
kerForProfile( |
526 tab.getProfile()); | 525 tab.getProfile()); |
527 | 526 |
528 if (!tracker.shouldTriggerHelpUI(FeatureConstants.DOWNLOAD_PAGE_
FEATURE)) return; | 527 if (!tracker.shouldTriggerHelpUI(FeatureConstants.DOWNLOAD_PAGE_
FEATURE)) return; |
(...skipping 16 matching lines...) Expand all Loading... |
545 }); | 544 }); |
546 activity.getAppMenuHandler().setMenuHighlight(R.id.offline_page_
id); | 545 activity.getAppMenuHandler().setMenuHighlight(R.id.offline_page_
id); |
547 int yInsetPx = activity.getResources().getDimensionPixelOffset( | 546 int yInsetPx = activity.getResources().getDimensionPixelOffset( |
548 R.dimen.text_bubble_menu_anchor_y_inset); | 547 R.dimen.text_bubble_menu_anchor_y_inset); |
549 yInsetPx = MathUtils.flipSignIf(yInsetPx, FeatureUtilities.isChr
omeHomeEnabled()); | 548 yInsetPx = MathUtils.flipSignIf(yInsetPx, FeatureUtilities.isChr
omeHomeEnabled()); |
550 mTextBubble.setInsetPx(0, yInsetPx, 0, 0); | 549 mTextBubble.setInsetPx(0, yInsetPx, 0, 0); |
551 mTextBubble.show(); | 550 mTextBubble.show(); |
552 } | 551 } |
553 | 552 |
554 private void handleIPHForErrorPageShown(Tab tab) { | 553 private void handleIPHForErrorPageShown(Tab tab) { |
555 if (!(activity instanceof ChromeTabbedActivity) | 554 if (!(activity instanceof ChromeTabbedActivity) || DeviceFormFac
tor.isTablet()) { |
556 || DeviceFormFactor.isTablet(mToolbar.getContext())) { | |
557 return; | 555 return; |
558 } | 556 } |
559 | 557 |
560 OfflinePageBridge bridge = OfflinePageBridge.getForProfile(tab.g
etProfile()); | 558 OfflinePageBridge bridge = OfflinePageBridge.getForProfile(tab.g
etProfile()); |
561 if (bridge == null | 559 if (bridge == null |
562 || !bridge.isShowingDownloadButtonInErrorPage(tab.getWeb
Contents())) { | 560 || !bridge.isShowingDownloadButtonInErrorPage(tab.getWeb
Contents())) { |
563 return; | 561 return; |
564 } | 562 } |
565 | 563 |
566 FeatureEngagementTracker tracker = | 564 FeatureEngagementTracker tracker = |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 | 1317 |
1320 private boolean shouldShowCusrsorInLocationBar() { | 1318 private boolean shouldShowCusrsorInLocationBar() { |
1321 Tab tab = mToolbarModel.getTab(); | 1319 Tab tab = mToolbarModel.getTab(); |
1322 if (tab == null) return false; | 1320 if (tab == null) return false; |
1323 NativePage nativePage = tab.getNativePage(); | 1321 NativePage nativePage = tab.getNativePage(); |
1324 if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof Incog
nitoNewTabPage)) { | 1322 if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof Incog
nitoNewTabPage)) { |
1325 return false; | 1323 return false; |
1326 } | 1324 } |
1327 | 1325 |
1328 Context context = mToolbar.getContext(); | 1326 Context context = mToolbar.getContext(); |
1329 return DeviceFormFactor.isTablet(context) | 1327 return DeviceFormFactor.isTablet() |
1330 && context.getResources().getConfiguration().keyboard | 1328 && context.getResources().getConfiguration().keyboard |
1331 == Configuration.KEYBOARD_QWERTY; | 1329 == Configuration.KEYBOARD_QWERTY; |
1332 } | 1330 } |
1333 | 1331 |
1334 private static class LoadProgressSimulator { | 1332 private static class LoadProgressSimulator { |
1335 private static final int MSG_ID_UPDATE_PROGRESS = 1; | 1333 private static final int MSG_ID_UPDATE_PROGRESS = 1; |
1336 | 1334 |
1337 private static final int PROGRESS_INCREMENT = 10; | 1335 private static final int PROGRESS_INCREMENT = 10; |
1338 private static final int PROGRESS_INCREMENT_DELAY_MS = 10; | 1336 private static final int PROGRESS_INCREMENT_DELAY_MS = 10; |
1339 | 1337 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 } | 1369 } |
1372 | 1370 |
1373 /** | 1371 /** |
1374 * Cancels simulating load progress. | 1372 * Cancels simulating load progress. |
1375 */ | 1373 */ |
1376 public void cancel() { | 1374 public void cancel() { |
1377 mHandler.removeMessages(MSG_ID_UPDATE_PROGRESS); | 1375 mHandler.removeMessages(MSG_ID_UPDATE_PROGRESS); |
1378 } | 1376 } |
1379 } | 1377 } |
1380 } | 1378 } |
OLD | NEW |