| 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.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; |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 466 } |
| 467 | 467 |
| 468 // 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 |
| 469 // from history. | 469 // from history. |
| 470 PanelState state = mSearchPanelDelegate.getPanelState(); | 470 PanelState state = mSearchPanelDelegate.getPanelState(); |
| 471 if (!mWereSearchResultsSeen && mLoadedSearchUrlTimeMs != 0L | 471 if (!mWereSearchResultsSeen && mLoadedSearchUrlTimeMs != 0L |
| 472 && state != PanelState.UNDEFINED && state != PanelState.CLOSED)
{ | 472 && state != PanelState.UNDEFINED && state != PanelState.CLOSED)
{ |
| 473 removeLastSearchVisit(); | 473 removeLastSearchVisit(); |
| 474 } | 474 } |
| 475 | 475 |
| 476 mSearchPanelDelegate.setSearchContentViewVisibility(false); | |
| 477 | |
| 478 boolean isTap = mSelectionController.getSelectionType() == SelectionType
.TAP; | 476 boolean isTap = mSelectionController.getSelectionType() == SelectionType
.TAP; |
| 479 boolean didRequestSurroundings = false; | 477 boolean didRequestSurroundings = false; |
| 480 | 478 |
| 481 if (isTap) { | 479 if (isTap) { |
| 482 // If the user action was not a long-press, immediately start loadin
g content. | 480 // If the user action was not a long-press, immediately start loadin
g content. |
| 483 mShouldLoadDelayedSearch = false; | 481 mShouldLoadDelayedSearch = false; |
| 484 } | 482 } |
| 485 | 483 |
| 486 if (isTap && mPolicy.shouldPreviousTapResolve( | 484 if (isTap && mPolicy.shouldPreviousTapResolve( |
| 487 mNetworkCommunicator.getBasePageUrl())) { | 485 mNetworkCommunicator.getBasePageUrl())) { |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 } | 989 } |
| 992 | 990 |
| 993 /** | 991 /** |
| 994 * @return whether a navigation in the search content view should promote to
a separate tab. | 992 * @return whether a navigation in the search content view should promote to
a separate tab. |
| 995 */ | 993 */ |
| 996 private boolean shouldPromoteSearchNavigation() { | 994 private boolean shouldPromoteSearchNavigation() { |
| 997 // A navigation can be due to us loading a URL, or a touch in the search
content view. | 995 // A navigation can be due to us loading a URL, or a touch in the search
content view. |
| 998 // Require a touch, but no recent loading, in order to promote to a sepa
rate tab. | 996 // Require a touch, but no recent loading, in order to promote to a sepa
rate tab. |
| 999 // Note that tapping the opt-in button requires checking for recent load
ing. | 997 // Note that tapping the opt-in button requires checking for recent load
ing. |
| 1000 return mSearchPanelDelegate.didTouchSearchContentView() | 998 return mSearchPanelDelegate.didTouchSearchContentView() |
| 1001 && !mSearchPanelDelegate.didLoadAnyUrl(); | 999 && !mSearchPanelDelegate.isProcessingPendingNavigation(); |
| 1002 } | 1000 } |
| 1003 | 1001 |
| 1004 /** | 1002 /** |
| 1005 * Called to check if an external navigation is being done and take the appr
opriate action: | 1003 * Called to check if an external navigation is being done and take the appr
opriate action: |
| 1006 * Auto-promotes the panel into a separate tab if that's not already being d
one. | 1004 * Auto-promotes the panel into a separate tab if that's not already being d
one. |
| 1007 * @param url The URL we are navigating to. | 1005 * @param url The URL we are navigating to. |
| 1008 */ | 1006 */ |
| 1009 public void onExternalNavigation(String url) { | 1007 public void onExternalNavigation(String url) { |
| 1010 mSearchPanelDelegate.updateTopControlState(); | 1008 mSearchPanelDelegate.updateTopControlState(); |
| 1011 | 1009 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 | 1220 |
| 1223 private native long nativeInit(); | 1221 private native long nativeInit(); |
| 1224 private native void nativeDestroy(long nativeContextualSearchManager); | 1222 private native void nativeDestroy(long nativeContextualSearchManager); |
| 1225 private native void nativeStartSearchTermResolutionRequest(long nativeContex
tualSearchManager, | 1223 private native void nativeStartSearchTermResolutionRequest(long nativeContex
tualSearchManager, |
| 1226 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, | 1224 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, |
| 1227 boolean maySendBasePageUrl); | 1225 boolean maySendBasePageUrl); |
| 1228 private native void nativeGatherSurroundingText(long nativeContextualSearchM
anager, | 1226 private native void nativeGatherSurroundingText(long nativeContextualSearchM
anager, |
| 1229 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, | 1227 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, |
| 1230 boolean maySendBasePageUrl); | 1228 boolean maySendBasePageUrl); |
| 1231 } | 1229 } |
| OLD | NEW |