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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 11359201: Remove TabContents from TabStripModelObserver::TabReplacedAt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_command_controller.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // defined(OS_WIN) 10 #endif // defined(OS_WIN)
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 1146
1147 void Browser::TabMoved(WebContents* contents, 1147 void Browser::TabMoved(WebContents* contents,
1148 int from_index, 1148 int from_index,
1149 int to_index) { 1149 int to_index) {
1150 DCHECK(from_index >= 0 && to_index >= 0); 1150 DCHECK(from_index >= 0 && to_index >= 0);
1151 // Notify the history service. 1151 // Notify the history service.
1152 SyncHistoryWithTabs(std::min(from_index, to_index)); 1152 SyncHistoryWithTabs(std::min(from_index, to_index));
1153 } 1153 }
1154 1154
1155 void Browser::TabReplacedAt(TabStripModel* tab_strip_model, 1155 void Browser::TabReplacedAt(TabStripModel* tab_strip_model,
1156 TabContents* old_contents, 1156 WebContents* old_contents,
1157 TabContents* new_contents, 1157 WebContents* new_contents,
1158 int index) { 1158 int index) {
1159 TabDetachedAtImpl(old_contents->web_contents(), index, DETACH_TYPE_REPLACE); 1159 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE);
1160 SessionService* session_service = 1160 SessionService* session_service =
1161 SessionServiceFactory::GetForProfile(profile_); 1161 SessionServiceFactory::GetForProfile(profile_);
1162 if (session_service) 1162 if (session_service)
1163 session_service->TabClosing(old_contents->web_contents()); 1163 session_service->TabClosing(old_contents);
1164 TabInsertedAt(new_contents->web_contents(), index, (index == active_index())); 1164 TabInsertedAt(new_contents, index, (index == active_index()));
1165 1165
1166 int entry_count = 1166 int entry_count = new_contents->GetController().GetEntryCount();
1167 new_contents->web_contents()->GetController().GetEntryCount();
1168 if (entry_count > 0) { 1167 if (entry_count > 0) {
1169 // Send out notification so that observers are updated appropriately. 1168 // Send out notification so that observers are updated appropriately.
1170 new_contents->web_contents()->GetController().NotifyEntryChanged( 1169 new_contents->GetController().NotifyEntryChanged(
1171 new_contents->web_contents()->GetController().GetEntryAtIndex( 1170 new_contents->GetController().GetEntryAtIndex(entry_count - 1),
1172 entry_count - 1),
1173 entry_count - 1); 1171 entry_count - 1);
1174 } 1172 }
1175 1173
1176 if (session_service) { 1174 if (session_service) {
1177 // The new_contents may end up with a different navigation stack. Force 1175 // The new_contents may end up with a different navigation stack. Force
1178 // the session service to update itself. 1176 // the session service to update itself.
1179 session_service->TabRestored(new_contents, 1177 session_service->TabRestored(new_contents,
1180 tab_strip_model_->IsTabPinned(index)); 1178 tab_strip_model_->IsTabPinned(index));
1181 } 1179 }
1182 1180
1183 content::DevToolsManager::GetInstance()->ContentsReplaced( 1181 content::DevToolsManager::GetInstance()->ContentsReplaced(
1184 old_contents->web_contents(), new_contents->web_contents()); 1182 old_contents, new_contents);
1185 } 1183 }
1186 1184
1187 void Browser::TabPinnedStateChanged(WebContents* contents, int index) { 1185 void Browser::TabPinnedStateChanged(WebContents* contents, int index) {
1188 SessionService* session_service = 1186 SessionService* session_service =
1189 SessionServiceFactory::GetForProfileIfExisting(profile()); 1187 SessionServiceFactory::GetForProfileIfExisting(profile());
1190 if (session_service) { 1188 if (session_service) {
1191 SessionTabHelper* session_tab_helper = 1189 SessionTabHelper* session_tab_helper =
1192 SessionTabHelper::FromWebContents(contents); 1190 SessionTabHelper::FromWebContents(contents);
1193 session_service->SetPinnedState(session_id(), 1191 session_service->SetPinnedState(session_id(),
1194 session_tab_helper->session_id(), 1192 session_tab_helper->session_id(),
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 if (contents && !allow_js_access) { 2350 if (contents && !allow_js_access) {
2353 contents->web_contents()->GetController().LoadURL( 2351 contents->web_contents()->GetController().LoadURL(
2354 target_url, 2352 target_url,
2355 content::Referrer(), 2353 content::Referrer(),
2356 content::PAGE_TRANSITION_LINK, 2354 content::PAGE_TRANSITION_LINK,
2357 std::string()); // No extra headers. 2355 std::string()); // No extra headers.
2358 } 2356 }
2359 2357
2360 return contents != NULL; 2358 return contents != NULL;
2361 } 2359 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_command_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698