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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/tabs/tab_strip_model.h" 5 #include "chrome/browser/tabs/tab_strip_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 void TabStripModelObserver::TabChangedAt(TabContents* contents, int index, 76 void TabStripModelObserver::TabChangedAt(TabContents* contents, int index,
77 TabChangeType change_type) { 77 TabChangeType change_type) {
78 } 78 }
79 79
80 void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, 80 void TabStripModelObserver::TabReplacedAt(TabContents* old_contents,
81 TabContents* new_contents, 81 TabContents* new_contents,
82 int index) { 82 int index) {
83 } 83 }
84 84
85 void TabStripModelObserver::TabReplacedAt(TabContents* old_contents,
86 TabContents* new_contents,
87 int index,
88 TabReplaceType type) {
89 TabReplacedAt(old_contents, new_contents, index);
90 }
91
85 void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, 92 void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents,
86 int index) { 93 int index) {
87 } 94 }
88 95
89 void TabStripModelObserver::TabMiniStateChanged(TabContents* contents, 96 void TabStripModelObserver::TabMiniStateChanged(TabContents* contents,
90 int index) { 97 int index) {
91 } 98 }
92 99
93 void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents, 100 void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents,
94 int index) { 101 int index) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ++selected_index_; 233 ++selected_index_;
227 } 234 }
228 235
229 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 236 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
230 TabInsertedAt(contents, index, foreground)); 237 TabInsertedAt(contents, index, foreground));
231 238
232 if (foreground) 239 if (foreground)
233 ChangeSelectedContentsFrom(selected_contents, index, false); 240 ChangeSelectedContentsFrom(selected_contents, index, false);
234 } 241 }
235 242
243 void TabStripModel::ReplaceTabContentsAt(
244 int index,
245 TabContents* new_contents,
246 TabStripModelObserver::TabReplaceType type) {
247 delete ReplaceTabContentsAtImpl(index, new_contents, type);
248 }
249
236 void TabStripModel::ReplaceNavigationControllerAt( 250 void TabStripModel::ReplaceNavigationControllerAt(
237 int index, NavigationController* controller) { 251 int index, NavigationController* controller) {
238 // This appears to be OK with no flicker since no redraw event 252 // This appears to be OK with no flicker since no redraw event
239 // occurs between the call to add an aditional tab and one to close 253 // occurs between the call to add an aditional tab and one to close
240 // the previous tab. 254 // the previous tab.
241 InsertTabContentsAt( 255 InsertTabContentsAt(
242 index + 1, controller->tab_contents(), 256 index + 1, controller->tab_contents(),
243 ADD_SELECTED | ADD_INHERIT_GROUP); 257 ADD_SELECTED | ADD_INHERIT_GROUP);
244 std::vector<int> closing_tabs; 258 std::vector<int> closing_tabs;
245 closing_tabs.push_back(index); 259 closing_tabs.push_back(index);
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 DCHECK(extension_app); 1050 DCHECK(extension_app);
1037 1051
1038 // Only allow the tab to be made phantom if the extension still exists. 1052 // Only allow the tab to be made phantom if the extension still exists.
1039 return extension_service->GetExtensionById(extension_app->id(), 1053 return extension_service->GetExtensionById(extension_app->id(),
1040 false) != NULL; 1054 false) != NULL;
1041 } 1055 }
1042 return false; 1056 return false;
1043 } 1057 }
1044 1058
1045 void TabStripModel::MakePhantom(int index) { 1059 void TabStripModel::MakePhantom(int index) {
1046 TabContents* old_contents = GetContentsAt(index); 1060 // MakePhantom is called when the TabContents is being destroyed so we don't
1047 TabContents* new_contents = old_contents->CloneAndMakePhantom(); 1061 // need to do anything with the returned value from ReplaceTabContentsAtImpl.
1048 1062 ReplaceTabContentsAtImpl(index, GetContentsAt(index)->CloneAndMakePhantom(),
1049 contents_data_[index]->contents = new_contents; 1063 TabStripModelObserver::REPLACE_MADE_PHANTOM);
1050
1051 // And notify observers.
1052 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
1053 TabReplacedAt(old_contents, new_contents, index));
1054 1064
1055 if (selected_index_ == index && HasNonPhantomTabs()) { 1065 if (selected_index_ == index && HasNonPhantomTabs()) {
1056 // Change the selection, otherwise we're going to force the phantom tab 1066 // Change the selection, otherwise we're going to force the phantom tab
1057 // to become selected. 1067 // to become selected.
1058 // NOTE: we must do this after the call to Replace otherwise browser's 1068 // NOTE: we must do this after the call to Replace otherwise browser's
1059 // TabSelectedAt will send out updates for the old TabContents which we've 1069 // TabSelectedAt will send out updates for the old TabContents which we've
1060 // already told observers has been closed (we sent out TabClosing at). 1070 // already told observers has been closed (we sent out TabClosing at).
1061 int new_selected_index = 1071 int new_selected_index =
1062 order_controller_->DetermineNewSelectedIndex(index, false); 1072 order_controller_->DetermineNewSelectedIndex(index, false);
1063 new_selected_index = IndexOfNextNonPhantomTab(new_selected_index, 1073 new_selected_index = IndexOfNextNonPhantomTab(new_selected_index,
(...skipping 24 matching lines...) Expand all
1088 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 1098 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
1089 TabMoved(moved_data->contents, index, to_position)); 1099 TabMoved(moved_data->contents, index, to_position));
1090 } 1100 }
1091 1101
1092 // static 1102 // static
1093 bool TabStripModel::OpenerMatches(const TabContentsData* data, 1103 bool TabStripModel::OpenerMatches(const TabContentsData* data,
1094 const NavigationController* opener, 1104 const NavigationController* opener,
1095 bool use_group) { 1105 bool use_group) {
1096 return data->opener == opener || (use_group && data->group == opener); 1106 return data->opener == opener || (use_group && data->group == opener);
1097 } 1107 }
1108
1109 TabContents* TabStripModel::ReplaceTabContentsAtImpl(
1110 int index,
1111 TabContents* new_contents,
1112 TabStripModelObserver::TabReplaceType type) {
1113 // TODO: this should reset group/opener of any tabs that point at
1114 // old_contents.
1115 DCHECK(ContainsIndex(index));
1116
1117 TabContents* old_contents = GetContentsAt(index);
1118
1119 contents_data_[index]->contents = new_contents;
1120
1121 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
1122 TabReplacedAt(old_contents, new_contents, index, type));
1123 return old_contents;
1124 }
OLDNEW
« 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