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

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. 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 device_orientation_dispatcher_(NULL), 605 device_orientation_dispatcher_(NULL),
606 media_stream_dispatcher_(NULL), 606 media_stream_dispatcher_(NULL),
607 media_stream_impl_(NULL), 607 media_stream_impl_(NULL),
608 devtools_agent_(NULL), 608 devtools_agent_(NULL),
609 accessibility_mode_(AccessibilityModeOff), 609 accessibility_mode_(AccessibilityModeOff),
610 renderer_accessibility_(NULL), 610 renderer_accessibility_(NULL),
611 java_bridge_dispatcher_(NULL), 611 java_bridge_dispatcher_(NULL),
612 mouse_lock_dispatcher_(NULL), 612 mouse_lock_dispatcher_(NULL),
613 #if defined(OS_ANDROID) 613 #if defined(OS_ANDROID)
614 expected_content_intent_id_(0), 614 expected_content_intent_id_(0),
615 synchronous_find_active_match_ordinal_(-1),
615 #endif 616 #endif
616 session_storage_namespace_id_(session_storage_namespace_id), 617 session_storage_namespace_id_(session_storage_namespace_id),
617 handling_select_range_(false), 618 handling_select_range_(false),
618 #if defined(OS_WIN) 619 #if defined(OS_WIN)
619 focused_plugin_id_(-1), 620 focused_plugin_id_(-1),
620 #endif 621 #endif
621 guest_to_embedder_channel_(guest_to_embedder_channel), 622 guest_to_embedder_channel_(guest_to_embedder_channel),
622 guest_pp_instance_(0), 623 guest_pp_instance_(0),
623 guest_uninitialized_context_(NULL), 624 guest_uninitialized_context_(NULL),
624 updating_frame_tree_(false), 625 updating_frame_tree_(false),
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 bool handled = true; 933 bool handled = true;
933 bool msg_is_ok = true; 934 bool msg_is_ok = true;
934 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) 935 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok)
935 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) 936 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
936 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) 937 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
937 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) 938 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame)
938 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) 939 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo)
939 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) 940 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo)
940 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) 941 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut)
941 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) 942 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy)
942 #if defined(OS_MACOSX)
943 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
944 #endif
945 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) 943 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
946 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 944 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
947 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) 945 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
948 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 946 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
949 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 947 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
950 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll) 948 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll)
951 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect) 949 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect)
952 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, 950 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets,
953 OnSetEditableSelectionOffsets) 951 OnSetEditableSelectionOffsets)
954 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, 952 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText,
955 OnSetCompositionFromExistingText) 953 OnSetCompositionFromExistingText)
956 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, 954 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete,
957 OnExtendSelectionAndDelete) 955 OnExtendSelectionAndDelete)
958 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) 956 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
959 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 957 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
960 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 958 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
961 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 959 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
962 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 960 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
963 #if defined(OS_ANDROID)
964 IPC_MESSAGE_HANDLER(ViewMsg_ActivateNearestFindResult,
965 OnActivateNearestFindResult)
966 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects,
967 OnFindMatchRects)
968 #endif
969 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 961 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
970 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 962 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
971 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) 963 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor)
972 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 964 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
973 OnSetZoomLevelForLoadingURL) 965 OnSetZoomLevelForLoadingURL)
974 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 966 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
975 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 967 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
976 OnResetPageEncodingToDefault) 968 OnResetPageEncodingToDefault)
977 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) 969 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest)
978 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) 970 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, 1003 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
1012 OnDisableScrollbarsForSmallWindows) 1004 OnDisableScrollbarsForSmallWindows)
1013 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) 1005 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs)
1014 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) 1006 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
1015 IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent, 1007 IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent,
1016 OnOrientationChangeEvent) 1008 OnOrientationChangeEvent)
1017 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) 1009 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
1018 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) 1010 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
1019 IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime, 1011 IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime,
1020 OnSetNavigationStartTime) 1012 OnSetNavigationStartTime)
1021 #if defined(OS_MACOSX)
1022 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
1023 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
1024 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
1025 OnPluginImeCompositionCompleted)
1026 #endif
1027 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, 1013 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent,
1028 OnSetEditCommandsForNextKeyEvent) 1014 OnSetEditCommandsForNextKeyEvent)
1029 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, 1015 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction,
1030 OnCustomContextMenuAction) 1016 OnCustomContextMenuAction)
1031 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) 1017 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened)
1032 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, 1018 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated,
1033 OnPpapiBrokerChannelCreated) 1019 OnPpapiBrokerChannelCreated)
1034 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, 1020 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult,
1035 OnPpapiBrokerPermissionResult) 1021 OnPpapiBrokerPermissionResult)
1036 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 1022 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
1037 OnGetAllSavableResourceLinksForCurrentPage) 1023 OnGetAllSavableResourceLinksForCurrentPage)
1038 IPC_MESSAGE_HANDLER( 1024 IPC_MESSAGE_HANDLER(
1039 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 1025 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
1040 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1026 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1041 #if defined(OS_MACOSX)
1042 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1043 #elif defined(OS_ANDROID)
1044 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1045 #endif
1046 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) 1027 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed)
1047 // TODO(viettrungluu): Move to a separate message filter. 1028 // TODO(viettrungluu): Move to a separate message filter.
1048 #if defined(OS_MACOSX)
1049 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
1050 #endif
1051 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 1029 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
1052 OnSetHistoryLengthAndPrune) 1030 OnSetHistoryLengthAndPrune)
1053 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1031 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1054 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) 1032 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit)
1055 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) 1033 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode)
1056 IPC_MESSAGE_HANDLER(ViewMsg_UpdateFrameTree, OnUpdatedFrameTree) 1034 IPC_MESSAGE_HANDLER(ViewMsg_UpdateFrameTree, OnUpdatedFrameTree)
1035 #if defined(OS_ANDROID)
1036 IPC_MESSAGE_HANDLER(ViewMsg_ActivateNearestFindResult,
1037 OnActivateNearestFindResult)
1038 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects)
1039 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1040 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewMsg_SynchronousFind, OnSynchronousFind)
1041 #elif defined(OS_MACOSX)
1042 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
1043 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
1044 OnPluginImeCompositionCompleted)
1045 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1046 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
1047 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
1048 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
1049 #endif
1057 1050
1058 // Have the super handle all other messages. 1051 // Have the super handle all other messages.
1059 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) 1052 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
1060 IPC_END_MESSAGE_MAP() 1053 IPC_END_MESSAGE_MAP()
1061 1054
1062 if (!msg_is_ok) { 1055 if (!msg_is_ok) {
1063 // The message had a handler, but its deserialization failed. 1056 // The message had a handler, but its deserialization failed.
1064 // Kill the renderer to avoid potential spoofing attacks. 1057 // Kill the renderer to avoid potential spoofing attacks.
1065 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; 1058 CHECK(false) << "Unable to deserialize message in RenderViewImpl.";
1066 } 1059 }
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after
3887 } 3880 }
3888 3881
3889 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { 3882 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) {
3890 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); 3883 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers));
3891 } 3884 }
3892 3885
3893 void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) { 3886 void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) {
3894 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); 3887 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
3895 } 3888 }
3896 3889
3897 void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, 3890 void RenderViewImpl::SendFindReply(int request_id,
3891 int match_count,
3892 int ordinal,
3893 const WebRect& selection_rect,
3894 bool final_status_update) {
3895 #if defined(OS_ANDROID)
3896 // Check if this is a synchronous find request.
jam 2012/09/19 19:37:56 nit: this comment and the one below are not very u
Leandro Graciá Gil 2012/09/20 16:05:06 Done.
3897 if (synchronous_find_reply_message_.get()) {
3898 if (final_status_update) {
3899 ViewMsg_SynchronousFind::WriteReplyParams(
3900 synchronous_find_reply_message_.get(),
3901 match_count,
3902 match_count ? synchronous_find_active_match_ordinal_ : 0);
3903 Send(synchronous_find_reply_message_.release());
3904 }
3905 return;
3906 }
3907 #endif
3908
3909 // Send the search result over to the browser process.
3910 Send(new ViewHostMsg_Find_Reply(routing_id_,
3911 request_id,
3912 match_count,
3913 selection_rect,
3914 ordinal,
3915 final_status_update));
3916 }
3917
3918 void RenderViewImpl::reportFindInPageMatchCount(int request_id,
3919 int count,
3898 bool final_update) { 3920 bool final_update) {
3899 int active_match_ordinal = -1; // -1 = don't update active match ordinal 3921 int active_match_ordinal = -1; // -1 = don't update active match ordinal
3900 if (!count) 3922 if (!count)
3901 active_match_ordinal = 0; 3923 active_match_ordinal = 0;
3902 3924
3903 Send(new ViewHostMsg_Find_Reply(routing_id_, 3925 // Send the search result over to the browser process.
3904 request_id, 3926 SendFindReply(request_id,
3905 count, 3927 count,
3906 gfx::Rect(), 3928 active_match_ordinal,
3907 active_match_ordinal, 3929 gfx::Rect(),
3908 final_update)); 3930 final_update);
3909 } 3931 }
3910 3932
3911 void RenderViewImpl::reportFindInPageSelection(int request_id, 3933 void RenderViewImpl::reportFindInPageSelection(int request_id,
3912 int active_match_ordinal, 3934 int active_match_ordinal,
3913 const WebRect& selection_rect) { 3935 const WebRect& selection_rect) {
3914 // Send the search result over to the browser process. 3936 #if defined(OS_ANDROID)
3915 Send(new ViewHostMsg_Find_Reply(routing_id_, 3937 // If this was a SynchronousFind request, we need to remember the ordinal
3916 request_id, 3938 // value here for replying when reportFindInPageMatchCount is called.
3917 -1, 3939 if (synchronous_find_reply_message_.get()) {
3918 selection_rect, 3940 synchronous_find_active_match_ordinal_ = active_match_ordinal;
3919 active_match_ordinal, 3941 return;
3920 false)); 3942 }
3943 #endif
3944
3945 SendFindReply(request_id,
3946 -1, /* number_of_matches */
jam 2012/09/19 19:37:56 nit: can you skip the comments here? if someone wa
Leandro Graciá Gil 2012/09/20 16:05:06 Done.
3947 active_match_ordinal,
3948 selection_rect,
3949 false /* final_update */);
3921 } 3950 }
3922 3951
3923 void RenderViewImpl::openFileSystem( 3952 void RenderViewImpl::openFileSystem(
3924 WebFrame* frame, 3953 WebFrame* frame,
3925 WebFileSystem::Type type, 3954 WebFileSystem::Type type,
3926 long long size, 3955 long long size,
3927 bool create, 3956 bool create,
3928 WebFileSystemCallbacks* callbacks) { 3957 WebFileSystemCallbacks* callbacks) {
3929 DCHECK(callbacks); 3958 DCHECK(callbacks);
3930 3959
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
4518 web_ui_bindings_.reset(new WebUIBindings( 4547 web_ui_bindings_.reset(new WebUIBindings(
4519 static_cast<content::RenderView*>(this), routing_id_)); 4548 static_cast<content::RenderView*>(this), routing_id_));
4520 } 4549 }
4521 return web_ui_bindings_.get(); 4550 return web_ui_bindings_.get();
4522 } 4551 }
4523 4552
4524 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { 4553 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() {
4525 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); 4554 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin();
4526 } 4555 }
4527 4556
4528 void RenderViewImpl::OnFind(int request_id, const string16& search_text, 4557 void RenderViewImpl::OnFind(int request_id,
4558 const string16& search_text,
4529 const WebFindOptions& options) { 4559 const WebFindOptions& options) {
4560 #if defined(OS_ANDROID)
4561 // Make sure any asynchronous messages do not disrupt an ongoing synchronous
4562 // find request as it might lead to deadlocks. Also, these should be safe to
4563 // ignore since they would belong to a previous find request.
4564 if (synchronous_find_reply_message_.get())
4565 return;
4566 #endif
4567 Find(request_id, search_text, options);
4568 }
4569
4570 void RenderViewImpl::Find(int request_id,
4571 const string16& search_text,
4572 const WebFindOptions& options) {
4530 WebFrame* main_frame = webview()->mainFrame(); 4573 WebFrame* main_frame = webview()->mainFrame();
4531 4574
4532 // Check if the plugin still exists in the document. 4575 // Check if the plugin still exists in the document.
4533 if (main_frame->document().isPluginDocument() && 4576 if (main_frame->document().isPluginDocument() &&
4534 GetWebPluginFromPluginDocument()) { 4577 GetWebPluginFromPluginDocument()) {
4535 if (options.findNext) { 4578 if (options.findNext) {
4536 // Just navigate back/forward. 4579 // Just navigate back/forward.
4537 GetWebPluginFromPluginDocument()->selectFindResult(options.forward); 4580 GetWebPluginFromPluginDocument()->selectFindResult(options.forward);
4538 } else { 4581 } else {
4539 if (GetWebPluginFromPluginDocument()->startFind( 4582 if (!GetWebPluginFromPluginDocument()->startFind(
4540 search_text, options.matchCase, request_id)) { 4583 search_text, options.matchCase, request_id)) {
4541 } else {
4542 // Send "no results". 4584 // Send "no results".
4543 Send(new ViewHostMsg_Find_Reply(routing_id_, 4585 SendFindReply(request_id, 0, 0, gfx::Rect(), true);
4544 request_id,
4545 0,
4546 gfx::Rect(),
4547 0,
4548 true));
4549 } 4586 }
4550 } 4587 }
4551 return; 4588 return;
4552 } 4589 }
4553 4590
4554 WebFrame* frame_after_main = main_frame->traverseNext(true); 4591 WebFrame* frame_after_main = main_frame->traverseNext(true);
4555 WebFrame* focused_frame = webview()->focusedFrame(); 4592 WebFrame* focused_frame = webview()->focusedFrame();
4556 WebFrame* search_frame = focused_frame; // start searching focused frame. 4593 WebFrame* search_frame = focused_frame; // start searching focused frame.
4557 4594
4558 bool multi_frame = (frame_after_main != main_frame); 4595 bool multi_frame = (frame_after_main != main_frame);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4611 // If nothing is found, set result to "0 of 0", otherwise, set it to 4648 // If nothing is found, set result to "0 of 0", otherwise, set it to
4612 // "-1 of 1" to indicate that we found at least one item, but we don't know 4649 // "-1 of 1" to indicate that we found at least one item, but we don't know
4613 // yet what is active. 4650 // yet what is active.
4614 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. 4651 int ordinal = result ? -1 : 0; // -1 here means, we might know more later.
4615 int match_count = result ? 1 : 0; // 1 here means possibly more coming. 4652 int match_count = result ? 1 : 0; // 1 here means possibly more coming.
4616 4653
4617 // If we find no matches then this will be our last status update. 4654 // If we find no matches then this will be our last status update.
4618 // Otherwise the scoping effort will send more results. 4655 // Otherwise the scoping effort will send more results.
4619 bool final_status_update = !result; 4656 bool final_status_update = !result;
4620 4657
4621 // Send the search result over to the browser process. 4658 SendFindReply(request_id, match_count, ordinal, selection_rect,
4622 Send(new ViewHostMsg_Find_Reply(routing_id_, 4659 final_status_update);
4623 request_id,
4624 match_count,
4625 selection_rect,
4626 ordinal,
4627 final_status_update));
4628 4660
4629 // Scoping effort begins, starting with the mainframe. 4661 // Scoping effort begins, starting with the mainframe.
4630 search_frame = main_frame; 4662 search_frame = main_frame;
4631 4663
4632 main_frame->resetMatchCount(); 4664 main_frame->resetMatchCount();
4633 4665
4634 do { 4666 do {
4635 // Cancel all old scoping requests before starting a new one. 4667 // Cancel all old scoping requests before starting a new one.
4636 search_frame->cancelPendingScopingEffort(); 4668 search_frame->cancelPendingScopingEffort();
4637 4669
4638 // We don't start another scoping effort unless at least one match has 4670 // We don't start another scoping effort unless at least one match has
4639 // been found. 4671 // been found.
4640 if (result) { 4672 if (result) {
4641 // Start new scoping request. If the scoping function determines that it 4673 // Start new scoping request. If the scoping function determines that it
4642 // needs to scope, it will defer until later. 4674 // needs to scope, it will defer until later.
4643 search_frame->scopeStringMatches(request_id, 4675 search_frame->scopeStringMatches(request_id,
4644 search_text, 4676 search_text,
4645 options, 4677 options,
4646 true); // reset the tickmarks 4678 true); // reset the tickmarks
4647 } 4679 }
4648 4680
4649 // Iterate to the next frame. The frame will not necessarily scope, for 4681 // Iterate to the next frame. The frame will not necessarily scope, for
4650 // example if it is not visible. 4682 // example if it is not visible.
4651 search_frame = search_frame->traverseNext(true); 4683 search_frame = search_frame->traverseNext(true);
4652 } while (search_frame != main_frame); 4684 } while (search_frame != main_frame);
4653 } 4685 }
4654 } 4686 }
4655 4687
4656 void RenderViewImpl::OnStopFinding(content::StopFindAction action) { 4688 void RenderViewImpl::OnStopFinding(content::StopFindAction action) {
4689 #if defined(OS_ANDROID)
4690 // Make sure any asynchronous messages do not disrupt an ongoing synchronous
4691 // find request as it might lead to deadlocks. Also, these should be safe to
4692 // ignore since they would belong to a previous find request.
4693 if (synchronous_find_reply_message_.get())
4694 return;
4695 #endif
4696
4697 StopFinding(action);
4698 }
4699
4700 void RenderViewImpl::StopFinding(content::StopFindAction action) {
4657 WebView* view = webview(); 4701 WebView* view = webview();
4658 if (!view) 4702 if (!view)
4659 return; 4703 return;
4660 4704
4661 WebDocument doc = view->mainFrame()->document(); 4705 WebDocument doc = view->mainFrame()->document();
4662 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { 4706 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) {
4663 GetWebPluginFromPluginDocument()->stopFind(); 4707 GetWebPluginFromPluginDocument()->stopFind();
4664 return; 4708 return;
4665 } 4709 }
4666 4710
(...skipping 14 matching lines...) Expand all
4681 if (!doc.isNull()) { 4725 if (!doc.isNull()) {
4682 WebNode node = doc.focusedNode(); 4726 WebNode node = doc.focusedNode();
4683 if (!node.isNull()) 4727 if (!node.isNull())
4684 node.simulateClick(); 4728 node.simulateClick();
4685 } 4729 }
4686 } 4730 }
4687 } 4731 }
4688 } 4732 }
4689 4733
4690 #if defined(OS_ANDROID) 4734 #if defined(OS_ANDROID)
4735 void RenderViewImpl::OnSynchronousFind(int request_id,
4736 const string16& search_string,
4737 const WebFindOptions& options,
4738 IPC::Message* reply_msg) {
4739 // It is impossible for simultaneous blocking finds to occur.
4740 CHECK(!synchronous_find_reply_message_.get());
4741 synchronous_find_reply_message_.reset(reply_msg);
4742
4743 // Find next should be asynchronous in order to minimize blocking
4744 // the UI thread as much as possible.
4745 DCHECK(!options.findNext);
4746 StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
4747 synchronous_find_active_match_ordinal_ = -1;
4748
4749 Find(request_id, search_string, options);
4750 }
4751
4691 void RenderViewImpl::OnActivateNearestFindResult(int request_id, 4752 void RenderViewImpl::OnActivateNearestFindResult(int request_id,
4692 float x, float y) { 4753 float x, float y) {
4693 if (!webview()) 4754 if (!webview())
4694 return; 4755 return;
4695 4756
4696 WebFrame* main_frame = webview()->mainFrame(); 4757 WebFrame* main_frame = webview()->mainFrame();
4697 WebRect selection_rect; 4758 WebRect selection_rect;
4698 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y), 4759 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y),
4699 &selection_rect); 4760 &selection_rect);
4700 if (ordinal == -1) { 4761 if (ordinal == -1) {
4701 // Something went wrong, so send a no-op reply (force the main_frame to 4762 // Something went wrong, so send a no-op reply (force the main_frame to
4702 // report the current match count) in case the host is waiting for a 4763 // report the current match count) in case the host is waiting for a
4703 // response due to rate-limiting). 4764 // response due to rate-limiting).
4704 main_frame->increaseMatchCount(0, request_id); 4765 main_frame->increaseMatchCount(0, request_id);
4705 return; 4766 return;
4706 } 4767 }
4707 4768
4708 Send(new ViewHostMsg_Find_Reply(routing_id_, 4769 SendFindReply(request_id,
4709 request_id, 4770 -1 /* number_of_matches */,
4710 -1 /* number_of_matches */, 4771 ordinal,
4711 selection_rect, 4772 selection_rect,
4712 ordinal, 4773 true /* final_update */);
4713 true /* final_update */));
4714 } 4774 }
4715 4775
4716 void RenderViewImpl::OnFindMatchRects(int current_version) { 4776 void RenderViewImpl::OnFindMatchRects(int current_version) {
4717 if (!webview()) 4777 if (!webview())
4718 return; 4778 return;
4719 4779
4720 WebFrame* main_frame = webview()->mainFrame(); 4780 WebFrame* main_frame = webview()->mainFrame();
4721 std::vector<gfx::RectF> match_rects; 4781 std::vector<gfx::RectF> match_rects;
4722 4782
4723 int rects_version = main_frame->findMatchMarkersVersion(); 4783 int rects_version = main_frame->findMatchMarkersVersion();
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
6149 6209
6150 updating_frame_tree_ = true; 6210 updating_frame_tree_ = true;
6151 active_frame_id_map_.clear(); 6211 active_frame_id_map_.clear();
6152 6212
6153 target_process_id_ = process_id; 6213 target_process_id_ = process_id;
6154 target_routing_id_ = route_id; 6214 target_routing_id_ = route_id;
6155 CreateFrameTree(webview()->mainFrame(), frames); 6215 CreateFrameTree(webview()->mainFrame(), frames);
6156 6216
6157 updating_frame_tree_ = false; 6217 updating_frame_tree_ = false;
6158 } 6218 }
OLDNEW
« content/renderer/render_view_impl.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698