Commit 055fe8f2 authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Remove code dealing with Web UIs living in subframes

This was needed when the "uber" page hosted multiple different iframes:

 <iframe src="chrome://settings"></iframe>
 <iframe src="chrome://extensions"></iframe>
 <iframe src="chrome://history"></iframe>
 <iframe src="chrome://about"></iframe>

for code separation purposes.

Because the "uber" page UI has been replaced and the replacements don't
use <iframe>s, the code can be removed.

R=creis@chromium.org
BUG=683418,666525

Change-Id: I1ee60a3fe74af3bfc78503740cbccf134ea41bd8
Reviewed-on: https://chromium-review.googlesource.com/696718Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Commit-Queue: Dan Beam (no longer on Chrome) <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506558}
parent 62db39d8
......@@ -660,7 +660,7 @@ WebUIController* ChromeWebUIControllerFactory::CreateWebUIControllerForURL(
if (!function)
return NULL;
if (web_ui->HasRenderFrame())
if (web_ui->GetWebContents()->GetMainFrame() != nullptr)
webui::LogWebUIUrl(url);
return (*function)(web_ui, url);
......
......@@ -1183,13 +1183,6 @@ void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) {
GetView()->GetScreenInfo(screen_info);
}
std::unique_ptr<WebUI> WebContentsImpl::CreateSubframeWebUI(
const GURL& url,
const std::string& frame_name) {
DCHECK(!frame_name.empty());
return CreateWebUI(url, frame_name);
}
WebUI* WebContentsImpl::GetWebUI() const {
WebUI* commited_web_ui = GetCommittedWebUI();
return commited_web_ui ? commited_web_ui
......@@ -5498,7 +5491,7 @@ NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost(
const GURL& url) {
return CreateWebUI(url, std::string());
return CreateWebUI(url);
}
NavigationEntry*
......@@ -5751,11 +5744,8 @@ void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
delegate_->UpdatePreferredSize(this, new_size);
}
std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUI(
const GURL& url,
const std::string& frame_name) {
std::unique_ptr<WebUIImpl> web_ui =
base::MakeUnique<WebUIImpl>(this, frame_name);
std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUI(const GURL& url) {
std::unique_ptr<WebUIImpl> web_ui = base::MakeUnique<WebUIImpl>(this);
WebUIController* controller =
WebUIControllerFactoryRegistry::GetInstance()
->CreateWebUIControllerForURL(web_ui.get(), url);
......
......@@ -323,9 +323,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
void ClosePage() override;
RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const override;
SkColor GetThemeColor() const override;
std::unique_ptr<WebUI> CreateSubframeWebUI(
const GURL& url,
const std::string& frame_name) override;
WebUI* GetWebUI() const override;
WebUI* GetCommittedWebUI() const override;
void SetUserAgentOverride(const std::string& override) override;
......@@ -1285,11 +1282,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
void OnPreferredSizeChanged(const gfx::Size& old_size);
// Internal helper to create WebUI objects associated with |this|. |url| is
// used to determine which WebUI should be created (if any). |frame_name|
// corresponds to the name of a frame that the WebUI should be created for (or
// the main frame if empty).
std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url,
const std::string& frame_name);
// used to determine which WebUI should be created (if any).
std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url);
void SetJavaScriptDialogManagerForTesting(
JavaScriptDialogManager* dialog_manager);
......
......@@ -76,11 +76,10 @@ base::string16 WebUI::GetJavascriptCall(
return result;
}
WebUIImpl::WebUIImpl(WebContents* contents, const std::string& frame_name)
WebUIImpl::WebUIImpl(WebContents* contents)
: bindings_(BINDINGS_POLICY_WEB_UI),
web_contents_(contents),
web_contents_observer_(new MainFrameNavigationObserver(this, contents)),
frame_name_(frame_name) {
web_contents_observer_(new MainFrameNavigationObserver(this, contents)) {
DCHECK(contents);
}
......@@ -154,10 +153,6 @@ void WebUIImpl::SetBindings(int bindings) {
bindings_ = bindings;
}
bool WebUIImpl::HasRenderFrame() {
return TargetFrame() != nullptr;
}
WebUIController* WebUIImpl::GetController() const {
return controller_.get();
}
......@@ -167,13 +162,13 @@ void WebUIImpl::SetController(WebUIController* controller) {
}
bool WebUIImpl::CanCallJavascript() {
RenderFrameHost* target_frame = TargetFrame();
return target_frame &&
RenderFrameHost* frame_host = web_contents_->GetMainFrame();
return frame_host &&
(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
target_frame->GetProcess()->GetID()) ||
frame_host->GetProcess()->GetID()) ||
// It's possible to load about:blank in a Web UI renderer.
// See http://crbug.com/42547
target_frame->GetLastCommittedURL().spec() == url::kAboutBlankURL);
frame_host->GetLastCommittedURL().spec() == url::kAboutBlankURL);
}
void WebUIImpl::CallJavascriptFunctionUnsafe(const std::string& function_name) {
......@@ -276,19 +271,7 @@ void WebUIImpl::ExecuteJavascript(const base::string16& javascript) {
if (!CanCallJavascript())
return;
TargetFrame()->ExecuteJavaScript(javascript);
}
RenderFrameHost* WebUIImpl::TargetFrame() {
if (frame_name_.empty())
return web_contents_->GetMainFrame();
FrameTreeNode* frame_tree_node = static_cast<WebContentsImpl*>(web_contents_)
->GetFrameTree()
->FindByName(frame_name_);
if (frame_tree_node)
return frame_tree_node->current_frame_host();
return nullptr;
web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
}
void WebUIImpl::DisallowJavascriptOnAllHandlers() {
......
......@@ -23,7 +23,7 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
public IPC::Listener,
public base::SupportsWeakPtr<WebUIImpl> {
public:
WebUIImpl(WebContents* contents, const std::string& frame_name);
WebUIImpl(WebContents* contents);
~WebUIImpl() override;
// Called when a RenderFrame is created for a WebUI (reload after a renderer
......@@ -47,7 +47,6 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
void OverrideTitle(const base::string16& title) override;
int GetBindings() const override;
void SetBindings(int bindings) override;
bool HasRenderFrame() override;
void AddMessageHandler(std::unique_ptr<WebUIMessageHandler> handler) override;
typedef base::Callback<void(const base::ListValue*)> MessageCallback;
void RegisterMessageCallback(const std::string& message,
......@@ -91,11 +90,6 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
// Execute a string of raw JavaScript on the page.
void ExecuteJavascript(const base::string16& javascript);
// Finds the frame in which to execute JavaScript based on |frame_name_|. If
// |frame_name_| is empty, the main frame is returned. May return NULL if no
// frame of the specified name exists in the page.
RenderFrameHost* TargetFrame();
// Called internally and by the owned MainFrameNavigationObserver.
void DisallowJavascriptOnAllHandlers();
......@@ -118,10 +112,6 @@ class CONTENT_EXPORT WebUIImpl : public WebUI,
// Notifies this WebUI about notifications in the main frame.
std::unique_ptr<MainFrameNavigationObserver> web_contents_observer_;
// The name of the frame this WebUI is embedded in. If empty, the main frame
// is used.
const std::string frame_name_;
std::unique_ptr<WebUIController> controller_;
DISALLOW_COPY_AND_ASSIGN(WebUIImpl);
......
......@@ -321,15 +321,6 @@ class WebContents : public PageNavigator,
// theme-color meta tag.
virtual SkColor GetThemeColor() const = 0;
// Create a WebUI page for the given url. In most cases, this doesn't need to
// be called by embedders since content will create its own WebUI objects as
// necessary. However if the embedder wants to create its own WebUI object and
// keep track of it manually, it can use this. |frame_name| is used to
// identify the frame and cannot be empty.
virtual std::unique_ptr<WebUI> CreateSubframeWebUI(
const GURL& url,
const std::string& frame_name) = 0;
// Returns the committed WebUI if one exists, otherwise the pending one.
virtual WebUI* GetWebUI() const = 0;
virtual WebUI* GetCommittedWebUI() const = 0;
......
......@@ -66,10 +66,6 @@ class CONTENT_EXPORT WebUI {
virtual int GetBindings() const = 0;
virtual void SetBindings(int bindings) = 0;
// Whether this WebUI has a render frame associated with it. This will be true
// if the URL that created this WebUI was actually visited.
virtual bool HasRenderFrame() = 0;
virtual void AddMessageHandler(
std::unique_ptr<WebUIMessageHandler> handler) = 0;
......
......@@ -40,10 +40,6 @@ int TestWebUI::GetBindings() const {
return 0;
}
bool TestWebUI::HasRenderFrame() {
return false;
}
void TestWebUI::AddMessageHandler(
std::unique_ptr<WebUIMessageHandler> handler) {
handlers_.push_back(std::move(handler));
......
......@@ -34,7 +34,6 @@ class TestWebUI : public WebUI {
void OverrideTitle(const base::string16& title) override {}
int GetBindings() const override;
void SetBindings(int bindings) override {}
bool HasRenderFrame() override;
void AddMessageHandler(std::unique_ptr<WebUIMessageHandler> handler) override;
void RegisterMessageCallback(const std::string& message,
const MessageCallback& callback) override {}
......
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