diff options
13 files changed, 5 insertions, 359 deletions
diff --git a/android_webview/browser/find_helper.cc b/android_webview/browser/find_helper.cc index b4c7669..56dbe49d 100644 --- a/android_webview/browser/find_helper.cc +++ b/android_webview/browser/find_helper.cc @@ -35,41 +35,6 @@ void FindHelper::SetListener(Listener* listener) { listener_ = listener; } -int FindHelper::FindAllSync(const string16& search_string) { - sync_find_started_ = true; - async_find_started_ = false; - - WebFindOptions options; - options.forward = true; - options.matchCase = false; - options.findNext = false; - - int match_count = 0; - int active_ordinal = 0; - - StartNewRequest(search_string); - - // Any ongoing asynchronous requests will be stopped in the renderer when - // calling SynchronousFind. Using the asynchronous StopFinding message could - // lead to deadblocks as the message could arrive in the middle of the - // synchronous operation and cancel the reply back. - ScopedAllowWaitForLegacyWebViewApi wait; - web_contents()->GetRenderViewHost()->SynchronousFind(current_request_id_, - search_string, - options, - &match_count, - &active_ordinal); - - // Post the task to ourselves to prevent trigerring the notification before - // we actually return from the request. - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&FindHelper::NotifyResults, weak_factory_.GetWeakPtr(), - active_ordinal, match_count, true)); - - return match_count; -} - void FindHelper::FindAllAsync(const string16& search_string) { // Stop any ongoing asynchronous request. web_contents()->GetRenderViewHost()->StopFinding( diff --git a/android_webview/browser/find_helper.h b/android_webview/browser/find_helper.h index a9d7aed..7662ec5 100644 --- a/android_webview/browser/find_helper.h +++ b/android_webview/browser/find_helper.h @@ -31,9 +31,6 @@ class FindHelper : public content::WebContentsObserver { // Does not own the listener and must set to NULL when invalid. void SetListener(Listener* listener); - // Synchronous API. - int FindAllSync(const string16& search_string); - // Asynchronous API. void FindAllAsync(const string16& search_string); void HandleFindReply(int request_id, diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index ac01bc9..5db36f0 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -381,9 +381,12 @@ public class AwContents { nativeEnableOnNewPicture(mNativeAwContents, enabled, invalidationOnly); } + // This is no longer synchronous and just calls the Async version and return 0. + // TODO(boliu): Remove this method. + @Deprecated public int findAllSync(String searchString) { - if (mNativeAwContents == 0) return 0; - return nativeFindAllSync(mNativeAwContents, searchString); + findAllAsync(searchString); + return 0; } public void findAllAsync(String searchString) { @@ -1055,7 +1058,6 @@ public class AwContents { private native void nativeAddVisitedLinks(int nativeAwContents, String[] visitedLinks); private native void nativeSetScrollForHWFrame(int nativeAwContents, int scrollX, int scrollY); - private native int nativeFindAllSync(int nativeAwContents, String searchString); private native void nativeFindAllAsync(int nativeAwContents, String searchString); private native void nativeFindNext(int nativeAwContents, boolean forward); private native void nativeClearMatches(int nativeAwContents); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/WebViewMixedFindApisTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/WebViewMixedFindApisTest.java deleted file mode 100644 index b5a7313..0000000 --- a/android_webview/javatests/src/org/chromium/android_webview/test/WebViewMixedFindApisTest.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.android_webview.test; - -import android.test.suitebuilder.annotation.SmallTest; - -import org.chromium.base.test.util.Feature; - -/** - * Tests the mixed use of synchronous and asynchronous find-in-page APIs in WebView. - * Helps to spot race conditions or potential deadlocks caused by the renderer receiving - * asynchronous messages while synchronous requests are being processed. - */ -public class WebViewMixedFindApisTest extends WebViewFindApisTestBase { - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testAsyncFindOperationsMixedWithSyncFind() throws Throwable { - clearMatchesOnUiThread(); - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(4, findAllSyncOnUiThread("wood")); - clearMatchesOnUiThread(); - assertEquals(4, findAllAsyncOnUiThread("wood")); - assertEquals(3, findNextOnUiThread(true)); - clearMatchesOnUiThread(); - assertEquals(4, findAllSyncOnUiThread("wood")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testInterleavedFinds() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(4, findAllAsyncOnUiThread("wood")); - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(3, findNextOnUiThread(true)); - assertEquals(4, findAllAsyncOnUiThread("wood")); - assertEquals(1, findNextOnUiThread(true)); - assertEquals(4, findAllSyncOnUiThread("wood")); - } -} diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/WebViewSynchronousFindApisTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/WebViewSynchronousFindApisTest.java deleted file mode 100644 index d4c4859..0000000 --- a/android_webview/javatests/src/org/chromium/android_webview/test/WebViewSynchronousFindApisTest.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.android_webview.test; - -import android.test.FlakyTest; -import android.test.suitebuilder.annotation.SmallTest; - -import org.chromium.base.test.util.Feature; - -/** - * Tests the synchronous find-in-page APIs in WebView. - */ -public class WebViewSynchronousFindApisTest extends WebViewFindApisTestBase { - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllFinds() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllDouble() throws Throwable { - findAllSyncOnUiThread("wood"); - assertEquals(4, findAllSyncOnUiThread("chuck")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllDoubleNext() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(2, findNextOnUiThread(true)); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllDoesNotFind() throws Throwable { - assertEquals(0, findAllSyncOnUiThread("foo")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllEmptyPage() throws Throwable { - assertEquals(0, findAllSyncOnUiThread("foo")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllEmptyString() throws Throwable { - assertEquals(0, findAllSyncOnUiThread("")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindNextForward() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - - for (int i = 2; i <= 4; i++) { - assertEquals(i - 1, findNextOnUiThread(true)); - } - assertEquals(0, findNextOnUiThread(true)); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindNextBackward() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - - for (int i = 4; i >= 1; i--) { - assertEquals(i - 1, findNextOnUiThread(false)); - } - assertEquals(3, findNextOnUiThread(false)); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindNextBig() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - - assertEquals(1, findNextOnUiThread(true)); - assertEquals(0, findNextOnUiThread(false)); - assertEquals(3, findNextOnUiThread(false)); - for (int i = 1; i <= 4; i++) { - assertEquals(i - 1, findNextOnUiThread(true)); - } - assertEquals(0, findNextOnUiThread(true)); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindAllEmptyNext() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(1, findNextOnUiThread(true)); - assertEquals(0, findAllSyncOnUiThread("")); - assertEquals(0, findNextOnUiThread(true)); - assertEquals(0, findAllSyncOnUiThread("")); - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(1, findNextOnUiThread(true)); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testClearMatches() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - clearMatchesOnUiThread(); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testClearFindNext() throws Throwable { - assertEquals(4, findAllSyncOnUiThread("wood")); - clearMatchesOnUiThread(); - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(2, findNextOnUiThread(true)); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindEmptyNext() throws Throwable { - assertEquals(0, findAllSyncOnUiThread("")); - assertEquals(0, findNextOnUiThread(true)); - assertEquals(4, findAllSyncOnUiThread("wood")); - } - - @SmallTest - @Feature({"AndroidWebView", "FindInPage"}) - public void testFindNextFirst() throws Throwable { - runTestOnUiThread(new Runnable() { - @Override - public void run() { - contents().findNext(true); - } - }); - assertEquals(4, findAllSyncOnUiThread("wood")); - assertEquals(1, findNextOnUiThread(true)); - assertEquals(0, findNextOnUiThread(false)); - assertEquals(3, findNextOnUiThread(false)); - } -} diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 4176419..f740291 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -439,11 +439,6 @@ void AwContents::HideGeolocationPrompt(const GURL& origin) { } } -jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { - return GetFindHelper()->FindAllSync( - ConvertJavaStringToUTF16(env, search_string)); -} - void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); } diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index 06698d5..a72dc32 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -138,7 +138,6 @@ class AwContents : public FindHelper::Listener, jstring origin); // Find-in-page API and related methods. - jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); void FindNext(JNIEnv* env, jobject obj, jboolean forward); void ClearMatches(JNIEnv* env, jobject obj); diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 40f36c0..1d0a0be 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -578,20 +578,6 @@ void RenderViewHostImpl::ActivateNearestFindResult(int request_id, void RenderViewHostImpl::RequestFindMatchRects(int current_version) { Send(new ViewMsg_FindMatchRects(GetRoutingID(), current_version)); } - -void RenderViewHostImpl::SynchronousFind(int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - int* match_count, - int* active_ordinal) { - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableWebViewSynchronousAPIs)) { - return; - } - - Send(new ViewMsg_SynchronousFind(GetRoutingID(), request_id, search_text, - options, match_count, active_ordinal)); -} #endif void RenderViewHostImpl::DragTargetDragEnter( diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h index 2a0c8a2..4b33cc0 100644 --- a/content/browser/renderer_host/render_view_host_impl.h +++ b/content/browser/renderer_host/render_view_host_impl.h @@ -214,11 +214,6 @@ class CONTENT_EXPORT RenderViewHostImpl float x, float y) OVERRIDE; virtual void RequestFindMatchRects(int current_version) OVERRIDE; - virtual void SynchronousFind(int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - int* match_count, - int* active_ordinal) OVERRIDE; #endif void set_delegate(RenderViewHostDelegate* d) { diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 800c045..3de8045 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1326,21 +1326,6 @@ IPC_MESSAGE_ROUTED3(ViewMsg_ActivateNearestFindResult, IPC_MESSAGE_ROUTED1(ViewMsg_FindMatchRects, int /* current_version */) -// Sent when the user wants to search for all occurrences of a word or find -// the next result in a synchronous way. This method forces the UI thread in -// the browser to wait for the renderer to reply, therefore blocking the UI. -// -// This functionality is required for compatibility with the legacy Android -// WebView API. As this goes strongly against the Chromium design guidelines, -// don't use this as inspiration. -// -IPC_SYNC_MESSAGE_ROUTED3_2(ViewMsg_SynchronousFind, - int /* request_id */, - string16 /* search_string */, - WebKit::WebFindOptions /* options */, - int /* match_count */, - int /* active_ordinal */) - // External popup menus. IPC_MESSAGE_ROUTED2(ViewMsg_SelectPopupMenuItems, bool /* user canceled the popup */, diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h index 10f7724..3da0b67 100644 --- a/content/public/browser/render_view_host.h +++ b/content/public/browser/render_view_host.h @@ -285,14 +285,6 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost { // Asks the renderer to send the rects of the current find matches. virtual void RequestFindMatchRects(int current_version) = 0; - - // Synchronous find request. Returns the number of matches found and the - // ordinal of the active match. Required by the legacy Android WebView API. - virtual void SynchronousFind(int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - int* match_count, - int* active_ordinal) = 0; #endif }; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 53e390b..e6abe7b 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -649,7 +649,6 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) update_frame_info_scheduled_(false), expected_content_intent_id_(0), media_player_proxy_(NULL), - synchronous_find_active_match_ordinal_(-1), enumeration_completion_id_(0), ALLOW_THIS_IN_INITIALIZER_LIST( load_progress_tracker_(new LoadProgressTracker(this))), @@ -1105,7 +1104,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { OnActivateNearestFindResult) IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) - IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewMsg_SynchronousFind, OnSynchronousFind) IPC_MESSAGE_HANDLER(ViewMsg_UndoScrollFocusedEditableNodeIntoView, OnUndoScrollFocusedEditableNodeIntoRect) IPC_MESSAGE_HANDLER(ViewMsg_EnableHidingTopControls, @@ -4243,19 +4241,6 @@ void RenderViewImpl::SendFindReply(int request_id, int ordinal, const WebRect& selection_rect, bool final_status_update) { -#if defined(OS_ANDROID) - if (synchronous_find_reply_message_.get()) { - if (final_status_update) { - ViewMsg_SynchronousFind::WriteReplyParams( - synchronous_find_reply_message_.get(), - match_count, - match_count ? synchronous_find_active_match_ordinal_ : 0); - Send(synchronous_find_reply_message_.release()); - } - return; - } -#endif - Send(new ViewHostMsg_Find_Reply(routing_id_, request_id, match_count, @@ -4302,15 +4287,6 @@ void RenderViewImpl::reportFindInPageMatchCount(int request_id, void RenderViewImpl::reportFindInPageSelection(int request_id, int active_match_ordinal, const WebRect& selection_rect) { -#if defined(OS_ANDROID) - // If this was a SynchronousFind request, we need to remember the ordinal - // value here for replying when reportFindInPageMatchCount is called. - if (synchronous_find_reply_message_.get()) { - synchronous_find_active_match_ordinal_ = active_match_ordinal; - return; - } -#endif - SendFindReply(request_id, -1, active_match_ordinal, @@ -4886,19 +4862,6 @@ WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { void RenderViewImpl::OnFind(int request_id, const string16& search_text, const WebFindOptions& options) { -#if defined(OS_ANDROID) - // Make sure any asynchronous messages do not disrupt an ongoing synchronous - // find request as it might lead to deadlocks. Also, these should be safe to - // ignore since they would belong to a previous find request. - if (synchronous_find_reply_message_.get()) - return; -#endif - Find(request_id, search_text, options); -} - -void RenderViewImpl::Find(int request_id, - const string16& search_text, - const WebFindOptions& options) { WebFrame* main_frame = webview()->mainFrame(); // Check if the plugin still exists in the document. @@ -5015,18 +4978,6 @@ void RenderViewImpl::Find(int request_id, } void RenderViewImpl::OnStopFinding(StopFindAction action) { -#if defined(OS_ANDROID) - // Make sure any asynchronous messages do not disrupt an ongoing synchronous - // find request as it might lead to deadlocks. Also, these should be safe to - // ignore since they would belong to a previous find request. - if (synchronous_find_reply_message_.get()) - return; -#endif - - StopFinding(action); -} - -void RenderViewImpl::StopFinding(StopFindAction action) { WebView* view = webview(); if (!view) return; @@ -5061,23 +5012,6 @@ void RenderViewImpl::StopFinding(StopFindAction action) { } #if defined(OS_ANDROID) -void RenderViewImpl::OnSynchronousFind(int request_id, - const string16& search_string, - const WebFindOptions& options, - IPC::Message* reply_msg) { - // It is impossible for simultaneous blocking finds to occur. - CHECK(!synchronous_find_reply_message_.get()); - synchronous_find_reply_message_.reset(reply_msg); - - // Find next should be asynchronous in order to minimize blocking - // the UI thread as much as possible. - DCHECK(!options.findNext); - StopFinding(STOP_FIND_ACTION_KEEP_SELECTION); - synchronous_find_active_match_ordinal_ = -1; - - Find(request_id, search_string, options); -} - void RenderViewImpl::OnActivateNearestFindResult(int request_id, float x, float y) { if (!webview()) diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 80b4c21..c11df2c 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -1065,10 +1065,6 @@ class CONTENT_EXPORT RenderViewImpl void OnFindMatchRects(int current_version); void OnSelectPopupMenuItems(bool canceled, const std::vector<int>& selected_indices); - void OnSynchronousFind(int request_id, - const string16& search_string, - const WebKit::WebFindOptions& options, - IPC::Message* reply_msg); void OnUndoScrollFocusedEditableNodeIntoRect(); void OnEnableHidingTopControls(bool enable); #elif defined(OS_MACOSX) @@ -1140,11 +1136,6 @@ class CONTENT_EXPORT RenderViewImpl // doesn't have a frame at the specified size, the first is returned. bool DownloadFavicon(int id, const GURL& image_url, int image_size); - // Starts a new find-in-page search or looks for the next match. - void Find(int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options); - GURL GetAlternateErrorPageURL(const GURL& failed_url, ErrorPageType error_type); @@ -1205,9 +1196,6 @@ class CONTENT_EXPORT RenderViewImpl // Starts nav_state_sync_timer_ if it isn't already running. void StartNavStateSyncTimerIfNecessary(); - // Stops the current find-in-page search. - void StopFinding(StopFindAction action); - // Dispatches the current state of selection on the webpage to the browser if // it has changed. // TODO(varunjain): delete this method once we figure out how to keep @@ -1500,14 +1488,6 @@ class CONTENT_EXPORT RenderViewImpl // created in the renderer process. scoped_ptr<webkit_media::MediaPlayerBridgeManagerImpl> media_bridge_manager_; - // Holds the message used to return find results to the browser during - // synchronous find-in-page requests. Only non-null during these requests. - scoped_ptr<IPC::Message> synchronous_find_reply_message_; - - // The active find-in-page match ordinal during synchronous requests. - // Needed to be remembered across WebKit callbacks. - int synchronous_find_active_match_ordinal_; - // A date/time picker object for date and time related input elements. scoped_ptr<RendererDateTimePicker> date_time_picker_client_; #endif |