| OLD | NEW |
| 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 tab_restore_service_ = profile->GetTabRestoreService(); | 234 tab_restore_service_ = profile->GetTabRestoreService(); |
| 235 if (tab_restore_service_) { | 235 if (tab_restore_service_) { |
| 236 tab_restore_service_->AddObserver(this); | 236 tab_restore_service_->AddObserver(this); |
| 237 TabRestoreServiceChanged(tab_restore_service_); | 237 TabRestoreServiceChanged(tab_restore_service_); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| 241 Browser::~Browser() { | 241 Browser::~Browser() { |
| 242 // The tab strip should not have any significant tabs at this point. | 242 // The tab strip should not have any significant tabs at this point. |
| 243 DCHECK(!tabstrip_model_.HasNonPhantomTabs()); | 243 DCHECK(tabstrip_model_.empty()); |
| 244 tabstrip_model_.RemoveObserver(this); | 244 tabstrip_model_.RemoveObserver(this); |
| 245 | 245 |
| 246 BrowserList::RemoveBrowser(this); | 246 BrowserList::RemoveBrowser(this); |
| 247 | 247 |
| 248 #if defined(OS_WIN) || defined(OS_LINUX) | 248 #if defined(OS_WIN) || defined(OS_LINUX) |
| 249 if (!BrowserList::HasBrowserWithProfile(profile_)) { | 249 if (!BrowserList::HasBrowserWithProfile(profile_)) { |
| 250 // We're the last browser window with this profile. We need to nuke the | 250 // We're the last browser window with this profile. We need to nuke the |
| 251 // TabRestoreService, which will start the shutdown of the | 251 // TabRestoreService, which will start the shutdown of the |
| 252 // NavigationControllers and allow for proper shutdown. If we don't do this | 252 // NavigationControllers and allow for proper shutdown. If we don't do this |
| 253 // chrome won't shutdown cleanly, and may end up crashing when some | 253 // chrome won't shutdown cleanly, and may end up crashing when some |
| (...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 } | 2344 } |
| 2345 | 2345 |
| 2346 void Browser::TabMoved(TabContents* contents, | 2346 void Browser::TabMoved(TabContents* contents, |
| 2347 int from_index, | 2347 int from_index, |
| 2348 int to_index) { | 2348 int to_index) { |
| 2349 DCHECK(from_index >= 0 && to_index >= 0); | 2349 DCHECK(from_index >= 0 && to_index >= 0); |
| 2350 // Notify the history service. | 2350 // Notify the history service. |
| 2351 SyncHistoryWithTabs(std::min(from_index, to_index)); | 2351 SyncHistoryWithTabs(std::min(from_index, to_index)); |
| 2352 } | 2352 } |
| 2353 | 2353 |
| 2354 void Browser::TabReplacedAt(TabContents* old_contents, | |
| 2355 TabContents* new_contents, int index) { | |
| 2356 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); | |
| 2357 TabInsertedAt(new_contents, index, | |
| 2358 (index == tabstrip_model_.selected_index())); | |
| 2359 | |
| 2360 int entry_count = new_contents->controller().entry_count(); | |
| 2361 if (entry_count > 0) { | |
| 2362 // Send out notification so that observers are updated appropriately. | |
| 2363 new_contents->controller().NotifyEntryChanged( | |
| 2364 new_contents->controller().GetEntryAtIndex(entry_count - 1), | |
| 2365 entry_count - 1); | |
| 2366 } | |
| 2367 } | |
| 2368 | |
| 2369 void Browser::TabPinnedStateChanged(TabContents* contents, int index) { | 2354 void Browser::TabPinnedStateChanged(TabContents* contents, int index) { |
| 2370 if (!profile()->HasSessionService()) | 2355 if (!profile()->HasSessionService()) |
| 2371 return; | 2356 return; |
| 2372 SessionService* session_service = profile()->GetSessionService(); | 2357 SessionService* session_service = profile()->GetSessionService(); |
| 2373 if (session_service) { | 2358 if (session_service) { |
| 2374 session_service->SetPinnedState( | 2359 session_service->SetPinnedState( |
| 2375 session_id(), | 2360 session_id(), |
| 2376 GetTabContentsAt(index)->controller().session_id(), | 2361 GetTabContentsAt(index)->controller().session_id(), |
| 2377 tabstrip_model_.IsTabPinned(index)); | 2362 tabstrip_model_.IsTabPinned(index)); |
| 2378 } | 2363 } |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3888 } | 3873 } |
| 3889 | 3874 |
| 3890 bool Browser::IsPinned(TabContents* source) { | 3875 bool Browser::IsPinned(TabContents* source) { |
| 3891 int index = tabstrip_model_.GetIndexOfTabContents(source); | 3876 int index = tabstrip_model_.GetIndexOfTabContents(source); |
| 3892 if (index == TabStripModel::kNoTab) { | 3877 if (index == TabStripModel::kNoTab) { |
| 3893 NOTREACHED() << "IsPinned called for tab not in our strip"; | 3878 NOTREACHED() << "IsPinned called for tab not in our strip"; |
| 3894 return false; | 3879 return false; |
| 3895 } | 3880 } |
| 3896 return tabstrip_model_.IsTabPinned(index); | 3881 return tabstrip_model_.IsTabPinned(index); |
| 3897 } | 3882 } |
| OLD | NEW |