@@ -1440,6 +1440,9 @@ public void onTrimMemory(int level) {
14401440 // Used to notify listeners of a new picture.
14411441 private PictureListener mPictureListener ;
14421442
1443+ // Used to notify listeners about find-on-page results.
1444+ private FindListener mFindListener ;
1445+
14431446 /**
14441447 * Refer to {@link WebView#requestFocusNodeHref(Message)} for more information
14451448 */
@@ -3694,6 +3697,17 @@ public WebBackForwardList copyBackForwardList() {
36943697 return mCallbackProxy .getBackForwardList ().clone ();
36953698 }
36963699
3700+ /**
3701+ * Register the interface to be used when a find-on-page result has become
3702+ * available. This will replace the current handler.
3703+ *
3704+ * @param listener An implementation of FindListener
3705+ */
3706+ public void setFindListener (FindListener listener ) {
3707+ checkThread ();
3708+ mFindListener = listener ;
3709+ }
3710+
36973711 /**
36983712 * See {@link WebView#findNext(boolean)}
36993713 */
@@ -3723,6 +3737,7 @@ private int findAllBody(String find, boolean isAsync) {
37233737 checkThread ();
37243738 if (0 == mNativeClass ) return 0 ; // client isn't initialized
37253739 mLastFind = find ;
3740+ if (find == null ) return 0 ;
37263741 mWebViewCore .removeMessages (EventHub .FIND_ALL );
37273742 WebViewCore .FindAllRequest request = new
37283743 WebViewCore .FindAllRequest (find );
@@ -8478,10 +8493,11 @@ public void handleMessage(Message msg) {
84788493 }
84798494
84808495 case UPDATE_MATCH_COUNT : {
8481- if (mFindCallback != null ) {
8482- mFindCallback .updateMatchCount (msg .arg1 , msg .arg2 ,
8483- (String ) msg .obj );
8484- }
8496+ boolean isNewFind = mLastFind == null || !mLastFind .equals (msg .obj );
8497+ if (mFindCallback != null )
8498+ mFindCallback .updateMatchCount (msg .arg1 , msg .arg2 , isNewFind );
8499+ if (mFindListener != null )
8500+ mFindListener .onFindResultReceived (msg .arg1 , msg .arg2 , true );
84858501 break ;
84868502 }
84878503 case CLEAR_CARET_HANDLE :
0 commit comments