 index 4fa796b38b3f..376e8e143770 100644
 --- a/content/browser/web_contents/web_contents_impl.cc
 +++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -685,13 +685,38 @@ RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() {
+@@ -685,12 +685,34 @@ RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() {
    return GetRenderManager();
  }
  
-+void SenMessageToFrameTreeWebUIs(RenderFrameHostImpl *parent_frame_host,
-+	const IPC::Message &message,
-+	int &dispatch_count) {
++void SendMessageToFrameTreeWebUIs(RenderFrameHostImpl* parent_frame_host,
++                                  const IPC::Message& message,
++                                  int& dispatch_count) {
++  // Get the web ui or the pending one if it's not yet commited.
++  WebUIImpl* web_ui = parent_frame_host->web_ui()
++      ? parent_frame_host->web_ui()
++      : parent_frame_host->pending_web_ui();
++  if (web_ui && web_ui->OnMessageReceived(message)) {
++    ++dispatch_count;
++  }
 +
-+	// Get the web ui or the pending one if it's not yet commited
-+	WebUIImpl *web_ui = parent_frame_host->web_ui()
-+		? parent_frame_host->web_ui()
-+		: parent_frame_host->pending_web_ui();
-+	if (web_ui && web_ui->OnMessageReceived(message)) {
-+		++dispatch_count;
-+	}
-+
-+	size_t child_count = parent_frame_host->frame_tree_node()->child_count();
-+	for (size_t i = 0; i < child_count; ++i) {
-+		RenderFrameHostImpl *sub_frame_host =
-+			parent_frame_host->frame_tree_node()->child_at(i)->current_frame_host();
-+		SenMessageToFrameTreeWebUIs(sub_frame_host, message, dispatch_count);
-+	}
++  size_t child_count = parent_frame_host->frame_tree_node()->child_count();
++  for (size_t i = 0; i < child_count; ++i) {
++    RenderFrameHostImpl* sub_frame_host =
++        parent_frame_host->frame_tree_node()->child_at(i)->current_frame_host();
++    SendMessageToFrameTreeWebUIs(sub_frame_host, message, dispatch_count);
++  }
 +}
-+
 +
  bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host,
                                          const IPC::Message& message) {
--  RenderFrameHost* main_frame = render_view_host->GetMainFrame();
--  if (main_frame) {
+   RenderFrameHost* main_frame = render_view_host->GetMainFrame();
++  int dispatch_count = 0;
+   if (main_frame) {
 -    WebUIImpl* web_ui = static_cast<RenderFrameHostImpl*>(main_frame)->web_ui();
 -    if (web_ui && web_ui->OnMessageReceived(message))
--      return true;
-+   RenderFrameHost *main_frame = render_view_host->GetMainFrame();
-+  int dispatch_count = 0;
-+  if (main_frame) {
-+    RenderFrameHostImpl *main_frame_host =
-+        static_cast<RenderFrameHostImpl *>(main_frame);
-+    SenMessageToFrameTreeWebUIs(main_frame_host, message, dispatch_count);
-+    if (dispatch_count > 0) {
-+      return true;
-+    }
++    RenderFrameHostImpl* main_frame_host =
++        static_cast<RenderFrameHostImpl*>(main_frame);
++    SendMessageToFrameTreeWebUIs(main_frame_host, message, dispatch_count);
++    if (dispatch_count > 0)
+       return true;
    }
  
-   for (auto& observer : observers_) {
-@@ -732,6 +757,7 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host,
-   return handled;
+@@ -5021,8 +5043,9 @@ NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
  }
  
-+
- bool WebContentsImpl::OnMessageReceived(RenderFrameHostImpl* render_frame_host,
-                                         const IPC::Message& message) {
-   for (auto& observer : observers_) {
-@@ -5013,9 +5039,9 @@ NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
-   return GetController();
- }
- 
--std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost(
+ std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost(
 -    const GURL& url) {
 -  return CreateWebUI(url, std::string());
-+std::unique_ptr<WebUIImpl>
-+WebContentsImpl::CreateWebUIForRenderFrameHost(const GURL &url, const std::string& frame_name) {
-+	return CreateWebUI(url, frame_name);
++    const GURL &url,
++    const std::string& frame_name) {
++  return CreateWebUI(url, frame_name);
  }
  
  NavigationEntry*

     } else {
-      // Otherwise create a new pending WebUI.
-      pending_web_ui_ = delegate_->CreateWebUIForRenderFrameHost(dest_url);
+	  //Give the frame a name if it does not already have one
+	  //The reason is web ui code base the frame look up on the frame name
+      std::string frame_name = GetFrameName();
+	  if (frame_name.empty() && !frame_tree_node_->IsMainFrame()) {
+	      frame_name = base::StringPrintf("frame_%i", frame_tree_node_->frame_tree_node_id());
+		  frame_tree_node_->SetFrameName(frame_name, "");
+      }
+
+	  //if the web ui is in subframes, the parent frame bindings does not have the web ui binding
+      //So, we reset the bindings for the subframes.
+      if (!frame_tree_node_->IsMainFrame() && new_web_ui_type != WebUI::kNoWebUI) {
+	      entry_bindings = NavigationEntryImpl::kInvalidBindings;
+	  }
+		
+	  // Otherwise create a new pending WebUI.
+      pending_web_ui_ = delegate_->CreateWebUIForRenderFrameHost(dest_url, frame_name);
       DCHECK(pending_web_ui_);
       pending_web_ui_type_ = new_web_ui_type;

   // applies, returns null.
   virtual std::unique_ptr<WebUIImpl> CreateWebUIForRenderFrameHost(
-      const GURL& url);
+      const GURL& url,
+      const std::string& frame_name);
 
   // Called by |frame| to notify that it has received an update on focused
   // element. |bounds_in_root_view| is the rectangle containing the element that
