| 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 29 matching lines...) Expand all Loading... |
| 40 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 40 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| 41 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; | 41 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; |
| 42 import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager; | 42 import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager; |
| 43 import org.chromium.chrome.browser.widget.findinpage.FindToolbarObserver; | 43 import org.chromium.chrome.browser.widget.findinpage.FindToolbarObserver; |
| 44 import org.chromium.components.navigation_interception.NavigationParams; | 44 import org.chromium.components.navigation_interception.NavigationParams; |
| 45 import org.chromium.content.browser.ContentViewCore; | 45 import org.chromium.content.browser.ContentViewCore; |
| 46 import org.chromium.content.browser.ContextualSearchClient; | 46 import org.chromium.content.browser.ContextualSearchClient; |
| 47 import org.chromium.content_public.browser.GestureStateListener; | 47 import org.chromium.content_public.browser.GestureStateListener; |
| 48 import org.chromium.content_public.browser.LoadUrlParams; | 48 import org.chromium.content_public.browser.LoadUrlParams; |
| 49 import org.chromium.content_public.browser.NavigationEntry; | 49 import org.chromium.content_public.browser.NavigationEntry; |
| 50 import org.chromium.content_public.browser.WebContentsObserver; | |
| 51 import org.chromium.content_public.common.TopControlsState; | 50 import org.chromium.content_public.common.TopControlsState; |
| 52 import org.chromium.ui.base.WindowAndroid; | 51 import org.chromium.ui.base.WindowAndroid; |
| 53 | 52 |
| 54 import java.net.MalformedURLException; | 53 import java.net.MalformedURLException; |
| 55 import java.net.URL; | 54 import java.net.URL; |
| 56 | 55 |
| 57 import javax.annotation.Nullable; | 56 import javax.annotation.Nullable; |
| 58 | 57 |
| 59 | 58 |
| 60 /** | 59 /** |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 | 80 |
| 82 // We blacklist this URL because malformed URLs may bring up this page. | 81 // We blacklist this URL because malformed URLs may bring up this page. |
| 83 private static final String BLACKLISTED_URL = "about:blank"; | 82 private static final String BLACKLISTED_URL = "about:blank"; |
| 84 | 83 |
| 85 private final ContextualSearchSelectionController mSelectionController; | 84 private final ContextualSearchSelectionController mSelectionController; |
| 86 private final ChromeActivity mActivity; | 85 private final ChromeActivity mActivity; |
| 87 private ViewGroup mParentView; | 86 private ViewGroup mParentView; |
| 88 private final ViewTreeObserver.OnGlobalFocusChangeListener mOnFocusChangeLis
tener; | 87 private final ViewTreeObserver.OnGlobalFocusChangeListener mOnFocusChangeLis
tener; |
| 89 | 88 |
| 90 private final WindowAndroid mWindowAndroid; | 89 private final WindowAndroid mWindowAndroid; |
| 91 private WebContentsObserver mSearchWebContentsObserver; | |
| 92 private ContextualSearchContentViewDelegate mSearchContentViewDelegate; | 90 private ContextualSearchContentViewDelegate mSearchContentViewDelegate; |
| 93 private final ContextualSearchTabPromotionDelegate mTabPromotionDelegate; | 91 private final ContextualSearchTabPromotionDelegate mTabPromotionDelegate; |
| 94 private TabModelSelectorTabObserver mTabModelSelectorTabObserver; | 92 private TabModelSelectorTabObserver mTabModelSelectorTabObserver; |
| 95 private TabModelObserver mTabModelObserver; | 93 private TabModelObserver mTabModelObserver; |
| 96 private FindToolbarManager mFindToolbarManager; | 94 private FindToolbarManager mFindToolbarManager; |
| 97 private FindToolbarObserver mFindToolbarObserver; | 95 private FindToolbarObserver mFindToolbarObserver; |
| 98 private boolean mIsSearchContentViewShowing; | 96 private boolean mIsSearchContentViewShowing; |
| 99 private boolean mDidStartLoadingResolvedSearchRequest; | 97 private boolean mDidStartLoadingResolvedSearchRequest; |
| 100 private long mLoadedSearchUrlTimeMs; | 98 private long mLoadedSearchUrlTimeMs; |
| 101 // TODO(donnd): consider changing this member's name to indicate "opened" in
stead of "seen". | 99 // TODO(donnd): consider changing this member's name to indicate "opened" in
stead of "seen". |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 mSearchRequest.setNormalPriority(); | 857 mSearchRequest.setNormalPriority(); |
| 860 loadSearchUrl(); | 858 loadSearchUrl(); |
| 861 } | 859 } |
| 862 mShouldLoadDelayedSearch = true; | 860 mShouldLoadDelayedSearch = true; |
| 863 mPolicy.updateCountersForOpen(); | 861 mPolicy.updateCountersForOpen(); |
| 864 } | 862 } |
| 865 } | 863 } |
| 866 | 864 |
| 867 @Override | 865 @Override |
| 868 public void onContentViewCreated(ContentViewCore contentViewCore) { | 866 public void onContentViewCreated(ContentViewCore contentViewCore) { |
| 867 if (mPolicy.shouldInjectJavaScript()) { |
| 868 // Enable a JavaScript communication channel between our service
and the new view. |
| 869 nativeEnableContextualSearchServiceForView(mNativeContextualSear
chManagerPtr, |
| 870 contentViewCore); |
| 871 } |
| 872 |
| 869 // TODO(mdjones): Move SearchContentViewDelegate ownership to panel. | 873 // TODO(mdjones): Move SearchContentViewDelegate ownership to panel. |
| 870 mSearchContentViewDelegate.setContextualSearchContentViewCore(conten
tViewCore); | 874 mSearchContentViewDelegate.setContextualSearchContentViewCore(conten
tViewCore); |
| 871 } | 875 } |
| 872 | 876 |
| 873 @Override | 877 @Override |
| 874 public void onContentViewDestroyed() { | 878 public void onContentViewDestroyed() { |
| 875 if (mSearchContentViewDelegate != null) { | 879 if (mSearchContentViewDelegate != null) { |
| 876 mSearchContentViewDelegate.releaseContextualSearchContentViewCor
e(); | 880 mSearchContentViewDelegate.releaseContextualSearchContentViewCor
e(); |
| 877 } | 881 } |
| 878 } | 882 } |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 // -------------------------------------------------------------------------
------------------- | 1225 // -------------------------------------------------------------------------
------------------- |
| 1222 | 1226 |
| 1223 private native long nativeInit(); | 1227 private native long nativeInit(); |
| 1224 private native void nativeDestroy(long nativeContextualSearchManager); | 1228 private native void nativeDestroy(long nativeContextualSearchManager); |
| 1225 private native void nativeStartSearchTermResolutionRequest(long nativeContex
tualSearchManager, | 1229 private native void nativeStartSearchTermResolutionRequest(long nativeContex
tualSearchManager, |
| 1226 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, | 1230 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, |
| 1227 boolean maySendBasePageUrl); | 1231 boolean maySendBasePageUrl); |
| 1228 private native void nativeGatherSurroundingText(long nativeContextualSearchM
anager, | 1232 private native void nativeGatherSurroundingText(long nativeContextualSearchM
anager, |
| 1229 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, | 1233 String selection, boolean useResolvedSearchTerm, ContentViewCore bas
eContentViewCore, |
| 1230 boolean maySendBasePageUrl); | 1234 boolean maySendBasePageUrl); |
| 1235 private native void nativeEnableContextualSearchServiceForView( |
| 1236 long nativeContextualSearchManager, ContentViewCore overlayContentVi
ewCore); |
| 1231 } | 1237 } |
| OLD | NEW |