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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 10941015: [Android] Upstream the WebView find-in-page API implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.view.ViewGroup; 7 import android.view.ViewGroup;
8 import android.os.Message; 8 import android.os.Message;
9 9
10 import org.chromium.base.CalledByNative; 10 import org.chromium.base.CalledByNative;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 */ 55 */
56 public AwContents(ViewGroup containerView, 56 public AwContents(ViewGroup containerView,
57 ContentViewCore.InternalAccessDelegate internalAccessAdapter, 57 ContentViewCore.InternalAccessDelegate internalAccessAdapter,
58 ContentViewCore contentViewCore, AwContentsClient contentsClient, 58 ContentViewCore contentViewCore, AwContentsClient contentsClient,
59 boolean privateBrowsing, boolean isAccessFromFileURLsGrantedByDefault) { 59 boolean privateBrowsing, boolean isAccessFromFileURLsGrantedByDefault) {
60 mNativeAwContents = nativeInit(contentsClient.getWebContentsDelegate(), pr ivateBrowsing); 60 mNativeAwContents = nativeInit(contentsClient.getWebContentsDelegate(), pr ivateBrowsing);
61 mContentViewCore = contentViewCore; 61 mContentViewCore = contentViewCore;
62 mContentsClient = contentsClient; 62 mContentsClient = contentsClient;
63 mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNative AwContents)); 63 mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNative AwContents));
64 64
65 // TODO: upstream the needed ContentViewCore initialization method. 65 mContentViewCore.initialize(containerView, internalAccessAdapter, false,
66 // mContentViewCore.initialize(containerView, internalAccessAdapter, false , 66 nativeGetWebContents(mNativeAwContents), isAccessFromFileURLsGrantedBy Default);
67 // nativeGetWebContents(mNativeAwContents), isAccessFromFileURLsGrante dByDefault);
68 mContentViewCore.setContentViewClient(contentsClient); 67 mContentViewCore.setContentViewClient(contentsClient);
69 } 68 }
70 69
71 public ContentViewCore getContentViewCore() { 70 public ContentViewCore getContentViewCore() {
72 return mContentViewCore; 71 return mContentViewCore;
73 } 72 }
74 73
75 public void destroy() { 74 public void destroy() {
76 if (mContentViewCore != null) { 75 if (mContentViewCore != null) {
77 mContentViewCore.destroy(); 76 mContentViewCore.destroy();
78 mContentViewCore = null; 77 mContentViewCore = null;
79 } 78 }
80 mCleanupReference.cleanupNow(); 79 mCleanupReference.cleanupNow();
81 } 80 }
82 81
82 public int findAllSync(String searchString) {
83 return nativeFindAllSync(mNativeAwContents, searchString);
84 }
85
86 public void findAllAsync(String searchString) {
87 nativeFindAllAsync(mNativeAwContents, searchString);
88 }
89
90 public void findNext(boolean forward) {
91 nativeFindNext(mNativeAwContents, forward);
92 }
93
94 public void clearMatches() {
95 nativeClearMatches(mNativeAwContents);
96 }
97
83 /** 98 /**
84 * @return load progress of the WebContents 99 * @return load progress of the WebContents.
85 */ 100 */
86 public int getMostRecentProgress() { 101 public int getMostRecentProgress() {
87 // WebContentsDelegateAndroid conveniently caches the most recent notifi ed value for us. 102 // WebContentsDelegateAndroid conveniently caches the most recent notifi ed value for us.
88 return mContentsClient.getWebContentsDelegate().getMostRecentProgress(); 103 return mContentsClient.getWebContentsDelegate().getMostRecentProgress();
89 } 104 }
90 105
91 //-------------------------------------------------------------------------- ------------------ 106 //-------------------------------------------------------------------------- ------------------
92 // WebView[Provider] method implementations (where not provided by ContentV iewCore) 107 // WebView[Provider] method implementations (where not provided by ContentV iewCore)
93 //-------------------------------------------------------------------------- ------------------ 108 //-------------------------------------------------------------------------- ------------------
94 109
95 public void documentHasImages(Message message) { 110 public void documentHasImages(Message message) {
96 nativeDocumentHasImages(mNativeAwContents, message); 111 nativeDocumentHasImages(mNativeAwContents, message);
97 } 112 }
98 113
99 //-------------------------------------------------------------------------- ------------------ 114 //-------------------------------------------------------------------------- ------------------
100 // Methods called from native via JNI 115 // Methods called from native via JNI
101 //-------------------------------------------------------------------------- ------------------ 116 //-------------------------------------------------------------------------- ------------------
102 117
103 @CalledByNative 118 @CalledByNative
104 private static void onDocumentHasImagesResponse(boolean result, Message mess age) { 119 private static void onDocumentHasImagesResponse(boolean result, Message mess age) {
105 message.arg1 = result ? 1 : 0; 120 message.arg1 = result ? 1 : 0;
106 message.sendToTarget(); 121 message.sendToTarget();
107 } 122 }
108 123
109 @CalledByNative 124 @CalledByNative
110 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos t, String realm) { 125 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos t, String realm) {
111 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); 126 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm);
112 } 127 }
113 128
129 @CalledByNative
130 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches ,
131 boolean isDoneCounting) {
132 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting);
133 }
134
114 //-------------------------------------------------------------------------- ------------------ 135 //-------------------------------------------------------------------------- ------------------
115 // Native methods 136 // Native methods
116 //-------------------------------------------------------------------------- ------------------ 137 //-------------------------------------------------------------------------- ------------------
117 138
118 private native int nativeInit(AwWebContentsDelegate webViewWebContentsDelega te, 139 private native int nativeInit(AwWebContentsDelegate webViewWebContentsDelega te,
119 boolean privateBrowsing); 140 boolean privateBrowsing);
120 private static native void nativeDestroy(int nativeAwContents); 141 private static native void nativeDestroy(int nativeAwContents);
121 142
122 private native int nativeGetWebContents(int nativeAwContents); 143 private native int nativeGetWebContents(int nativeAwContents);
123 144
124 private native void nativeDocumentHasImages(int nativeAwContents, Message me ssage); 145 private native void nativeDocumentHasImages(int nativeAwContents, Message me ssage);
146
147 private native int nativeFindAllSync(int nativeAwContents, String searchStri ng);
148 private native void nativeFindAllAsync(int nativeAwContents, String searchSt ring);
149 private native void nativeFindNext(int nativeAwContents, boolean forward);
150 private native void nativeClearMatches(int nativeAwContents);
125 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698