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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 10941015: [Android] Upstream the WebView find-in-page API implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixes + command line switch for synchronous APIs 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 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 media_stream_dispatcher_(NULL), 610 media_stream_dispatcher_(NULL),
611 media_stream_impl_(NULL), 611 media_stream_impl_(NULL),
612 devtools_agent_(NULL), 612 devtools_agent_(NULL),
613 accessibility_mode_(AccessibilityModeOff), 613 accessibility_mode_(AccessibilityModeOff),
614 renderer_accessibility_(NULL), 614 renderer_accessibility_(NULL),
615 java_bridge_dispatcher_(NULL), 615 java_bridge_dispatcher_(NULL),
616 mouse_lock_dispatcher_(NULL), 616 mouse_lock_dispatcher_(NULL),
617 #if defined(OS_ANDROID) 617 #if defined(OS_ANDROID)
618 expected_content_intent_id_(0), 618 expected_content_intent_id_(0),
619 media_player_proxy_(NULL), 619 media_player_proxy_(NULL),
620 synchronous_find_active_match_ordinal_(-1),
620 #endif 621 #endif
621 session_storage_namespace_id_(session_storage_namespace_id), 622 session_storage_namespace_id_(session_storage_namespace_id),
622 handling_select_range_(false), 623 handling_select_range_(false),
623 #if defined(OS_WIN) 624 #if defined(OS_WIN)
624 focused_plugin_id_(-1), 625 focused_plugin_id_(-1),
625 #endif 626 #endif
626 guest_to_embedder_channel_(guest_to_embedder_channel), 627 guest_to_embedder_channel_(guest_to_embedder_channel),
627 guest_pp_instance_(0), 628 guest_pp_instance_(0),
628 guest_uninitialized_context_(NULL), 629 guest_uninitialized_context_(NULL),
629 updating_frame_tree_(false), 630 updating_frame_tree_(false),
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 bool handled = true; 938 bool handled = true;
938 bool msg_is_ok = true; 939 bool msg_is_ok = true;
939 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) 940 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok)
940 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) 941 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
941 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) 942 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
942 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) 943 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame)
943 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) 944 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo)
944 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) 945 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo)
945 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) 946 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut)
946 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) 947 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy)
947 #if defined(OS_MACOSX)
948 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
949 #endif
950 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) 948 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
951 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 949 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
952 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) 950 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
953 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 951 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
954 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 952 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
955 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll) 953 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll)
956 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect) 954 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect)
957 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, 955 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets,
958 OnSetEditableSelectionOffsets) 956 OnSetEditableSelectionOffsets)
959 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, 957 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText,
960 OnSetCompositionFromExistingText) 958 OnSetCompositionFromExistingText)
961 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, 959 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete,
962 OnExtendSelectionAndDelete) 960 OnExtendSelectionAndDelete)
963 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) 961 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
964 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 962 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
965 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 963 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
966 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 964 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
967 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 965 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
968 #if defined(OS_ANDROID)
969 IPC_MESSAGE_HANDLER(ViewMsg_ActivateNearestFindResult,
970 OnActivateNearestFindResult)
971 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects,
972 OnFindMatchRects)
973 #endif
974 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 966 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
975 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 967 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
976 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) 968 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor)
977 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 969 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
978 OnSetZoomLevelForLoadingURL) 970 OnSetZoomLevelForLoadingURL)
979 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 971 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
980 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 972 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
981 OnResetPageEncodingToDefault) 973 OnResetPageEncodingToDefault)
982 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) 974 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest)
983 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) 975 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, 1008 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
1017 OnDisableScrollbarsForSmallWindows) 1009 OnDisableScrollbarsForSmallWindows)
1018 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) 1010 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs)
1019 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) 1011 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
1020 IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent, 1012 IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent,
1021 OnOrientationChangeEvent) 1013 OnOrientationChangeEvent)
1022 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) 1014 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
1023 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) 1015 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
1024 IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime, 1016 IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime,
1025 OnSetNavigationStartTime) 1017 OnSetNavigationStartTime)
1026 #if defined(OS_MACOSX)
1027 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
1028 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
1029 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
1030 OnPluginImeCompositionCompleted)
1031 #endif
1032 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, 1018 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent,
1033 OnSetEditCommandsForNextKeyEvent) 1019 OnSetEditCommandsForNextKeyEvent)
1034 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, 1020 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction,
1035 OnCustomContextMenuAction) 1021 OnCustomContextMenuAction)
1036 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) 1022 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened)
1037 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, 1023 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated,
1038 OnPpapiBrokerChannelCreated) 1024 OnPpapiBrokerChannelCreated)
1039 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, 1025 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult,
1040 OnPpapiBrokerPermissionResult) 1026 OnPpapiBrokerPermissionResult)
1041 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 1027 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
1042 OnGetAllSavableResourceLinksForCurrentPage) 1028 OnGetAllSavableResourceLinksForCurrentPage)
1043 IPC_MESSAGE_HANDLER( 1029 IPC_MESSAGE_HANDLER(
1044 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 1030 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
1045 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1031 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1046 #if defined(OS_MACOSX)
1047 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1048 #elif defined(OS_ANDROID)
1049 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1050 #endif
1051 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) 1032 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed)
1052 // TODO(viettrungluu): Move to a separate message filter. 1033 // TODO(viettrungluu): Move to a separate message filter.
1053 #if defined(OS_MACOSX)
1054 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
1055 #endif
1056 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 1034 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
1057 OnSetHistoryLengthAndPrune) 1035 OnSetHistoryLengthAndPrune)
1058 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1036 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1059 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) 1037 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit)
1060 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) 1038 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode)
1061 IPC_MESSAGE_HANDLER(ViewMsg_UpdateFrameTree, OnUpdatedFrameTree) 1039 IPC_MESSAGE_HANDLER(ViewMsg_UpdateFrameTree, OnUpdatedFrameTree)
1040 #if defined(OS_ANDROID)
1041 IPC_MESSAGE_HANDLER(ViewMsg_ActivateNearestFindResult,
1042 OnActivateNearestFindResult)
1043 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects)
1044 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1045 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewMsg_SynchronousFind, OnSynchronousFind)
1046 #elif defined(OS_MACOSX)
1047 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
1048 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
1049 OnPluginImeCompositionCompleted)
1050 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1051 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
1052 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
1053 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
1054 #endif
1062 1055
1063 // Have the super handle all other messages. 1056 // Have the super handle all other messages.
1064 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) 1057 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
1065 IPC_END_MESSAGE_MAP() 1058 IPC_END_MESSAGE_MAP()
1066 1059
1067 if (!msg_is_ok) { 1060 if (!msg_is_ok) {
1068 // The message had a handler, but its deserialization failed. 1061 // The message had a handler, but its deserialization failed.
1069 // Kill the renderer to avoid potential spoofing attacks. 1062 // Kill the renderer to avoid potential spoofing attacks.
1070 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; 1063 CHECK(false) << "Unable to deserialize message in RenderViewImpl.";
1071 } 1064 }
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 } 3909 }
3917 3910
3918 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { 3911 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) {
3919 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); 3912 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers));
3920 } 3913 }
3921 3914
3922 void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) { 3915 void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) {
3923 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); 3916 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
3924 } 3917 }
3925 3918
3926 void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, 3919 void RenderViewImpl::SendFindReply(int request_id,
3920 int match_count,
3921 int ordinal,
3922 const WebRect& selection_rect,
3923 bool final_status_update) {
3924 #if defined(OS_ANDROID)
3925 if (synchronous_find_reply_message_.get()) {
3926 if (final_status_update) {
3927 ViewMsg_SynchronousFind::WriteReplyParams(
3928 synchronous_find_reply_message_.get(),
3929 match_count,
3930 match_count ? synchronous_find_active_match_ordinal_ : 0);
3931 Send(synchronous_find_reply_message_.release());
3932 }
3933 return;
3934 }
3935 #endif
3936
3937 Send(new ViewHostMsg_Find_Reply(routing_id_,
3938 request_id,
3939 match_count,
3940 selection_rect,
3941 ordinal,
3942 final_status_update));
3943 }
3944
3945 void RenderViewImpl::reportFindInPageMatchCount(int request_id,
3946 int count,
3927 bool final_update) { 3947 bool final_update) {
3928 int active_match_ordinal = -1; // -1 = don't update active match ordinal 3948 int active_match_ordinal = -1; // -1 = don't update active match ordinal
3929 if (!count) 3949 if (!count)
3930 active_match_ordinal = 0; 3950 active_match_ordinal = 0;
3931 3951
3932 Send(new ViewHostMsg_Find_Reply(routing_id_, 3952 // Send the search result over to the browser process.
3933 request_id, 3953 SendFindReply(request_id,
3934 count, 3954 count,
3935 gfx::Rect(), 3955 active_match_ordinal,
3936 active_match_ordinal, 3956 gfx::Rect(),
3937 final_update)); 3957 final_update);
3938 } 3958 }
3939 3959
3940 void RenderViewImpl::reportFindInPageSelection(int request_id, 3960 void RenderViewImpl::reportFindInPageSelection(int request_id,
3941 int active_match_ordinal, 3961 int active_match_ordinal,
3942 const WebRect& selection_rect) { 3962 const WebRect& selection_rect) {
3943 // Send the search result over to the browser process. 3963 #if defined(OS_ANDROID)
3944 Send(new ViewHostMsg_Find_Reply(routing_id_, 3964 // If this was a SynchronousFind request, we need to remember the ordinal
3945 request_id, 3965 // value here for replying when reportFindInPageMatchCount is called.
3946 -1, 3966 if (synchronous_find_reply_message_.get()) {
3947 selection_rect, 3967 synchronous_find_active_match_ordinal_ = active_match_ordinal;
3948 active_match_ordinal, 3968 return;
3949 false)); 3969 }
3970 #endif
3971
3972 SendFindReply(request_id,
3973 -1,
3974 active_match_ordinal,
3975 selection_rect,
3976 false);
3950 } 3977 }
3951 3978
3952 void RenderViewImpl::openFileSystem( 3979 void RenderViewImpl::openFileSystem(
3953 WebFrame* frame, 3980 WebFrame* frame,
3954 WebFileSystem::Type type, 3981 WebFileSystem::Type type,
3955 long long size, 3982 long long size,
3956 bool create, 3983 bool create,
3957 WebFileSystemCallbacks* callbacks) { 3984 WebFileSystemCallbacks* callbacks) {
3958 DCHECK(callbacks); 3985 DCHECK(callbacks);
3959 3986
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
4547 web_ui_bindings_.reset(new WebUIBindings( 4574 web_ui_bindings_.reset(new WebUIBindings(
4548 static_cast<content::RenderView*>(this), routing_id_)); 4575 static_cast<content::RenderView*>(this), routing_id_));
4549 } 4576 }
4550 return web_ui_bindings_.get(); 4577 return web_ui_bindings_.get();
4551 } 4578 }
4552 4579
4553 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { 4580 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() {
4554 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); 4581 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin();
4555 } 4582 }
4556 4583
4557 void RenderViewImpl::OnFind(int request_id, const string16& search_text, 4584 void RenderViewImpl::OnFind(int request_id,
4585 const string16& search_text,
4558 const WebFindOptions& options) { 4586 const WebFindOptions& options) {
4587 #if defined(OS_ANDROID)
4588 // Make sure any asynchronous messages do not disrupt an ongoing synchronous
4589 // find request as it might lead to deadlocks. Also, these should be safe to
4590 // ignore since they would belong to a previous find request.
4591 if (synchronous_find_reply_message_.get())
4592 return;
4593 #endif
4594 Find(request_id, search_text, options);
4595 }
4596
4597 void RenderViewImpl::Find(int request_id,
4598 const string16& search_text,
4599 const WebFindOptions& options) {
4559 WebFrame* main_frame = webview()->mainFrame(); 4600 WebFrame* main_frame = webview()->mainFrame();
4560 4601
4561 // Check if the plugin still exists in the document. 4602 // Check if the plugin still exists in the document.
4562 if (main_frame->document().isPluginDocument() && 4603 if (main_frame->document().isPluginDocument() &&
4563 GetWebPluginFromPluginDocument()) { 4604 GetWebPluginFromPluginDocument()) {
4564 if (options.findNext) { 4605 if (options.findNext) {
4565 // Just navigate back/forward. 4606 // Just navigate back/forward.
4566 GetWebPluginFromPluginDocument()->selectFindResult(options.forward); 4607 GetWebPluginFromPluginDocument()->selectFindResult(options.forward);
4567 } else { 4608 } else {
4568 if (GetWebPluginFromPluginDocument()->startFind( 4609 if (!GetWebPluginFromPluginDocument()->startFind(
4569 search_text, options.matchCase, request_id)) { 4610 search_text, options.matchCase, request_id)) {
4570 } else {
4571 // Send "no results". 4611 // Send "no results".
4572 Send(new ViewHostMsg_Find_Reply(routing_id_, 4612 SendFindReply(request_id, 0, 0, gfx::Rect(), true);
4573 request_id,
4574 0,
4575 gfx::Rect(),
4576 0,
4577 true));
4578 } 4613 }
4579 } 4614 }
4580 return; 4615 return;
4581 } 4616 }
4582 4617
4583 WebFrame* frame_after_main = main_frame->traverseNext(true); 4618 WebFrame* frame_after_main = main_frame->traverseNext(true);
4584 WebFrame* focused_frame = webview()->focusedFrame(); 4619 WebFrame* focused_frame = webview()->focusedFrame();
4585 WebFrame* search_frame = focused_frame; // start searching focused frame. 4620 WebFrame* search_frame = focused_frame; // start searching focused frame.
4586 4621
4587 bool multi_frame = (frame_after_main != main_frame); 4622 bool multi_frame = (frame_after_main != main_frame);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4640 // If nothing is found, set result to "0 of 0", otherwise, set it to 4675 // If nothing is found, set result to "0 of 0", otherwise, set it to
4641 // "-1 of 1" to indicate that we found at least one item, but we don't know 4676 // "-1 of 1" to indicate that we found at least one item, but we don't know
4642 // yet what is active. 4677 // yet what is active.
4643 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. 4678 int ordinal = result ? -1 : 0; // -1 here means, we might know more later.
4644 int match_count = result ? 1 : 0; // 1 here means possibly more coming. 4679 int match_count = result ? 1 : 0; // 1 here means possibly more coming.
4645 4680
4646 // If we find no matches then this will be our last status update. 4681 // If we find no matches then this will be our last status update.
4647 // Otherwise the scoping effort will send more results. 4682 // Otherwise the scoping effort will send more results.
4648 bool final_status_update = !result; 4683 bool final_status_update = !result;
4649 4684
4650 // Send the search result over to the browser process. 4685 SendFindReply(request_id, match_count, ordinal, selection_rect,
4651 Send(new ViewHostMsg_Find_Reply(routing_id_, 4686 final_status_update);
4652 request_id,
4653 match_count,
4654 selection_rect,
4655 ordinal,
4656 final_status_update));
4657 4687
4658 // Scoping effort begins, starting with the mainframe. 4688 // Scoping effort begins, starting with the mainframe.
4659 search_frame = main_frame; 4689 search_frame = main_frame;
4660 4690
4661 main_frame->resetMatchCount(); 4691 main_frame->resetMatchCount();
4662 4692
4663 do { 4693 do {
4664 // Cancel all old scoping requests before starting a new one. 4694 // Cancel all old scoping requests before starting a new one.
4665 search_frame->cancelPendingScopingEffort(); 4695 search_frame->cancelPendingScopingEffort();
4666 4696
4667 // We don't start another scoping effort unless at least one match has 4697 // We don't start another scoping effort unless at least one match has
4668 // been found. 4698 // been found.
4669 if (result) { 4699 if (result) {
4670 // Start new scoping request. If the scoping function determines that it 4700 // Start new scoping request. If the scoping function determines that it
4671 // needs to scope, it will defer until later. 4701 // needs to scope, it will defer until later.
4672 search_frame->scopeStringMatches(request_id, 4702 search_frame->scopeStringMatches(request_id,
4673 search_text, 4703 search_text,
4674 options, 4704 options,
4675 true); // reset the tickmarks 4705 true); // reset the tickmarks
4676 } 4706 }
4677 4707
4678 // Iterate to the next frame. The frame will not necessarily scope, for 4708 // Iterate to the next frame. The frame will not necessarily scope, for
4679 // example if it is not visible. 4709 // example if it is not visible.
4680 search_frame = search_frame->traverseNext(true); 4710 search_frame = search_frame->traverseNext(true);
4681 } while (search_frame != main_frame); 4711 } while (search_frame != main_frame);
4682 } 4712 }
4683 } 4713 }
4684 4714
4685 void RenderViewImpl::OnStopFinding(content::StopFindAction action) { 4715 void RenderViewImpl::OnStopFinding(content::StopFindAction action) {
4716 #if defined(OS_ANDROID)
4717 // Make sure any asynchronous messages do not disrupt an ongoing synchronous
4718 // find request as it might lead to deadlocks. Also, these should be safe to
4719 // ignore since they would belong to a previous find request.
4720 if (synchronous_find_reply_message_.get())
4721 return;
4722 #endif
4723
4724 StopFinding(action);
4725 }
4726
4727 void RenderViewImpl::StopFinding(content::StopFindAction action) {
4686 WebView* view = webview(); 4728 WebView* view = webview();
4687 if (!view) 4729 if (!view)
4688 return; 4730 return;
4689 4731
4690 WebDocument doc = view->mainFrame()->document(); 4732 WebDocument doc = view->mainFrame()->document();
4691 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { 4733 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) {
4692 GetWebPluginFromPluginDocument()->stopFind(); 4734 GetWebPluginFromPluginDocument()->stopFind();
4693 return; 4735 return;
4694 } 4736 }
4695 4737
(...skipping 14 matching lines...) Expand all
4710 if (!doc.isNull()) { 4752 if (!doc.isNull()) {
4711 WebNode node = doc.focusedNode(); 4753 WebNode node = doc.focusedNode();
4712 if (!node.isNull()) 4754 if (!node.isNull())
4713 node.simulateClick(); 4755 node.simulateClick();
4714 } 4756 }
4715 } 4757 }
4716 } 4758 }
4717 } 4759 }
4718 4760
4719 #if defined(OS_ANDROID) 4761 #if defined(OS_ANDROID)
4762 void RenderViewImpl::OnSynchronousFind(int request_id,
4763 const string16& search_string,
4764 const WebFindOptions& options,
4765 IPC::Message* reply_msg) {
4766 // It is impossible for simultaneous blocking finds to occur.
4767 CHECK(!synchronous_find_reply_message_.get());
4768 synchronous_find_reply_message_.reset(reply_msg);
4769
4770 // Find next should be asynchronous in order to minimize blocking
4771 // the UI thread as much as possible.
4772 DCHECK(!options.findNext);
4773 StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
4774 synchronous_find_active_match_ordinal_ = -1;
4775
4776 Find(request_id, search_string, options);
4777 }
4778
4720 void RenderViewImpl::OnActivateNearestFindResult(int request_id, 4779 void RenderViewImpl::OnActivateNearestFindResult(int request_id,
4721 float x, float y) { 4780 float x, float y) {
4722 if (!webview()) 4781 if (!webview())
4723 return; 4782 return;
4724 4783
4725 WebFrame* main_frame = webview()->mainFrame(); 4784 WebFrame* main_frame = webview()->mainFrame();
4726 WebRect selection_rect; 4785 WebRect selection_rect;
4727 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y), 4786 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y),
4728 &selection_rect); 4787 &selection_rect);
4729 if (ordinal == -1) { 4788 if (ordinal == -1) {
4730 // Something went wrong, so send a no-op reply (force the main_frame to 4789 // Something went wrong, so send a no-op reply (force the main_frame to
4731 // report the current match count) in case the host is waiting for a 4790 // report the current match count) in case the host is waiting for a
4732 // response due to rate-limiting). 4791 // response due to rate-limiting).
4733 main_frame->increaseMatchCount(0, request_id); 4792 main_frame->increaseMatchCount(0, request_id);
4734 return; 4793 return;
4735 } 4794 }
4736 4795
4737 Send(new ViewHostMsg_Find_Reply(routing_id_, 4796 SendFindReply(request_id,
4738 request_id, 4797 -1 /* number_of_matches */,
4739 -1 /* number_of_matches */, 4798 ordinal,
4740 selection_rect, 4799 selection_rect,
4741 ordinal, 4800 true /* final_update */);
4742 true /* final_update */));
4743 } 4801 }
4744 4802
4745 void RenderViewImpl::OnFindMatchRects(int current_version) { 4803 void RenderViewImpl::OnFindMatchRects(int current_version) {
4746 if (!webview()) 4804 if (!webview())
4747 return; 4805 return;
4748 4806
4749 WebFrame* main_frame = webview()->mainFrame(); 4807 WebFrame* main_frame = webview()->mainFrame();
4750 std::vector<gfx::RectF> match_rects; 4808 std::vector<gfx::RectF> match_rects;
4751 4809
4752 int rects_version = main_frame->findMatchMarkersVersion(); 4810 int rects_version = main_frame->findMatchMarkersVersion();
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
6178 6236
6179 updating_frame_tree_ = true; 6237 updating_frame_tree_ = true;
6180 active_frame_id_map_.clear(); 6238 active_frame_id_map_.clear();
6181 6239
6182 target_process_id_ = process_id; 6240 target_process_id_ = process_id;
6183 target_routing_id_ = route_id; 6241 target_routing_id_ = route_id;
6184 CreateFrameTree(webview()->mainFrame(), frames); 6242 CreateFrameTree(webview()->mainFrame(), frames);
6185 6243
6186 updating_frame_tree_ = false; 6244 updating_frame_tree_ = false;
6187 } 6245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698