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

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

Issue 9297043: Cleanup: Use TabStripModel pass-thrus in more places, use to be removed tabstrip_model() accessor i… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
===================================================================
--- chrome/browser/ui/browser.cc (revision 119531)
+++ chrome/browser/ui/browser.cc (working copy)
@@ -1192,7 +1192,7 @@
}
TabContentsWrapper* Browser::GetSelectedTabContentsWrapper() const {
- return tabstrip_model()->GetActiveTabContents();
+ return tab_handler_->GetTabStripModel()->GetActiveTabContents();
}
WebContents* Browser::GetSelectedWebContents() const {
@@ -1201,11 +1201,11 @@
}
TabContentsWrapper* Browser::GetTabContentsWrapperAt(int index) const {
- return tabstrip_model()->GetTabContentsAt(index);
+ return tab_handler_->GetTabStripModel()->GetTabContentsAt(index);
}
WebContents* Browser::GetWebContentsAt(int index) const {
- TabContentsWrapper* wrapper = tabstrip_model()->GetTabContentsAt(index);
+ TabContentsWrapper* wrapper = GetTabContentsWrapperAt(index);
if (wrapper)
return wrapper->web_contents();
return NULL;
@@ -1216,7 +1216,7 @@
}
bool Browser::IsTabPinned(int index) const {
- return tabstrip_model()->IsTabPinned(index);
+ return tab_handler_->GetTabStripModel()->IsTabPinned(index);
}
bool Browser::IsTabDiscarded(int index) const {
@@ -1327,7 +1327,9 @@
int add_types = select ? TabStripModel::ADD_ACTIVE :
TabStripModel::ADD_NONE;
if (pin) {
- tab_index = std::min(tab_index, tabstrip_model()->IndexOfFirstNonMiniTab());
+ int first_mini_tab_idx =
+ tab_handler_->GetTabStripModel()->IndexOfFirstNonMiniTab();
+ tab_index = std::min(tab_index, first_mini_tab_idx);
add_types |= TabStripModel::ADD_PINNED;
}
tab_handler_->GetTabStripModel()->InsertTabContentsAt(tab_index, wrapper,
@@ -1375,8 +1377,7 @@
DCHECK_EQ(0u, entries.size());
tab_handler_->GetTabStripModel()->ReplaceNavigationControllerAt(
- tab_handler_->GetTabStripModel()->active_index(),
- wrapper);
+ active_index(), wrapper);
}
bool Browser::CanRestoreTab() {
@@ -1634,7 +1635,7 @@
void Browser::Stop() {
content::RecordAction(UserMetricsAction("Stop"));
- GetSelectedTabContentsWrapper()->web_contents()->Stop();
+ GetSelectedWebContents()->Stop();
}
void Browser::NewWindow() {
@@ -1674,7 +1675,7 @@
if (is_type_tabbed()) {
AddBlankTab(true);
- GetSelectedTabContentsWrapper()->web_contents()->GetView()->RestoreFocus();
+ GetSelectedWebContents()->GetView()->RestoreFocus();
} else {
Browser* b = GetOrCreateTabbedBrowser(profile_);
b->AddBlankTab(true);
@@ -1682,8 +1683,7 @@
// The call to AddBlankTab above did not set the focus to the tab as its
// window was not active, so we have to do it explicitly.
// See http://crbug.com/6380.
- b->GetSelectedTabContentsWrapper()->web_contents()->GetView()->
- RestoreFocus();
+ b->GetSelectedWebContents()->GetView()->RestoreFocus();
}
}
@@ -1730,7 +1730,7 @@
void Browser::SelectNumberedTab(int index) {
if (index < tab_count()) {
content::RecordAction(UserMetricsAction("SelectNumberedTab"));
- tab_handler_->GetTabStripModel()->ActivateTabAt(index, true);
+ ActivateTabAt(index, true);
}
}
@@ -1771,9 +1771,8 @@
void Browser::ConvertPopupToTabbedBrowser() {
content::RecordAction(UserMetricsAction("ShowAsTab"));
- int tab_strip_index = tab_handler_->GetTabStripModel()->active_index();
TabContentsWrapper* contents =
- tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index);
+ tab_handler_->GetTabStripModel()->DetachTabContentsAt(active_index());
Browser* browser = Browser::Create(profile_);
browser->tabstrip_model()->AppendTabContents(contents, true);
browser->window()->Show();
@@ -1967,8 +1966,7 @@
if (is_devtools())
return;
- RenderViewHost* host =
- GetSelectedTabContentsWrapper()->web_contents()->GetRenderViewHost();
+ RenderViewHost* host = GetSelectedWebContents()->GetRenderViewHost();
if (zoom == content::PAGE_ZOOM_RESET) {
host->SetZoomLevel(0);
content::RecordAction(UserMetricsAction("ZoomNormal"));
@@ -2106,7 +2104,7 @@
content::RecordAction(UserMetricsAction("DevTools_ToggleWindow"));
DevToolsWindow::ToggleDevToolsWindow(
- GetSelectedTabContentsWrapper()->web_contents()->GetRenderViewHost(),
+ GetSelectedWebContents()->GetRenderViewHost(),
action);
}
@@ -2612,8 +2610,7 @@
const NavigationController* controller, int* index_result) {
BrowserList::const_iterator it;
for (it = BrowserList::begin(); it != BrowserList::end(); ++it) {
- int index = (*it)->tab_handler_->GetTabStripModel()->GetIndexOfController(
- controller);
+ int index = (*it)->GetIndexOfController(controller);
if (index != TabStripModel::kNoTab) {
if (index_result)
*index_result = index;
@@ -3087,7 +3084,7 @@
void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents,
content::PageTransition transition,
bool user_initiated) {
- tabstrip_model()->TabNavigating(contents, transition);
+ tab_handler_->GetTabStripModel()->TabNavigating(contents, transition);
bool contents_is_selected = contents == GetSelectedTabContentsWrapper();
if (user_initiated && contents_is_selected && window()->GetLocationBar()) {
@@ -3221,7 +3218,7 @@
// window next to the tab being duplicated.
int index = tab_handler_->GetTabStripModel()->
GetIndexOfTabContents(contents);
- pinned = tab_handler_->GetTabStripModel()->IsTabPinned(index);
+ pinned = IsTabPinned(index);
int add_types = TabStripModel::ADD_ACTIVE |
TabStripModel::ADD_INHERIT_GROUP |
(pinned ? TabStripModel::ADD_PINNED : 0);
@@ -3310,8 +3307,7 @@
// in-progress downloads.
// Note that the next call when it returns false will ask the user for
// confirmation before closing the browser if the user decides so.
- if (tab_handler_->GetTabStripModel()->count() ==
- static_cast<int>(indices->size()) &&
+ if (tab_count() == static_cast<int>(indices->size()) &&
!CanCloseWithInProgressDownloads()) {
indices->clear();
can_close_all = false;
@@ -3452,8 +3448,7 @@
SessionService* session_service =
SessionServiceFactory::GetForProfileIfExisting(profile_);
if (session_service && !tab_handler_->GetTabStripModel()->closing_all()) {
- session_service->SetSelectedTabInWindow(
- session_id(), tab_handler_->GetTabStripModel()->active_index());
+ session_service->SetSelectedTabInWindow(session_id(), active_index());
}
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH);
@@ -3472,8 +3467,7 @@
TabContentsWrapper* new_contents,
int index) {
TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE);
- TabInsertedAt(new_contents, index,
- (index == tab_handler_->GetTabStripModel()->active_index()));
+ TabInsertedAt(new_contents, index, (index == active_index()));
int entry_count =
new_contents->web_contents()->GetController().GetEntryCount();
@@ -3490,8 +3484,7 @@
if (session_service) {
// The new_contents may end up with a different navigation stack. Force
// the session service to update itself.
- session_service->TabRestored(
- new_contents, tab_handler_->GetTabStripModel()->IsTabPinned(index));
+ session_service->TabRestored(new_contents, IsTabPinned(index));
}
content::DevToolsManager::GetInstance()->TabReplaced(
@@ -3505,7 +3498,7 @@
session_service->SetPinnedState(
session_id(),
GetTabContentsWrapperAt(index)->restore_tab_helper()->session_id(),
- tab_handler_->GetTabStripModel()->IsTabPinned(index));
+ IsTabPinned(index));
}
}
@@ -3528,9 +3521,8 @@
WebContents* Browser::OpenURLFromTab(WebContents* source,
const OpenURLParams& params) {
browser::NavigateParams nav_params(this, params.url, params.transition);
- nav_params.source_contents =
- tabstrip_model()->GetTabContentsAt(
- tabstrip_model()->GetWrapperIndex(source));
+ nav_params.source_contents = GetTabContentsWrapperAt(
+ tab_handler_->GetTabStripModel()->GetWrapperIndex(source));
nav_params.referrer = params.referrer;
nav_params.disposition = params.disposition;
nav_params.tabstrip_add_types = TabStripModel::ADD_NONE;
@@ -3609,10 +3601,9 @@
}
browser::NavigateParams params(this, new_wrapper);
- params.source_contents =
- source ? tabstrip_model()->GetTabContentsAt(
- tabstrip_model()->GetWrapperIndex(source))
- : NULL;
+ params.source_contents = source ? GetTabContentsWrapperAt(
+ tab_handler_->GetTabStripModel()->GetWrapperIndex(source))
+ : NULL;
params.disposition = disposition;
params.window_bounds = initial_pos;
params.window_action = browser::NavigateParams::SHOW_WINDOW;
@@ -3621,8 +3612,8 @@
}
void Browser::ActivateContents(WebContents* contents) {
- tab_handler_->GetTabStripModel()->ActivateTabAt(
- tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false);
+ ActivateTabAt(tab_handler_->GetTabStripModel()->GetWrapperIndex(contents),
+ false);
window_->Activate();
}
@@ -3886,8 +3877,8 @@
void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) {
DCHECK(source);
- int index = tabstrip_model()->GetWrapperIndex(source);
- TabContentsWrapper* wrapper = tabstrip_model()->GetTabContentsAt(index);
+ TabContentsWrapper* wrapper = GetTabContentsWrapperAt(
+ tab_handler_->GetTabStripModel()->GetWrapperIndex(source));
ViewSource(wrapper);
}
@@ -3895,8 +3886,8 @@
const GURL& frame_url,
const std::string& frame_content_state) {
DCHECK(source);
- int index = tabstrip_model()->GetWrapperIndex(source);
- TabContentsWrapper* wrapper = tabstrip_model()->GetTabContentsAt(index);
+ TabContentsWrapper* wrapper = GetTabContentsWrapperAt(
+ tab_handler_->GetTabStripModel()->GetWrapperIndex(source));
ViewSource(wrapper, frame_url, frame_content_state);
}
@@ -4446,12 +4437,12 @@
}
void Browser::SetTabContentBlocked(TabContentsWrapper* wrapper, bool blocked) {
- int index = tabstrip_model()->GetIndexOfTabContents(wrapper);
+ int index = tab_handler_->GetTabStripModel()->GetIndexOfTabContents(wrapper);
if (index == TabStripModel::kNoTab) {
NOTREACHED();
return;
}
- tabstrip_model()->SetTabBlocked(index, blocked);
+ tab_handler_->GetTabStripModel()->SetTabBlocked(index, blocked);
UpdatePrintingState(wrapper->web_contents()->GetContentRestrictions());
}
@@ -4912,8 +4903,7 @@
// immediately start/stop, which gives a more snappy feel. We want to do
// this for any tab so they start & stop quickly.
tab_handler_->GetTabStripModel()->UpdateTabContentsStateAt(
- tab_handler_->GetTabStripModel()->GetIndexOfController(
- &source->GetController()),
+ GetIndexOfController(&source->GetController()),
TabStripModelObserver::LOADING_ONLY);
// The status bubble needs to be updated during INVALIDATE_TYPE_LOAD too,
// but we do that asynchronously by not stripping INVALIDATE_TYPE_LOAD from
@@ -4926,8 +4916,7 @@
// the TabStripModel, so we notify the TabStripModel now and notify others
// asynchronously.
tab_handler_->GetTabStripModel()->UpdateTabContentsStateAt(
- tab_handler_->GetTabStripModel()->GetIndexOfController(
- &source->GetController()),
+ GetIndexOfController(&source->GetController()),
TabStripModelObserver::TITLE_NOT_LOADING);
}
@@ -5052,7 +5041,7 @@
session_service->SetPinnedState(
session_id(),
tab->restore_tab_helper()->session_id(),
- tab_handler_->GetTabStripModel()->IsTabPinned(i));
+ IsTabPinned(i));
}
}
}
@@ -5251,8 +5240,7 @@
SetAsDelegate(contents, NULL);
RemoveScheduledUpdatesFor(contents->web_contents());
- if (find_bar_controller_.get() &&
- index == tab_handler_->GetTabStripModel()->active_index()) {
+ if (find_bar_controller_.get() && index == active_index()) {
find_bar_controller_->ChangeTabContents(NULL);
}
@@ -5403,8 +5391,8 @@
if (CanSupportWindowFeature(FEATURE_TABSTRIP)) {
// If this is a tabbed browser, just create a duplicate tab inside the same
// window next to the tab being duplicated.
- int index = tab_handler_->GetTabStripModel()->
- GetIndexOfTabContents(contents);
+ int index =
+ tab_handler_->GetTabStripModel()->GetIndexOfTabContents(contents);
int add_types = TabStripModel::ADD_ACTIVE |
TabStripModel::ADD_INHERIT_GROUP;
tab_handler_->GetTabStripModel()->InsertTabContentsAt(index + 1,
@@ -5498,8 +5486,7 @@
}
void Browser::ToggleSpeechInput() {
- GetSelectedTabContentsWrapper()->web_contents()->GetRenderViewHost()->
- ToggleSpeechInput();
+ GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
}
void Browser::OnWindowDidShow() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698