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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1851793002: Implement a shell of FindRequestManager, and hook it up to WebContentsImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 2d463287de60180ff5c1c2e3e3f41c96ae7d9f7b..847e07f7e6034be296336e130a5fbd9888c60dc6 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -39,6 +39,7 @@
#include "content/browser/download/download_stats.h"
#include "content/browser/download/mhtml_generation_manager.h"
#include "content/browser/download/save_package.h"
+#include "content/browser/find_request_manager.h"
#include "content/browser/frame_host/cross_process_frame_connector.h"
#include "content/browser/frame_host/interstitial_page_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
@@ -600,7 +601,6 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser)
IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser,
OnSetSelectedColorInColorChooser)
-
IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint,
OnFirstVisuallyNonEmptyPaint)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache,
@@ -2893,22 +2893,24 @@ void WebContentsImpl::Find(int request_id,
}
// See if a top level browser plugin handles the find request first.
+ // TODO(paulmeyer): Remove this after find-in-page works across GuestViews.
if (browser_plugin_embedder_ &&
browser_plugin_embedder_->Find(request_id, search_text, options)) {
return;
}
- GetMainFrame()->Send(new FrameMsg_Find(GetMainFrame()->GetRoutingID(),
- request_id, search_text, options));
+
+ GetOrCreateFindRequestManager()->Find(request_id, search_text, options);
}
void WebContentsImpl::StopFinding(StopFindAction action) {
// See if a top level browser plugin handles the stop finding request first.
+ // TODO(paulmeyer): Remove this after find-in-page works across GuestViews.
if (browser_plugin_embedder_ &&
browser_plugin_embedder_->StopFinding(action)) {
return;
}
- GetMainFrame()->Send(
- new FrameMsg_StopFinding(GetMainFrame()->GetRoutingID(), action));
+
+ GetOrCreateFindRequestManager()->StopFinding(action);
}
void WebContentsImpl::InsertCSS(const std::string& css) {
@@ -3426,10 +3428,14 @@ void WebContentsImpl::OnFindReply(int request_id,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update) {
- if (delegate_) {
- delegate_->FindReply(this, request_id, number_of_matches, selection_rect,
- active_match_ordinal, final_update);
- }
+ // Forward the find reply to the FindRequestManager, along with the
+ // RenderFrameHost associated with the frame that the reply came from.
+ GetOrCreateFindRequestManager()->FindReply(render_frame_message_source_,
+ request_id,
+ number_of_matches,
+ selection_rect,
+ active_match_ordinal,
+ final_update);
}
#if defined(OS_ANDROID)
@@ -3437,8 +3443,8 @@ void WebContentsImpl::OnFindMatchRectsReply(
int version,
const std::vector<gfx::RectF>& rects,
const gfx::RectF& active_rect) {
- if (delegate_)
- delegate_->FindMatchRectsReply(this, version, rects, active_rect);
+ GetOrCreateFindRequestManager()->FindMatchRectsReply(
+ render_frame_message_source_, version, rects, active_rect);
}
void WebContentsImpl::OnOpenDateTimeDialog(
@@ -4645,6 +4651,15 @@ WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() {
return web_contents_android;
}
+void WebContentsImpl::ActivateNearestFindResult(float x,
+ float y) {
+ GetOrCreateFindRequestManager()->ActivateNearestFindResult(x, y);
+}
+
+void WebContentsImpl::RequestFindMatchRects(int current_version) {
+ GetOrCreateFindRequestManager()->RequestFindMatchRects(current_version);
+}
+
bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() {
return CreateRenderViewForRenderManager(
GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE,
@@ -4798,6 +4813,37 @@ WebUI* WebContentsImpl::CreateWebUI(const GURL& url,
return NULL;
}
+FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() {
+ // TODO(paulmeyer): This method will need to access (or potentially create)
+ // the FindRequestManager in the outermost WebContents once find-in-page
+ // across GuestViews is implemented.
+ if (!find_request_manager_.get())
dcheng 2016/04/04 18:59:52 Nit: no .get()
paulmeyer 2016/04/04 20:07:47 Done. Thanks for catching this! I didn't realize
+ find_request_manager_.reset(new FindRequestManager(this));
+
+ return find_request_manager_.get();
+}
+
+void WebContentsImpl::FindReply(int request_id,
+ int number_of_matches,
+ const gfx::Rect& selection_rect,
+ int active_match_ordinal,
+ bool final_update) {
+ if (delegate_) {
+ delegate_->FindReply(this, request_id, number_of_matches, selection_rect,
+ active_match_ordinal, final_update);
+ }
+}
+
+#if defined(OS_ANDROID)
+void WebContentsImpl::FindMatchRectsReply(
+ int version,
+ const std::vector<gfx::RectF>& rects,
+ const gfx::RectF& active_rect) {
+ if (delegate_)
+ delegate_->FindMatchRectsReply(this, version, rects, active_rect);
+}
+#endif
+
void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
force_disable_overscroll_content_ = force_disable;
if (view_)

Powered by Google App Engine
This is Rietveld 408576698