Commit 2bc64182 authored by raymes's avatar raymes Committed by Commit bot

Allow MimeHandlerViewGuest to be notified of StopFinding events.

Currently we notify the guest of StartFind events but not StopFinding.

BUG=455079

Review URL: https://codereview.chromium.org/901833002

Cr-Commit-Position: refs/heads/master@{#314939}
parent 0ff80d95
...@@ -174,6 +174,12 @@ bool BrowserPluginEmbedder::Find(int request_id, ...@@ -174,6 +174,12 @@ bool BrowserPluginEmbedder::Find(int request_id,
options)); options));
} }
bool BrowserPluginEmbedder::StopFinding(StopFindAction action) {
return GetBrowserPluginGuestManager()->ForEachGuest(
GetWebContents(),
base::Bind(&BrowserPluginEmbedder::StopFindingInGuest, action));
}
// static // static
bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked,
WebContents* guest) { WebContents* guest) {
...@@ -200,4 +206,15 @@ bool BrowserPluginEmbedder::FindInGuest(int request_id, ...@@ -200,4 +206,15 @@ bool BrowserPluginEmbedder::FindInGuest(int request_id,
return false; return false;
} }
bool BrowserPluginEmbedder::StopFindingInGuest(StopFindAction action,
WebContents* guest) {
if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest()
->StopFinding(action)) {
// 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 } // namespace content
...@@ -75,6 +75,7 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver { ...@@ -75,6 +75,7 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver {
bool Find(int request_id, bool Find(int request_id,
const base::string16& search_text, const base::string16& search_text,
const blink::WebFindOptions& options); const blink::WebFindOptions& options);
bool StopFinding(StopFindAction action);
private: private:
explicit BrowserPluginEmbedder(WebContentsImpl* web_contents); explicit BrowserPluginEmbedder(WebContentsImpl* web_contents);
...@@ -92,6 +93,8 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver { ...@@ -92,6 +93,8 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver {
const base::string16& search_text, const base::string16& search_text,
const blink::WebFindOptions& options, const blink::WebFindOptions& options,
WebContents* guest); WebContents* guest);
static bool StopFindingInGuest(StopFindAction action, WebContents* guest);
// Message handlers. // Message handlers.
void OnAttach(int instance_id, void OnAttach(int instance_id,
const BrowserPluginHostMsg_Attach_Params& params); const BrowserPluginHostMsg_Attach_Params& params);
......
...@@ -384,6 +384,10 @@ bool BrowserPluginGuest::Find(int request_id, ...@@ -384,6 +384,10 @@ bool BrowserPluginGuest::Find(int request_id,
return delegate_->Find(request_id, search_text, options); return delegate_->Find(request_id, search_text, options);
} }
bool BrowserPluginGuest::StopFinding(StopFindAction action) {
return delegate_->StopFinding(action);
}
WebContentsImpl* BrowserPluginGuest::GetWebContents() const { WebContentsImpl* BrowserPluginGuest::GetWebContents() const {
return static_cast<WebContentsImpl*>(web_contents()); return static_cast<WebContentsImpl*>(web_contents());
} }
......
...@@ -219,6 +219,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestSizer, ...@@ -219,6 +219,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestSizer,
bool Find(int request_id, bool Find(int request_id,
const base::string16& search_text, const base::string16& search_text,
const blink::WebFindOptions& options); const blink::WebFindOptions& options);
bool StopFinding(StopFindAction action);
private: private:
class EmbedderVisibilityObserver; class EmbedderVisibilityObserver;
......
...@@ -2479,6 +2479,11 @@ void WebContentsImpl::Find(int request_id, ...@@ -2479,6 +2479,11 @@ void WebContentsImpl::Find(int request_id,
} }
void WebContentsImpl::StopFinding(StopFindAction action) { void WebContentsImpl::StopFinding(StopFindAction action) {
// See if a top level browser plugin handles the stop finding request first.
if (browser_plugin_embedder_ &&
browser_plugin_embedder_->StopFinding(action)) {
return;
}
Send(new ViewMsg_StopFinding(GetRoutingID(), action)); Send(new ViewMsg_StopFinding(GetRoutingID(), action));
} }
......
...@@ -26,4 +26,8 @@ bool BrowserPluginGuestDelegate::Find(int request_id, ...@@ -26,4 +26,8 @@ bool BrowserPluginGuestDelegate::Find(int request_id,
return false; return false;
} }
bool BrowserPluginGuestDelegate::StopFinding(StopFindAction action) {
return false;
}
} // namespace content } // namespace content
...@@ -80,6 +80,7 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate { ...@@ -80,6 +80,7 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate {
virtual bool Find(int request_id, virtual bool Find(int request_id,
const base::string16& search_text, const base::string16& search_text,
const blink::WebFindOptions& options); const blink::WebFindOptions& options);
virtual bool StopFinding(StopFindAction action);
// Provides the delegate with an interface with which to size the guest. // Provides the delegate with an interface with which to size the guest.
virtual void SetGuestSizer(GuestSizer* guest_sizer) {} virtual void SetGuestSizer(GuestSizer* guest_sizer) {}
......
...@@ -244,7 +244,7 @@ bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) { ...@@ -244,7 +244,7 @@ bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) {
params->options->match_case ? *params->options->match_case : false; params->options->match_case ? *params->options->match_case : false;
} }
guest->StartFinding(search_text, options, this); guest->StartFindInternal(search_text, options, this);
return true; return true;
} }
...@@ -275,7 +275,7 @@ bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) { ...@@ -275,7 +275,7 @@ bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) {
action = content::STOP_FIND_ACTION_KEEP_SELECTION; action = content::STOP_FIND_ACTION_KEEP_SELECTION;
} }
guest->StopFinding(action); guest->StopFindingInternal(action);
return true; return true;
} }
......
...@@ -173,6 +173,14 @@ bool MimeHandlerViewGuest::Find(int request_id, ...@@ -173,6 +173,14 @@ bool MimeHandlerViewGuest::Find(int request_id,
return false; return false;
} }
bool MimeHandlerViewGuest::StopFinding(content::StopFindAction action) {
if (is_full_page_plugin()) {
web_contents()->StopFinding(action);
return true;
}
return false;
}
content::WebContents* MimeHandlerViewGuest::OpenURLFromTab( content::WebContents* MimeHandlerViewGuest::OpenURLFromTab(
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {
......
...@@ -74,6 +74,7 @@ class MimeHandlerViewGuest : public GuestView<MimeHandlerViewGuest>, ...@@ -74,6 +74,7 @@ class MimeHandlerViewGuest : public GuestView<MimeHandlerViewGuest>,
bool Find(int request_id, bool Find(int request_id,
const base::string16& search_text, const base::string16& search_text,
const blink::WebFindOptions& options) override; const blink::WebFindOptions& options) override;
bool StopFinding(content::StopFindAction action) override;
// WebContentsDelegate implementation. // WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab( content::WebContents* OpenURLFromTab(
......
...@@ -557,14 +557,14 @@ void WebViewGuest::Observe(int type, ...@@ -557,14 +557,14 @@ void WebViewGuest::Observe(int type,
} }
} }
void WebViewGuest::StartFinding( void WebViewGuest::StartFindInternal(
const base::string16& search_text, const base::string16& search_text,
const blink::WebFindOptions& options, const blink::WebFindOptions& options,
scoped_refptr<WebViewInternalFindFunction> find_function) { scoped_refptr<WebViewInternalFindFunction> find_function) {
find_helper_.Find(web_contents(), search_text, options, find_function); find_helper_.Find(web_contents(), search_text, options, find_function);
} }
void WebViewGuest::StopFinding(content::StopFindAction action) { void WebViewGuest::StopFindingInternal(content::StopFindAction action) {
find_helper_.CancelAllFindSessions(); find_helper_.CancelAllFindSessions();
web_contents()->StopFinding(action); web_contents()->StopFinding(action);
} }
......
...@@ -169,12 +169,13 @@ class WebViewGuest : public GuestView<WebViewGuest>, ...@@ -169,12 +169,13 @@ class WebViewGuest : public GuestView<WebViewGuest>,
double zoom() const { return current_zoom_factor_; } double zoom() const { return current_zoom_factor_; }
// Begin or continue a find request. // Begin or continue a find request.
void StartFinding(const base::string16& search_text, void StartFindInternal(
const blink::WebFindOptions& options, const base::string16& search_text,
scoped_refptr<WebViewInternalFindFunction> find_function); const blink::WebFindOptions& options,
scoped_refptr<WebViewInternalFindFunction> find_function);
// Conclude a find request to clear highlighting. // Conclude a find request to clear highlighting.
void StopFinding(content::StopFindAction); void StopFindingInternal(content::StopFindAction);
// If possible, navigate the guest to |relative_index| entries away from the // If possible, navigate the guest to |relative_index| entries away from the
// current navigation entry. Returns true on success. // current navigation entry. Returns true on success.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment