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

Unified Diff: chrome/browser/ui/toolbar/toolbar_model.cc

Issue 9479008: Re-factor location bar/toolbar code to get rid of the browser dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 8 years, 10 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: chrome/browser/ui/toolbar/toolbar_model.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc
index ef9d04497c9bfd0c3323f51e5b90b16a9b5d68c9..41e15dbc0cf3456a88ef439f2f62bc3a114cad70 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model.cc
@@ -34,6 +34,13 @@ using content::WebContents;
ToolbarModel::ToolbarModel(Browser* browser)
: browser_(browser),
+ web_contents_(NULL),
+ input_in_progress_(false) {
+}
+
+ToolbarModel::ToolbarModel(WebContents* web_contents)
+ : browser_(NULL),
+ web_contents_(web_contents),
input_in_progress_(false) {
}
@@ -84,7 +91,7 @@ bool ToolbarModel::ShouldDisplayURL() const {
}
}
- WebContents* web_contents = browser_->GetSelectedWebContents();
+ WebContents* web_contents = GetSelectedWebContents();
if (web_contents && web_contents->GetWebUIForCurrentState())
return !web_contents->GetWebUIForCurrentState()->ShouldHideURL();
@@ -174,6 +181,12 @@ NavigationController* ToolbarModel::GetNavigationController() const {
// This |current_tab| can be NULL during the initialization of the
// toolbar during window creation (i.e. before any tabs have been added
// to the window).
- WebContents* current_tab = browser_->GetSelectedWebContents();
+ WebContents* current_tab = GetSelectedWebContents();
return current_tab ? &current_tab->GetController() : NULL;
}
+
+WebContents* ToolbarModel::GetSelectedWebContents() const {
+ if (browser_)
+ return browser_->GetSelectedWebContents();
+ return web_contents_;
+}

Powered by Google App Engine
This is Rietveld 408576698