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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java

Issue 1326643003: Overlay content is its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-panel-functionality
Patch Set: address comments Created 5 years, 3 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
OLDNEW
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.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.view.View; 8 import android.view.View;
9 import android.view.ViewGroup; 9 import android.view.ViewGroup;
10 import android.view.ViewTreeObserver; 10 import android.view.ViewTreeObserver;
11 import android.view.ViewTreeObserver.OnGlobalFocusChangeListener; 11 import android.view.ViewTreeObserver.OnGlobalFocusChangeListener;
12 12
13 import org.chromium.base.ActivityState; 13 import org.chromium.base.ActivityState;
14 import org.chromium.base.ApplicationStatus; 14 import org.chromium.base.ApplicationStatus;
15 import org.chromium.base.ApplicationStatus.ActivityStateListener; 15 import org.chromium.base.ApplicationStatus.ActivityStateListener;
16 import org.chromium.base.SysUtils; 16 import org.chromium.base.SysUtils;
17 import org.chromium.base.VisibleForTesting; 17 import org.chromium.base.VisibleForTesting;
18 import org.chromium.base.annotations.CalledByNative; 18 import org.chromium.base.annotations.CalledByNative;
19 import org.chromium.chrome.R; 19 import org.chromium.chrome.R;
20 import org.chromium.chrome.browser.ChromeActivity; 20 import org.chromium.chrome.browser.ChromeActivity;
21 import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate;
21 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel.PanelState; 22 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel.PanelState;
22 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel.StateChangeReason; 23 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel.StateChangeReason;
23 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanelDelegate; 24 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanelDelegate;
24 import org.chromium.chrome.browser.contextualsearch.ContextualSearchSelectionCon troller.SelectionType; 25 import org.chromium.chrome.browser.contextualsearch.ContextualSearchSelectionCon troller.SelectionType;
25 import org.chromium.chrome.browser.device.DeviceClassManager; 26 import org.chromium.chrome.browser.device.DeviceClassManager;
26 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; 27 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler;
27 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.Overrid eUrlLoadingResult; 28 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.Overrid eUrlLoadingResult;
28 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; 29 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams;
29 import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; 30 import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection;
30 import org.chromium.chrome.browser.infobar.InfoBarContainer; 31 import org.chromium.chrome.browser.infobar.InfoBarContainer;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 private long mLoadedSearchUrlTimeMs; 100 private long mLoadedSearchUrlTimeMs;
100 // TODO(donnd): consider changing this member's name to indicate "opened" in stead of "seen". 101 // TODO(donnd): consider changing this member's name to indicate "opened" in stead of "seen".
101 private boolean mWereSearchResultsSeen; 102 private boolean mWereSearchResultsSeen;
102 private boolean mWereInfoBarsHidden; 103 private boolean mWereInfoBarsHidden;
103 private boolean mDidLoadAnyUrl; 104 private boolean mDidLoadAnyUrl;
104 private boolean mDidPromoteSearchNavigation; 105 private boolean mDidPromoteSearchNavigation;
105 private boolean mDidBasePageLoadJustStart; 106 private boolean mDidBasePageLoadJustStart;
106 private boolean mWasActivatedByTap; 107 private boolean mWasActivatedByTap;
107 private boolean mIsInitialized; 108 private boolean mIsInitialized;
108 109
110 /**
111 * This boolean is used for loading content after a long-press when content is not immediately
112 * loaded.
113 */
114 private boolean mShouldLoadDelayedSearch;
115
109 private boolean mIsShowingPromo; 116 private boolean mIsShowingPromo;
110 private boolean mDidLogPromoOutcome; 117 private boolean mDidLogPromoOutcome;
111 118
112 /** 119 /**
113 * Whether contextual search manager is currently promoting a tab. We should be ignoring hide 120 * Whether contextual search manager is currently promoting a tab. We should be ignoring hide
114 * requests when mIsPromotingTab is set to true. 121 * requests when mIsPromotingTab is set to true.
115 */ 122 */
116 private boolean mIsPromotingToTab; 123 private boolean mIsPromotingToTab;
117 124
118 private ContextualSearchNetworkCommunicator mNetworkCommunicator; 125 private ContextualSearchNetworkCommunicator mNetworkCommunicator;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 466 }
460 467
461 // If the user is jumping from one unseen search to another search, remo ve the last search 468 // If the user is jumping from one unseen search to another search, remo ve the last search
462 // from history. 469 // from history.
463 PanelState state = mSearchPanelDelegate.getPanelState(); 470 PanelState state = mSearchPanelDelegate.getPanelState();
464 if (!mWereSearchResultsSeen && mLoadedSearchUrlTimeMs != 0L 471 if (!mWereSearchResultsSeen && mLoadedSearchUrlTimeMs != 0L
465 && state != PanelState.UNDEFINED && state != PanelState.CLOSED) { 472 && state != PanelState.UNDEFINED && state != PanelState.CLOSED) {
466 removeLastSearchVisit(); 473 removeLastSearchVisit();
467 } 474 }
468 475
476 mSearchPanelDelegate.setSearchContentViewVisibility(false);
477
469 boolean isTap = mSelectionController.getSelectionType() == SelectionType .TAP; 478 boolean isTap = mSelectionController.getSelectionType() == SelectionType .TAP;
470 boolean didRequestSurroundings = false; 479 boolean didRequestSurroundings = false;
480
481 if (isTap) {
482 // If the user action was not a long-press, immediately start loadin g content.
483 mShouldLoadDelayedSearch = false;
pedro (no code reviews) 2015/09/23 00:00:12 I'm not very happy with adding a new boolean, beca
mdjones 2015/09/23 00:29:31 Acknowledged.
484 }
485
471 if (isTap && mPolicy.shouldPreviousTapResolve( 486 if (isTap && mPolicy.shouldPreviousTapResolve(
472 mNetworkCommunicator.getBasePageUrl())) { 487 mNetworkCommunicator.getBasePageUrl())) {
473 mNetworkCommunicator.startSearchTermResolutionRequest( 488 mNetworkCommunicator.startSearchTermResolutionRequest(
474 mSelectionController.getSelectedText()); 489 mSelectionController.getSelectedText());
475 didRequestSurroundings = true; 490 didRequestSurroundings = true;
476 } else { 491 } else {
477 boolean shouldPrefetch = mPolicy.shouldPrefetchSearchResult(isTap); 492 boolean shouldPrefetch = mPolicy.shouldPrefetchSearchResult(isTap);
478 mSearchRequest = new ContextualSearchRequest(mSelectionController.ge tSelectedText(), 493 mSearchRequest = new ContextualSearchRequest(mSelectionController.ge tSelectedText(),
479 null, shouldPrefetch); 494 null, shouldPrefetch);
480 mDidLoadResolvedSearchRequest = false; 495 mDidLoadResolvedSearchRequest = false;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 /** 765 /**
751 * @return Whether a Tap gesture is currently supported. 766 * @return Whether a Tap gesture is currently supported.
752 */ 767 */
753 private boolean isTapSupported() { 768 private boolean isTapSupported() {
754 // Base page just started navigating away, so taps should be ignored. 769 // Base page just started navigating away, so taps should be ignored.
755 if (mDidBasePageLoadJustStart) return false; 770 if (mDidBasePageLoadJustStart) return false;
756 771
757 return mPolicy.isTapSupported(); 772 return mPolicy.isTapSupported();
758 } 773 }
759 774
775 // ========================================================================= ===================
776 // OverlayContentDelegate
777 // ========================================================================= ===================
778
779 @Override
780 public OverlayContentDelegate getOverlayContentDelegate() {
781 return new SearchOverlayContentDelegate();
782 }
783
784 /**
785 * Implementation of OverlayContentDelegate. Made public for testing purpose s.
786 */
787 public class SearchOverlayContentDelegate extends OverlayContentDelegate {
788
789 public SearchOverlayContentDelegate() {}
790
791 @Override
792 public void onMainFrameLoadStarted(String url) {
793 onExternalNavigation(url);
794 }
795
796 @Override
797 public void onMainFrameNavigation(String url, boolean isFailure) {
798 handleDidNavigateMainFrame(url, isFailure);
799 }
800
801 @Override
802 public void onContentLoadStarted(String url) {
803 onStartedLoading();
804 }
805
806 @Override
807 public void onContentLoadFinished() {
808 onSearchResultsLoaded();
809 }
810
811 @Override
812 public void onVisibilityChanged(boolean isVisible) {
813 onContentViewVisibilityChanged(isVisible);
814 }
815
816 @Override
817 public void onContentViewCreated(ContentViewCore contentViewCore) {
818 // TODO: implemented in manager
819 ContextualSearchManager.this.onContentViewCreated(contentViewCore);
820 }
821
822 @Override
823 public void onContentViewDestroyed() {
824 // TODO: implemented in manager
825 ContextualSearchManager.this.onContentViewDestroyed();
826 }
827
828 @Override
829 public void onContentViewSeen() {
830 mSearchPanelDelegate.setWasSearchContentViewSeen();
831 }
832
833 @Override
834 public boolean shouldInterceptNavigation(ExternalNavigationHandler exter nalNavHandler,
835 NavigationParams navigationParams) {
836 return ContextualSearchManager.this.shouldInterceptNavigation(extern alNavHandler,
837 navigationParams);
838 }
839 }
840
841
760 // ------------------------------------------------------------------------- ------------------- 842 // ------------------------------------------------------------------------- -------------------
761 // Search Content View 843 // Search Content View
762 // ------------------------------------------------------------------------- ------------------- 844 // ------------------------------------------------------------------------- -------------------
763 845
764 /** 846 /**
765 * Gets the {@code ContentViewCore} associated with Contextual Search Panel. 847 * Gets the {@code ContentViewCore} associated with Contextual Search Panel.
766 * @return Contextual Search Panel's {@code ContentViewCore}. 848 * @return Contextual Search Panel's {@code ContentViewCore}.
767 */ 849 */
768 @Override 850 @Override
769 public ContentViewCore getSearchContentViewCore() { 851 public ContentViewCore getSearchContentViewCore() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 @Override 910 @Override
829 public void logPromoOutcome() { 911 public void logPromoOutcome() {
830 ContextualSearchUma.logPromoOutcome(mWasActivatedByTap); 912 ContextualSearchUma.logPromoOutcome(mWasActivatedByTap);
831 mDidLogPromoOutcome = true; 913 mDidLogPromoOutcome = true;
832 } 914 }
833 915
834 /** 916 /**
835 * Called when the Search Content view has finished loading to record how lo ng it takes the SERP 917 * Called when the Search Content view has finished loading to record how lo ng it takes the SERP
836 * to load after opening the panel. 918 * to load after opening the panel.
837 */ 919 */
838 @Override
839 public void onSearchResultsLoaded() { 920 public void onSearchResultsLoaded() {
840 if (mSearchRequest == null) return; 921 if (mSearchRequest == null) return;
841 922
842 mSearchPanelDelegate.onSearchResultsLoaded(mSearchRequest.wasPrefetch()) ; 923 mSearchPanelDelegate.onSearchResultsLoaded(mSearchRequest.wasPrefetch()) ;
843 924
844 // Any time we place a page in a ContentViewCore, clear history if neede d. 925 // Any time we place a page in a ContentViewCore, clear history if neede d.
845 // This prevents error URLs from appearing in the Tab's history stack. 926 // This prevents error URLs from appearing in the Tab's history stack.
846 // Also please note that clearHistory() will not 927 // Also please note that clearHistory() will not
847 // clear the current entry (search results page in this case), 928 // clear the current entry (search results page in this case),
848 // and it will not work properly if there are pending navigations. 929 // and it will not work properly if there are pending navigations.
849 // That's why we need to clear the history here, after the navigation 930 // That's why we need to clear the history here, after the navigation
850 // is completed. 931 // is completed.
851 boolean shouldClearHistory = mSearchRequest.getHasFailed(); 932 boolean shouldClearHistory = mSearchRequest.getHasFailed();
852 if (shouldClearHistory && mSearchPanelDelegate.getContentViewCore() != n ull) { 933 if (shouldClearHistory && mSearchPanelDelegate.getContentViewCore() != n ull) {
853 mSearchPanelDelegate.getContentViewCore().getWebContents().getNaviga tionController() 934 mSearchPanelDelegate.getContentViewCore().getWebContents().getNaviga tionController()
854 .clearHistory(); 935 .clearHistory();
855 } 936 }
856 } 937 }
857 938
858 @Override 939 /**
859 public void handleDidNavigateMainFrame(String url, int httpResultCode) { 940 * Handles the WebContentsObserver#didNavigateMainFrame callback.
941 * @param url The URL of the navigation.
942 * @param isFailure True if the navigation resulted in a failure.
943 */
944 public void handleDidNavigateMainFrame(String url, boolean isFailure) {
860 if (shouldPromoteSearchNavigation()) { 945 if (shouldPromoteSearchNavigation()) {
861 onExternalNavigation(url); 946 onExternalNavigation(url);
862 } else { 947 } else {
863 // Could be just prefetching, check if that failed. 948 // Could be just prefetching, check if that failed.
864 boolean isFailure = isHttpFailureCode(httpResultCode);
865 onContextualSearchRequestNavigation(isFailure); 949 onContextualSearchRequestNavigation(isFailure);
866 } 950 }
867 } 951 }
868 952
869 @Override 953 /**
954 * Called when the WebContents for the panel starts loading.
955 */
870 public void onStartedLoading() { 956 public void onStartedLoading() {
871 mDidPromoteSearchNavigation = false; 957 mDidPromoteSearchNavigation = false;
872 } 958 }
873 959
874 @Override 960 /**
961 * Determine if the panel should intercept a particular navigation.
962 * @param externamNavHandler External navigation handler.
963 * @param navigationParams Params associated with the navigation.
964 * @return True if the navigation should be intecepted.
965 */
875 public boolean shouldInterceptNavigation( 966 public boolean shouldInterceptNavigation(
876 ExternalNavigationHandler externalNavHandler, NavigationParams navig ationParams) { 967 ExternalNavigationHandler externalNavHandler, NavigationParams navig ationParams) {
877 mTabRedirectHandler.updateNewUrlLoading(navigationParams.pageTransitionT ype, 968 mTabRedirectHandler.updateNewUrlLoading(navigationParams.pageTransitionT ype,
878 navigationParams.isRedirect, 969 navigationParams.isRedirect,
879 navigationParams.hasUserGesture || navigationParams.hasUserGestu reCarryover, 970 navigationParams.hasUserGesture || navigationParams.hasUserGestu reCarryover,
880 mActivity.getLastUserInteractionTime(), TabRedirectHandler.INVAL ID_ENTRY_INDEX); 971 mActivity.getLastUserInteractionTime(), TabRedirectHandler.INVAL ID_ENTRY_INDEX);
881 ExternalNavigationParams params = new ExternalNavigationParams.Builder( 972 ExternalNavigationParams params = new ExternalNavigationParams.Builder(
882 navigationParams.url, false, navigationParams.referrer, 973 navigationParams.url, false, navigationParams.referrer,
883 navigationParams.pageTransitionType, navigationParams.isRedirect ) 974 navigationParams.pageTransitionType, navigationParams.isRedirect )
884 .setApplicationMustBeInForeground(true) 975 .setApplicationMustBeInForeground(true)
885 .setRedirectHandler(mTabRedirectHandler) 976 .setRedirectHandler(mTabRedirectHandler)
886 .setIsMainFrame(navigationParams.isMainFrame) 977 .setIsMainFrame(navigationParams.isMainFrame)
887 .build(); 978 .build();
888 if (externalNavHandler.shouldOverrideUrlLoading(params) 979 if (externalNavHandler.shouldOverrideUrlLoading(params)
889 != OverrideUrlLoadingResult.NO_OVERRIDE) { 980 != OverrideUrlLoadingResult.NO_OVERRIDE) {
890 mSearchPanelDelegate.maximizePanelThenPromoteToTab(StateChangeReason .TAB_PROMOTION, 981 mSearchPanelDelegate.maximizePanelThenPromoteToTab(StateChangeReason .TAB_PROMOTION,
891 INTERCEPT_NAVIGATION_PROMOTION_ANIMATION_DURATION_MS); 982 INTERCEPT_NAVIGATION_PROMOTION_ANIMATION_DURATION_MS);
892 return true; 983 return false;
893 } 984 }
894 if (navigationParams.isExternalProtocol) { 985 if (navigationParams.isExternalProtocol) {
895 return true; 986 return false;
896 } 987 }
897 return false; 988 return true;
898 } 989 }
899 990
900 /** 991 /**
901 * @return Whether the given HTTP result code represents a failure or not. 992 * @return Whether the given HTTP result code represents a failure or not.
902 */ 993 */
903 private boolean isHttpFailureCode(int httpResultCode) { 994 private boolean isHttpFailureCode(int httpResultCode) {
904 return httpResultCode <= 0 || httpResultCode >= 400; 995 return httpResultCode <= 0 || httpResultCode >= 400;
905 } 996 }
906 997
907 /** 998 /**
908 * @return whether a navigation in the search content view should promote to a separate tab. 999 * @return whether a navigation in the search content view should promote to a separate tab.
909 */ 1000 */
910 private boolean shouldPromoteSearchNavigation() { 1001 private boolean shouldPromoteSearchNavigation() {
911 // A navigation can be due to us loading a URL, or a touch in the search content view. 1002 // A navigation can be due to us loading a URL, or a touch in the search content view.
912 // Require a touch, but no recent loading, in order to promote to a sepa rate tab. 1003 // Require a touch, but no recent loading, in order to promote to a sepa rate tab.
913 // Note that tapping the opt-in button requires checking for recent load ing. 1004 // Note that tapping the opt-in button requires checking for recent load ing.
914 return mSearchPanelDelegate.didTouchSearchContentView() 1005 return mSearchPanelDelegate.didTouchSearchContentView()
915 && !mSearchPanelDelegate.didLoadAnyUrl(); 1006 && !mSearchPanelDelegate.didLoadAnyUrl();
916 } 1007 }
917 1008
918 /** 1009 /**
919 * Called to check if an external navigation is being done and take the appr opriate action: 1010 * Called to check if an external navigation is being done and take the appr opriate action:
920 * Auto-promotes the panel into a separate tab if that's not already being d one. 1011 * Auto-promotes the panel into a separate tab if that's not already being d one.
921 * @param url The URL we are navigating to. 1012 * @param url The URL we are navigating to.
922 */ 1013 */
923 @Override
924 public void onExternalNavigation(String url) { 1014 public void onExternalNavigation(String url) {
925 mSearchPanelDelegate.updateTopControlState(); 1015 mSearchPanelDelegate.updateTopControlState();
926 1016
927 if (!mDidPromoteSearchNavigation 1017 if (!mDidPromoteSearchNavigation
928 && !BLACKLISTED_URL.equals(url) 1018 && !BLACKLISTED_URL.equals(url)
929 && !url.startsWith(INTENT_URL_PREFIX) 1019 && !url.startsWith(INTENT_URL_PREFIX)
930 && shouldPromoteSearchNavigation()) { 1020 && shouldPromoteSearchNavigation()) {
931 // Do not promote to a regular tab if we're loading our Resolved Sea rch 1021 // Do not promote to a regular tab if we're loading our Resolved Sea rch
932 // URL, otherwise we'll promote it when prefetching the Serp. 1022 // URL, otherwise we'll promote it when prefetching the Serp.
933 // Don't promote URLs when they are navigating to an intent - this i s 1023 // Don't promote URLs when they are navigating to an intent - this i s
934 // handled by the InterceptNavigationDelegate which uses a faster 1024 // handled by the InterceptNavigationDelegate which uses a faster
935 // maximizing animation. 1025 // maximizing animation.
936 mDidPromoteSearchNavigation = true; 1026 mDidPromoteSearchNavigation = true;
937 mSearchPanelDelegate.maximizePanelThenPromoteToTab(StateChangeReason .SERP_NAVIGATION); 1027 mSearchPanelDelegate.maximizePanelThenPromoteToTab(StateChangeReason .SERP_NAVIGATION);
938 } 1028 }
939 } 1029 }
940 1030
941 @Override 1031 /**
1032 * This method is called when the panel's ContentViewCore is created.
1033 * @param contentView The created ContentViewCore.
1034 */
942 public void onContentViewCreated(ContentViewCore contentView) { 1035 public void onContentViewCreated(ContentViewCore contentView) {
943 // TODO(mdjones): Move SearchContentViewDelegate ownership to panel. 1036 // TODO(mdjones): Move SearchContentViewDelegate ownership to panel.
944 mSearchContentViewDelegate.setContextualSearchContentViewCore(contentVie w); 1037 mSearchContentViewDelegate.setContextualSearchContentViewCore(contentVie w);
945 } 1038 }
946 1039
947 @Override 1040 /**
1041 * This method is called when the panel's ContentViewCore is destroyed.
1042 */
948 public void onContentViewDestroyed() { 1043 public void onContentViewDestroyed() {
949 if (mSearchContentViewDelegate != null) { 1044 if (mSearchContentViewDelegate != null) {
950 mSearchContentViewDelegate.releaseContextualSearchContentViewCore(); 1045 mSearchContentViewDelegate.releaseContextualSearchContentViewCore();
951 } 1046 }
952 } 1047 }
953 1048
954 @Override 1049 @Override
955 public void openResolvedSearchUrlInNewTab() { 1050 public void openResolvedSearchUrlInNewTab() {
956 if (mSearchRequest != null && mSearchRequest.getSearchUrl() != null) { 1051 if (mSearchRequest != null && mSearchRequest.getSearchUrl() != null) {
957 openUrlInNewTab(mSearchRequest.getSearchUrl()); 1052 openUrlInNewTab(mSearchRequest.getSearchUrl());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 ? entry.getUrl() : searchContentViewCore.getWebContents().getUrl (); 1114 ? entry.getUrl() : searchContentViewCore.getWebContents().getUrl ();
1020 return url; 1115 return url;
1021 } 1116 }
1022 1117
1023 @Override 1118 @Override
1024 public float getSearchContentViewVerticalScroll() { 1119 public float getSearchContentViewVerticalScroll() {
1025 return mSearchPanelDelegate.getContentViewCore() != null 1120 return mSearchPanelDelegate.getContentViewCore() != null
1026 ? mSearchPanelDelegate.getContentViewCore().computeVerticalScrol lOffset() : -1.f; 1121 ? mSearchPanelDelegate.getContentViewCore().computeVerticalScrol lOffset() : -1.f;
1027 } 1122 }
1028 1123
1029 @Override 1124 /**
1125 * This is called when the search panel is shown or is hidden.
1126 * @param isVisible True if the panel is now visible.
1127 */
1030 public void onContentViewVisibilityChanged(boolean isVisible) { 1128 public void onContentViewVisibilityChanged(boolean isVisible) {
1031 if (isVisible) { 1129 if (isVisible) {
1032 mWereSearchResultsSeen = true; 1130 mWereSearchResultsSeen = true;
1033 // If there's no current request, then either a search term resoluti on 1131 // If there's no current request, then either a search term resoluti on
1034 // is in progress or we should do a verbatim search now. 1132 // is in progress or we should do a verbatim search now.
1035 if (mSearchRequest == null 1133 if (mSearchRequest == null
1036 && mPolicy.shouldCreateVerbatimRequest(mSelectionController, 1134 && mPolicy.shouldCreateVerbatimRequest(mSelectionController,
1037 mNetworkCommunicator.getBasePageUrl())) { 1135 mNetworkCommunicator.getBasePageUrl())) {
1038 mSearchRequest = new ContextualSearchRequest( 1136 mSearchRequest = new ContextualSearchRequest(
1039 mSelectionController.getSelectedText()); 1137 mSelectionController.getSelectedText());
1040 mDidLoadResolvedSearchRequest = false; 1138 mDidLoadResolvedSearchRequest = false;
1041 } 1139 }
1042 if (mSearchRequest != null && !mDidLoadResolvedSearchRequest) { 1140 if ((mSearchRequest != null && !mDidLoadResolvedSearchRequest)
1141 || mShouldLoadDelayedSearch) {
pedro (no code reviews) 2015/09/23 00:00:12 Could you please include a comment here detailing
mdjones 2015/09/23 00:29:31 Done.
1043 mSearchRequest.setNormalPriority(); 1142 mSearchRequest.setNormalPriority();
1044 loadSearchUrl(); 1143 loadSearchUrl();
1045 } 1144 }
1145 mShouldLoadDelayedSearch = true;
1046 mPolicy.updateCountersForOpen(); 1146 mPolicy.updateCountersForOpen();
1047 } 1147 }
1048 } 1148 }
1049 1149
1050 @Override 1150 @Override
1051 public void preserveBasePageSelectionOnNextLossOfFocus() { 1151 public void preserveBasePageSelectionOnNextLossOfFocus() {
1052 ContentViewCore basePageContentView = getBaseContentView(); 1152 ContentViewCore basePageContentView = getBaseContentView();
1053 if (basePageContentView != null) { 1153 if (basePageContentView != null) {
1054 basePageContentView.preserveSelectionOnNextLossOfFocus(); 1154 basePageContentView.preserveSelectionOnNextLossOfFocus();
1055 } 1155 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1271
1172 private native long nativeInit(); 1272 private native long nativeInit();
1173 private native void nativeDestroy(long nativeContextualSearchManager); 1273 private native void nativeDestroy(long nativeContextualSearchManager);
1174 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager, 1274 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager,
1175 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore, 1275 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore,
1176 boolean maySendBasePageUrl); 1276 boolean maySendBasePageUrl);
1177 private native void nativeGatherSurroundingText(long nativeContextualSearchM anager, 1277 private native void nativeGatherSurroundingText(long nativeContextualSearchM anager,
1178 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore, 1278 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore,
1179 boolean maySendBasePageUrl); 1279 boolean maySendBasePageUrl);
1180 } 1280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698