From 0fa0be50a2ca75472c27113b43bd5b3bc42d7629 Mon Sep 17 00:00:00 2001 From: raymes Date: Mon, 13 Oct 2014 13:38:09 -0700 Subject: Implement find in page support for top level BrowserPlugins. Right now BrowserPlugins don't handle find in page. This CL adds support for find in page in MIMEHandlerView BrowserPlugin instances. Find in page is only handled for "full page" plugins, that is when the BrowserPlugin as loaded at the top level. The reason is because supporting find in embedded BrowserPlugins would require recursively searching which is far more complicated to implement and we (jam@, fsamuel@) have decided to defer implementing for the time being. Detecting whether the BrowserPlugin is loaded at the top level requires detecting whether the main frame is a "plugin document" in blink, which needs to be sent to the browser from the renderer. It isn't sufficient to determine whether the BrowserPlugin is merely loaded in the main frame, because it may be ed inside a html document in the main frame. In that case we don't want find in page to search the document. BUG=303491 Review URL: https://codereview.chromium.org/597753003 Cr-Commit-Position: refs/heads/master@{#299358} --- .../browser_plugin/browser_plugin_embedder.cc | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'content/browser/browser_plugin/browser_plugin_embedder.cc') diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc index bbd690f..cb47159 100644 --- a/content/browser/browser_plugin/browser_plugin_embedder.cc +++ b/content/browser/browser_plugin/browser_plugin_embedder.cc @@ -22,6 +22,7 @@ #include "content/public/common/result_codes.h" #include "content/public/common/url_constants.h" #include "net/base/escape.h" +#include "third_party/WebKit/public/web/WebFindOptions.h" #include "ui/events/keycodes/keyboard_codes.h" namespace content { @@ -162,6 +163,18 @@ bool BrowserPluginEmbedder::HandleKeyboardEvent( return event_consumed; } +bool BrowserPluginEmbedder::Find(int request_id, + const base::string16& search_text, + const blink::WebFindOptions& options) { + return GetBrowserPluginGuestManager()->ForEachGuest( + GetWebContents(), + base::Bind(&BrowserPluginEmbedder::FindInGuest, + base::Unretained(this), + request_id, + search_text, + options)); +} + bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, WebContents* guest) { *mouse_unlocked |= static_cast(guest) @@ -173,4 +186,17 @@ bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, return false; } +bool BrowserPluginEmbedder::FindInGuest(int request_id, + const base::string16& search_text, + const blink::WebFindOptions& options, + WebContents* guest) { + if (static_cast(guest)->GetBrowserPluginGuest()->Find( + request_id, search_text, options)) { + // There can only ever currently be one browser plugin that handles find so + // we can break the iteration at this point. + return true; + } + return false; +} + } // namespace content -- cgit v1.1