2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/browser/frame_host/render_frame_host_delegate.cc b/content/browser/frame_host/render_frame_host_delegate.cc
|
2018-09-14 18:03:43 +00:00
|
|
|
index 390bcf09995e..f9090f8ea24a 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/frame_host/render_frame_host_delegate.cc
|
|
|
|
+++ b/content/browser/frame_host/render_frame_host_delegate.cc
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -99,7 +99,9 @@ RenderFrameHostDelegate::GetFocusedFrameIncludingInnerWebContents() {
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<WebUIImpl>
|
|
|
|
-RenderFrameHostDelegate::CreateWebUIForRenderFrameHost(const GURL& url) {
|
|
|
|
+RenderFrameHostDelegate::CreateWebUIForRenderFrameHost(
|
|
|
|
+ const GURL& url,
|
|
|
|
+ const std::string& frame_name) {
|
2018-09-14 18:03:43 +00:00
|
|
|
return nullptr;
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/content/browser/frame_host/render_frame_host_delegate.h b/content/browser/frame_host/render_frame_host_delegate.h
|
2018-09-14 18:03:43 +00:00
|
|
|
index cd4a295dfa37..1057c6d33b9e 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/frame_host/render_frame_host_delegate.h
|
|
|
|
+++ b/content/browser/frame_host/render_frame_host_delegate.h
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -275,7 +275,8 @@ class CONTENT_EXPORT RenderFrameHostDelegate {
|
2018-09-14 05:02:16 +00:00
|
|
|
// Creates a WebUI object for a frame navigating to |url|. If no WebUI
|
|
|
|
// 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
|
|
|
|
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
|
2018-09-14 18:03:43 +00:00
|
|
|
index 7a53675a2139..29bb8eaba5c1 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/frame_host/render_frame_host_impl.cc
|
|
|
|
+++ b/content/browser/frame_host/render_frame_host_impl.cc
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -25,6 +25,7 @@
|
2018-09-14 05:02:16 +00:00
|
|
|
#include "base/task_scheduler/post_task.h"
|
2018-09-14 18:03:43 +00:00
|
|
|
#include "base/threading/thread_task_runner_handle.h"
|
2018-09-14 05:02:16 +00:00
|
|
|
#include "base/time/time.h"
|
|
|
|
+#include "base/unguessable_token.h"
|
|
|
|
#include "build/build_config.h"
|
|
|
|
#include "cc/base/switches.h"
|
|
|
|
#include "content/browser/accessibility/browser_accessibility_manager.h"
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -4198,8 +4199,23 @@ bool RenderFrameHostImpl::UpdatePendingWebUI(const GURL& dest_url,
|
2018-09-14 05:02:16 +00:00
|
|
|
DCHECK(web_ui_);
|
|
|
|
should_reuse_web_ui_ = true;
|
|
|
|
} else {
|
|
|
|
+ // 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, frame_name + base::UnguessableToken::Create().ToString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 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);
|
|
|
|
+ pending_web_ui_ = delegate_->CreateWebUIForRenderFrameHost(dest_url, frame_name);
|
|
|
|
DCHECK(pending_web_ui_);
|
|
|
|
pending_web_ui_type_ = new_web_ui_type;
|
|
|
|
|
|
|
|
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
2018-09-14 18:03:43 +00:00
|
|
|
index 6ed6ece96d0f..11bf320311bb 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/web_contents/web_contents_impl.cc
|
|
|
|
+++ b/content/browser/web_contents/web_contents_impl.cc
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -752,6 +752,25 @@ RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() {
|
2018-09-14 05:02:16 +00:00
|
|
|
return GetRenderManager();
|
|
|
|
}
|
2018-09-14 18:03:43 +00:00
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
+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, parent_frame_host)) {
|
|
|
|
+ ++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) {
|
|
|
|
for (auto& observer : observers_) {
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -787,9 +806,10 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host,
|
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
bool WebContentsImpl::OnMessageReceived(RenderFrameHostImpl* render_frame_host,
|
|
|
|
const IPC::Message& message) {
|
|
|
|
- {
|
|
|
|
- WebUIImpl* web_ui = render_frame_host->web_ui();
|
|
|
|
- if (web_ui && web_ui->OnMessageReceived(message, render_frame_host))
|
|
|
|
+ int dispatch_count = 0;
|
|
|
|
+ if (render_frame_host) {
|
|
|
|
+ SendMessageToFrameTreeWebUIs(render_frame_host, message, dispatch_count);
|
|
|
|
+ if (dispatch_count > 0)
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-14 18:03:43 +00:00
|
|
|
|
|
|
|
@@ -5782,8 +5802,9 @@ NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost(
|
|
|
|
- const GURL& url) {
|
|
|
|
- return CreateWebUI(url);
|
|
|
|
+ const GURL& url,
|
|
|
|
+ const std::string& frame_name) {
|
|
|
|
+ return CreateWebUI(url/*, frame_name*/);
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigationEntry*
|
|
|
|
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
|
2018-09-14 18:03:43 +00:00
|
|
|
index cd1c992c7738..5d52d8cb0bc4 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/web_contents/web_contents_impl.h
|
|
|
|
+++ b/content/browser/web_contents/web_contents_impl.h
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -543,7 +543,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
2018-09-14 05:02:16 +00:00
|
|
|
SiteInstance* source_site_instance) const override;
|
|
|
|
void EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) override;
|
|
|
|
std::unique_ptr<WebUIImpl> CreateWebUIForRenderFrameHost(
|
|
|
|
- const GURL& url) override;
|
|
|
|
+ const GURL& url,
|
|
|
|
+ const std::string& frame_name) override;
|
|
|
|
void SetFocusedFrame(FrameTreeNode* node, SiteInstance* source) override;
|
|
|
|
void DidCallFocus() override;
|
|
|
|
RenderFrameHost* GetFocusedFrameIncludingInnerWebContents() override;
|