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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
10 import android.view.View; | 10 import android.view.View; |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 assert mContext != null; | 839 assert mContext != null; |
840 String surroundingText = mContext.getSurroundingText(); | 840 String surroundingText = mContext.getSurroundingText(); |
841 assert surroundingText != null; | 841 assert surroundingText != null; |
842 int startOffset = mContext.getSelectionStartOffset(); | 842 int startOffset = mContext.getSelectionStartOffset(); |
843 int endOffset = mContext.getSelectionEndOffset(); | 843 int endOffset = mContext.getSelectionEndOffset(); |
844 if (!ContextualSearchFieldTrial.isPageContentNotificationDisabled()) { | 844 if (!ContextualSearchFieldTrial.isPageContentNotificationDisabled()) { |
845 GSAContextDisplaySelection selection = new GSAContextDisplaySelectio
n( | 845 GSAContextDisplaySelection selection = new GSAContextDisplaySelectio
n( |
846 mContext.getEncoding(), surroundingText, startOffset, endOff
set); | 846 mContext.getEncoding(), surroundingText, startOffset, endOff
set); |
847 notifyShowContextualSearch(selection); | 847 notifyShowContextualSearch(selection); |
848 } | 848 } |
849 mSearchPanel.setWasSelectionPartOfUrl( | |
850 ContextualSearchSelectionController.isSelectionPartOfUrl( | |
851 surroundingText, startOffset, endOffset)); | |
852 } | 849 } |
853 | 850 |
854 /** | 851 /** |
855 * Notifies all Contextual Search observers that a search has occurred. | 852 * Notifies all Contextual Search observers that a search has occurred. |
856 * @param selectionContext The selection and context that triggered the sear
ch. | 853 * @param selectionContext The selection and context that triggered the sear
ch. |
857 */ | 854 */ |
858 private void notifyShowContextualSearch(GSAContextDisplaySelection selection
Context) { | 855 private void notifyShowContextualSearch(GSAContextDisplaySelection selection
Context) { |
859 if (!mPolicy.canSendSurroundings()) selectionContext = null; | 856 if (!mPolicy.canSendSurroundings()) selectionContext = null; |
860 | 857 |
861 for (ContextualSearchObserver observer : mObservers) { | 858 for (ContextualSearchObserver observer : mObservers) { |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 private native void nativeStartSearchTermResolutionRequest(long nativeContex
tualSearchManager, | 1573 private native void nativeStartSearchTermResolutionRequest(long nativeContex
tualSearchManager, |
1577 ContextualSearchContext contextualSearchContext, WebContents baseWeb
Contents); | 1574 ContextualSearchContext contextualSearchContext, WebContents baseWeb
Contents); |
1578 protected native void nativeGatherSurroundingText(long nativeContextualSearc
hManager, | 1575 protected native void nativeGatherSurroundingText(long nativeContextualSearc
hManager, |
1579 ContextualSearchContext contextualSearchContext, WebContents baseWeb
Contents); | 1576 ContextualSearchContext contextualSearchContext, WebContents baseWeb
Contents); |
1580 private native void nativeEnableContextualSearchJsApiForOverlay( | 1577 private native void nativeEnableContextualSearchJsApiForOverlay( |
1581 long nativeContextualSearchManager, WebContents overlayWebContents); | 1578 long nativeContextualSearchManager, WebContents overlayWebContents); |
1582 // Don't call these directly, instead call the private methods that cache th
e results. | 1579 // Don't call these directly, instead call the private methods that cache th
e results. |
1583 private native String nativeGetTargetLanguage(long nativeContextualSearchMan
ager); | 1580 private native String nativeGetTargetLanguage(long nativeContextualSearchMan
ager); |
1584 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa
nager); | 1581 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa
nager); |
1585 } | 1582 } |
OLD | NEW |