Commit c5b1e6df authored by Matt Jones's avatar Matt Jones Committed by Commit Bot

Unfocus omnibox when share button is pressed

The omnibox needs to be unfocused to unsuppress the bottom sheet that
is triggered when attempting to share. This patch does that by
providing a runnable to the ShareButtonCoordinator that performs the
unfocus action.

Bug: 1135907
Change-Id: I3b9f14f76b90f13f381f910e4b495ebbecba9168
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2456508
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815118}
parent 822d7cb2
...@@ -68,11 +68,14 @@ public class ShareButtonController implements ButtonDataProvider, ConfigurationC ...@@ -68,11 +68,14 @@ public class ShareButtonController implements ButtonDataProvider, ConfigurationC
* @param activityLifecycleDispatcher Dispatcher for activity lifecycle events, e.g. * @param activityLifecycleDispatcher Dispatcher for activity lifecycle events, e.g.
* configuration changes. * configuration changes.
* @param modalDialogManager dispatcher for modal lifecycles events * @param modalDialogManager dispatcher for modal lifecycles events
* @param onShareRunnable A {@link Runnable} to execute when a share event occurs. This object
* does not actually handle sharing, but can provide supplemental
* functionality when the share button is pressed.
*/ */
public ShareButtonController(Context context, ActivityTabProvider tabProvider, public ShareButtonController(Context context, ActivityTabProvider tabProvider,
ObservableSupplier<ShareDelegate> shareDelegateSupplier, ShareUtils shareUtils, ObservableSupplier<ShareDelegate> shareDelegateSupplier, ShareUtils shareUtils,
ActivityLifecycleDispatcher activityLifecycleDispatcher, ActivityLifecycleDispatcher activityLifecycleDispatcher,
ModalDialogManager modalDialogManager) { ModalDialogManager modalDialogManager, Runnable onShareRunnable) {
mContext = context; mContext = context;
mActivityLifecycleDispatcher = activityLifecycleDispatcher; mActivityLifecycleDispatcher = activityLifecycleDispatcher;
...@@ -89,6 +92,7 @@ public class ShareButtonController implements ButtonDataProvider, ConfigurationC ...@@ -89,6 +92,7 @@ public class ShareButtonController implements ButtonDataProvider, ConfigurationC
Tab tab = mTabProvider.get(); Tab tab = mTabProvider.get();
assert tab != null : "Tab became null after share button was displayed"; assert tab != null : "Tab became null after share button was displayed";
if (tab == null) return; if (tab == null) return;
if (onShareRunnable != null) onShareRunnable.run();
RecordUserAction.record("MobileTopToolbarShareButton"); RecordUserAction.record("MobileTopToolbarShareButton");
shareDelegate.share(tab, /*shareDirectly=*/false); shareDelegate.share(tab, /*shareDirectly=*/false);
}); });
......
...@@ -50,6 +50,7 @@ import org.chromium.chrome.browser.image_descriptions.ImageDescriptionsControlle ...@@ -50,6 +50,7 @@ import org.chromium.chrome.browser.image_descriptions.ImageDescriptionsControlle
import org.chromium.chrome.browser.lifecycle.Destroyable; import org.chromium.chrome.browser.lifecycle.Destroyable;
import org.chromium.chrome.browser.lifecycle.InflationObserver; import org.chromium.chrome.browser.lifecycle.InflationObserver;
import org.chromium.chrome.browser.metrics.UkmRecorder; import org.chromium.chrome.browser.metrics.UkmRecorder;
import org.chromium.chrome.browser.omnibox.LocationBar.OmniboxFocusReason;
import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader; import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader;
import org.chromium.chrome.browser.paint_preview.PaintPreviewTabHelper; import org.chromium.chrome.browser.paint_preview.PaintPreviewTabHelper;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
...@@ -528,7 +529,8 @@ public class RootUiCoordinator ...@@ -528,7 +529,8 @@ public class RootUiCoordinator
mActivity, mActivity.getLifecycleDispatcher(), mProfileSupplier); mActivity, mActivity.getLifecycleDispatcher(), mProfileSupplier);
ShareButtonController shareButtonController = new ShareButtonController(mActivity, ShareButtonController shareButtonController = new ShareButtonController(mActivity,
mActivityTabProvider, mShareDelegateSupplier, new ShareUtils(), mActivityTabProvider, mShareDelegateSupplier, new ShareUtils(),
mActivity.getLifecycleDispatcher(), mActivity.getModalDialogManager()); mActivity.getLifecycleDispatcher(), mActivity.getModalDialogManager(),
() -> mToolbarManager.setUrlBarFocus(false, OmniboxFocusReason.UNFOCUS));
mButtonDataProviders = Arrays.asList(mIdentityDiscController, shareButtonController); mButtonDataProviders = Arrays.asList(mIdentityDiscController, shareButtonController);
mToolbarManager = new ToolbarManager(mActivity, mActivity.getBrowserControlsManager(), mToolbarManager = new ToolbarManager(mActivity, mActivity.getBrowserControlsManager(),
mActivity.getFullscreenManager(), toolbarContainer, mActivity.getFullscreenManager(), toolbarContainer,
......
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