summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin/browser_plugin_embedder.cc
diff options
context:
space:
mode:
authorlazyboy@chromium.org <lazyboy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 22:24:11 +0000
committerlazyboy@chromium.org <lazyboy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 22:24:11 +0000
commitb0452f8a2e07b6e1505dcbfde897b906105fffc9 (patch)
tree3cc2dbcacc95cb02f7de3df31ec41bb1a7543c85 /content/browser/browser_plugin/browser_plugin_embedder.cc
parentcdf740538b89917805a0e3717b68203508ac6359 (diff)
downloadchromium_src-b0452f8a2e07b6e1505dcbfde897b906105fffc9.zip
chromium_src-b0452f8a2e07b6e1505dcbfde897b906105fffc9.tar.gz
chromium_src-b0452f8a2e07b6e1505dcbfde897b906105fffc9.tar.bz2
Triggering InspectElement from context menu over a guest will open guest's devtools with correct element highlighted.
BUG=140329 Review URL: https://chromiumcodereview.appspot.com/11362016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_plugin/browser_plugin_embedder.cc')
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.cc49
1 files changed, 44 insertions, 5 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 678bb2ff..1fd0a57 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -32,7 +32,8 @@ BrowserPluginEmbedder::BrowserPluginEmbedder(
RenderViewHost* render_view_host)
: WebContentsObserver(web_contents),
render_view_host_(render_view_host),
- visible_(true) {
+ visible_(true),
+ next_get_render_view_request_id_(0) {
// Listen to visibility changes so that an embedder hides its guests
// as well.
registrar_.Add(this,
@@ -44,8 +45,7 @@ BrowserPluginEmbedder::BrowserPluginEmbedder(
}
BrowserPluginEmbedder::~BrowserPluginEmbedder() {
- // Destroy guests that are managed by the current embedder.
- DestroyGuests();
+ CleanUp();
}
// static
@@ -219,11 +219,17 @@ void BrowserPluginEmbedder::SetFocus(int instance_id,
guest->SetFocus(focused);
}
-void BrowserPluginEmbedder::DestroyGuests() {
+void BrowserPluginEmbedder::CleanUp() {
+ // Destroy guests that are managed by the current embedder.
STLDeleteContainerPairSecondPointers(
guest_web_contents_by_instance_id_.begin(),
guest_web_contents_by_instance_id_.end());
guest_web_contents_by_instance_id_.clear();
+
+ // CleanUp gets called when BrowserPluginEmbedder's WebContents goes away
+ // or the associated RenderViewHost is destroyed or swapped out. Therefore we
+ // don't need to care about the pending callbacks anymore.
+ pending_get_render_view_callbacks_.clear();
}
void BrowserPluginEmbedder::HandleInputEvent(int instance_id,
@@ -252,7 +258,7 @@ void BrowserPluginEmbedder::RenderViewDeleted(
}
void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) {
- DestroyGuests();
+ CleanUp();
}
void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) {
@@ -322,6 +328,39 @@ void BrowserPluginEmbedder::TerminateGuest(int instance_id) {
guest->Terminate();
}
+void BrowserPluginEmbedder::GetRenderViewHostAtPosition(
+ int x,
+ int y,
+ const WebContents::GetRenderViewHostCallback& callback) {
+ // Store the callback so we can call it later when we have the response.
+ pending_get_render_view_callbacks_.insert(
+ std::make_pair(next_get_render_view_request_id_, callback));
+ render_view_host_->Send(
+ new BrowserPluginMsg_PluginAtPositionRequest(
+ render_view_host_->GetRoutingID(),
+ next_get_render_view_request_id_,
+ gfx::Point(x, y)));
+ ++next_get_render_view_request_id_;
+}
+
+void BrowserPluginEmbedder::PluginAtPositionResponse(
+ int instance_id, int request_id, const gfx::Point& position) {
+ const std::map<int, WebContents::GetRenderViewHostCallback>::iterator
+ callback_iter = pending_get_render_view_callbacks_.find(request_id);
+ if (callback_iter == pending_get_render_view_callbacks_.end())
+ return;
+
+ RenderViewHost* render_view_host;
+ BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
+ if (guest)
+ render_view_host = guest->GetWebContents()->GetRenderViewHost();
+ else // No plugin, use embedder's RenderViewHost.
+ render_view_host = render_view_host_;
+
+ callback_iter->second.Run(render_view_host, position.x(), position.y());
+ pending_get_render_view_callbacks_.erase(callback_iter);
+}
+
void BrowserPluginEmbedder::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {