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

Unified Diff: content/browser/tab_contents/tab_contents.cc

Issue 9224002: Make WebUI objects not derive from WebUI. WebUI objects own the controller. This is the ownership... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head to clear linux_chromeos browsertest failures Created 8 years, 11 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/browser/tab_contents/tab_contents.cc
===================================================================
--- content/browser/tab_contents/tab_contents.cc (revision 117871)
+++ content/browser/tab_contents/tab_contents.cc (working copy)
@@ -121,6 +121,7 @@
using content::UserMetricsAction;
using content::WebContents;
using content::WebContentsObserver;
+using content::WebUIController;
namespace {
@@ -431,6 +432,20 @@
return view_.get();
}
+WebUI* TabContents::CreateWebUI(const GURL& url) {
+ WebUI* web_ui = new WebUI(this);
+ WebUIController* controller =
+ content::GetContentClient()->browser()->GetWebUIFactory()->
+ CreateWebUIForURL(web_ui, url);
+ if (controller) {
+ web_ui->SetController(controller);
+ return web_ui;
+ }
+
+ delete web_ui;
+ return NULL;
+}
+
WebUI* TabContents::GetWebUI() const {
return render_manager_.web_ui() ? render_manager_.web_ui()
: render_manager_.pending_web_ui();
@@ -457,7 +472,7 @@
entry = controller_.GetActiveEntry();
if (!(entry && entry->IsViewSourceMode())) {
// Give the Web UI the chance to override our title.
- const string16& title = our_web_ui->overridden_title();
+ const string16& title = our_web_ui->GetOverriddenTitle();
if (!title.empty())
return title;
}
@@ -1121,7 +1136,7 @@
bool TabContents::FocusLocationBarByDefault() {
WebUI* web_ui = GetWebUIForCurrentState();
if (web_ui)
- return web_ui->focus_location_bar_by_default();
+ return web_ui->ShouldFocusLocationBarByDefault();
NavigationEntry* entry = controller_.GetActiveEntry();
if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL))
return true;
@@ -1465,8 +1480,7 @@
// that opened the window, as long as both renderers have the same
// privileges.
if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) {
- WebUI* web_ui = content::GetContentClient()->browser()->
- GetWebUIFactory()->CreateWebUIForURL(this, GetURL());
+ WebUI* web_ui = CreateWebUI(GetURL());
// web_ui might be NULL if the URL refers to a non-existent extension.
if (web_ui) {
render_manager_.SetWebUIPostCommit(web_ui);
@@ -1944,11 +1958,11 @@
// chrome: URLs might have search terms or other stuff we don't want to
// send to the site), so we send no referrer.
OpenURLParams params(url, content::Referrer(), disposition,
- render_manager_.web_ui()->link_transition_type(),
+ render_manager_.web_ui()->GetLinkTransitionType(),
false /* is_renderer_initiated */);
params.transferred_global_request_id = old_request_id;
new_contents = OpenURL(params);
- transition_type = render_manager_.web_ui()->link_transition_type();
+ transition_type = render_manager_.web_ui()->GetLinkTransitionType();
} else {
OpenURLParams params(url, referrer, disposition,
content::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */);
@@ -2178,8 +2192,7 @@
}
WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) {
- return content::GetContentClient()->browser()->GetWebUIFactory()->
- CreateWebUIForURL(this, url);
+ return CreateWebUI(url);
}
NavigationEntry*

Powered by Google App Engine
This is Rietveld 408576698