Commit 7b99edee authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Do not use TabImpl.getActivity in ToolbarButtonIPHController

ToolbarButtonIPHController is build with a particular ChromeActivity
and the objects associated with it. Therefore it doesn't need to
use TabImpl.getActivity() to get the current activity dynamically.
This CL removes replaces the use of API with the controller's
|mActivity|.

Bug: 952703
Change-Id: Ie3e601250192832f4fb2706e44e673c374a0129a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129374Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755155}
parent ef404831
...@@ -22,7 +22,6 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; ...@@ -22,7 +22,6 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
import org.chromium.chrome.browser.previews.Previews; import org.chromium.chrome.browser.previews.Previews;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration; import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration;
import org.chromium.chrome.browser.translate.TranslateBridge; import org.chromium.chrome.browser.translate.TranslateBridge;
import org.chromium.chrome.browser.translate.TranslateUtils; import org.chromium.chrome.browser.translate.TranslateUtils;
...@@ -264,9 +263,8 @@ public class ToolbarButtonInProductHelpController ...@@ -264,9 +263,8 @@ public class ToolbarButtonInProductHelpController
*/ */
private void showDownloadPageTextBubble(final Tab tab, String featureName) { private void showDownloadPageTextBubble(final Tab tab, String featureName) {
if (tab == null) return; if (tab == null) return;
ChromeActivity activity = ((TabImpl) tab).getActivity(); if (!(mActivity instanceof ChromeTabbedActivity) || mActivity.isTablet()
if (!(activity instanceof ChromeTabbedActivity) || activity.isTablet() || mActivity.isInOverviewMode() || !DownloadUtils.isAllowedToDownloadPage(tab)) {
|| activity.isInOverviewMode() || !DownloadUtils.isAllowedToDownloadPage(tab)) {
return; return;
} }
...@@ -280,9 +278,7 @@ public class ToolbarButtonInProductHelpController ...@@ -280,9 +278,7 @@ public class ToolbarButtonInProductHelpController
.setAnchorView(mActivity.getToolbarManager().getMenuButtonView()) .setAnchorView(mActivity.getToolbarManager().getMenuButtonView())
.build()); .build());
// Record metrics if we show Download IPH after a screenshot of the page. // Record metrics if we show Download IPH after a screenshot of the page.
ChromeTabbedActivity chromeActivity = ((ChromeTabbedActivity) activity); ScreenshotTabObserver tabObserver = ScreenshotTabObserver.from(tab);
ScreenshotTabObserver tabObserver =
ScreenshotTabObserver.from(chromeActivity.getActivityTab());
if (tabObserver != null) { if (tabObserver != null) {
tabObserver.onActionPerformedAfterScreenshot( tabObserver.onActionPerformedAfterScreenshot(
ScreenshotTabObserver.SCREENSHOT_ACTION_DOWNLOAD_IPH); ScreenshotTabObserver.SCREENSHOT_ACTION_DOWNLOAD_IPH);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment