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

Unified Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 3105004: Adds support for showing the match preview on views. It's behind the (Closed)
Patch Set: Addressed review comments Created 10 years, 4 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 | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/views/frame/browser_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tabs/tab_strip_model.cc
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 8ac8fc443028242484d4212533a9a4b045b44f7f..269de35f021e68fb9b1ab828787416217ee90260 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -82,6 +82,13 @@ void TabStripModelObserver::TabReplacedAt(TabContents* old_contents,
int index) {
}
+void TabStripModelObserver::TabReplacedAt(TabContents* old_contents,
+ TabContents* new_contents,
+ int index,
+ TabReplaceType type) {
+ TabReplacedAt(old_contents, new_contents, index);
+}
+
void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents,
int index) {
}
@@ -233,6 +240,13 @@ void TabStripModel::InsertTabContentsAt(int index,
ChangeSelectedContentsFrom(selected_contents, index, false);
}
+void TabStripModel::ReplaceTabContentsAt(
+ int index,
+ TabContents* new_contents,
+ TabStripModelObserver::TabReplaceType type) {
+ delete ReplaceTabContentsAtImpl(index, new_contents, type);
+}
+
void TabStripModel::ReplaceNavigationControllerAt(
int index, NavigationController* controller) {
// This appears to be OK with no flicker since no redraw event
@@ -1043,14 +1057,10 @@ bool TabStripModel::ShouldMakePhantomOnClose(int index) {
}
void TabStripModel::MakePhantom(int index) {
- TabContents* old_contents = GetContentsAt(index);
- TabContents* new_contents = old_contents->CloneAndMakePhantom();
-
- contents_data_[index]->contents = new_contents;
-
- // And notify observers.
- FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
- TabReplacedAt(old_contents, new_contents, index));
+ // MakePhantom is called when the TabContents is being destroyed so we don't
+ // need to do anything with the returned value from ReplaceTabContentsAtImpl.
+ ReplaceTabContentsAtImpl(index, GetContentsAt(index)->CloneAndMakePhantom(),
+ TabStripModelObserver::REPLACE_MADE_PHANTOM);
if (selected_index_ == index && HasNonPhantomTabs()) {
// Change the selection, otherwise we're going to force the phantom tab
@@ -1095,3 +1105,20 @@ bool TabStripModel::OpenerMatches(const TabContentsData* data,
bool use_group) {
return data->opener == opener || (use_group && data->group == opener);
}
+
+TabContents* TabStripModel::ReplaceTabContentsAtImpl(
+ int index,
+ TabContents* new_contents,
+ TabStripModelObserver::TabReplaceType type) {
+ // TODO: this should reset group/opener of any tabs that point at
+ // old_contents.
+ DCHECK(ContainsIndex(index));
+
+ TabContents* old_contents = GetContentsAt(index);
+
+ contents_data_[index]->contents = new_contents;
+
+ FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
+ TabReplacedAt(old_contents, new_contents, index, type));
+ return old_contents;
+}
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698