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

Unified Diff: content/renderer/render_view_impl.cc

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT. Added subframe targeting + test. Created 8 years, 2 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/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index aef2207674ee7aca7f20337151b20a16de39fe68..456b859edd572e140b1262a851aed76ac76ee368 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -3905,12 +3905,14 @@ void RenderViewImpl::CreateFrameTree(WebKit::WebFrame* frame,
}
}
-WebKit::WebFrame* RenderViewImpl::GetFrameByMappedID(int frame_id) {
- std::map<int, int>::iterator it = active_frame_id_map_.find(frame_id);
- if (it == active_frame_id_map_.end())
- return NULL;
-
- return FindFrameByID(webview()->mainFrame(), it->second);
+WebKit::WebFrame* RenderViewImpl::GetFrameByMappedID(int remote_frame_id) {
+ std::map<int, int>::const_iterator it = active_frame_id_map_.begin();
+ for (; it != active_frame_id_map_.end(); ++it) {
+ if (it->second == remote_frame_id) {
+ return FindFrameByID(webview()->mainFrame(), it->first);
+ }
+ }
+ return NULL;
}
void RenderViewImpl::EnsureMediaStreamImpl() {
@@ -4191,7 +4193,6 @@ bool RenderViewImpl::willCheckAndDispatchMessageEvent(
} else {
params.target_frame_id = 0;
}
-
Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params));
return true;
}
@@ -6297,19 +6298,18 @@ void RenderViewImpl::OnJavaBridgeInit() {
#endif
}
-void RenderViewImpl::OnUpdatedFrameTree(
+void RenderViewImpl::UpdateFrameTree(
int process_id,
int route_id,
const std::string& frame_tree) {
// We should only act on this message if we are swapped out. It's possible
// for this to happen due to races.
- if (!is_swapped_out_)
- return;
-
base::DictionaryValue* frames = NULL;
scoped_ptr<base::Value> tree(base::JSONReader::Read(frame_tree));
- if (tree.get() && tree->IsType(base::Value::TYPE_DICTIONARY))
- tree->GetAsDictionary(&frames);
+ if (tree.get() && tree->IsType(base::Value::TYPE_DICTIONARY)) {
+ if (!tree->GetAsDictionary(&frames))
+ return;
+ }
updating_frame_tree_ = true;
active_frame_id_map_.clear();
@@ -6320,3 +6320,23 @@ void RenderViewImpl::OnUpdatedFrameTree(
updating_frame_tree_ = false;
}
+
+void RenderViewImpl::OnUpdatedFrameTree(
nasko 2012/10/02 17:52:31 This change might be worthwhile as a separate bug/
Fady Samuel 2012/10/02 22:04:08 Done. Leaving it here until the other patch lands.
+ int process_id,
+ int route_id,
+ const std::string& frame_tree) {
+ if (!is_swapped_out_)
+ return;
+
+ if (frame_tree.empty())
+ return;
+ // Post the task to update the frame tree on the task queue to ensure that
nasko 2012/10/02 17:52:31 nit: An empty line prior to the comment will make
+ // that any pending postMessage tasks are handled before the frame tree is
+ // updated. If we navigate between the time we schedule a postMessage, and
+ // the time we handle it, we will get a navigation that will prevent the
+ // message from being posted.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&RenderViewImpl::UpdateFrameTree, AsWeakPtr(),
+ process_id, route_id, frame_tree));
+}

Powered by Google App Engine
This is Rietveld 408576698