OLD | NEW |
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/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // Then move the non-pinned tabs. | 349 // Then move the non-pinned tabs. |
350 MoveSelectedTabsToImpl(std::max(index, total_mini_count), | 350 MoveSelectedTabsToImpl(std::max(index, total_mini_count), |
351 selected_mini_count, | 351 selected_mini_count, |
352 selected_count - selected_mini_count); | 352 selected_count - selected_mini_count); |
353 } | 353 } |
354 | 354 |
355 TabContents* TabStripModel::GetActiveTabContents() const { | 355 TabContents* TabStripModel::GetActiveTabContents() const { |
356 return GetTabContentsAt(active_index()); | 356 return GetTabContentsAt(active_index()); |
357 } | 357 } |
358 | 358 |
| 359 content::WebContents* TabStripModel::GetActiveWebContents() const { |
| 360 return GetTabContentsAt(active_index())->web_contents(); |
| 361 } |
| 362 |
359 TabContents* TabStripModel::GetTabContentsAt(int index) const { | 363 TabContents* TabStripModel::GetTabContentsAt(int index) const { |
360 if (ContainsIndex(index)) | 364 if (ContainsIndex(index)) |
361 return GetContentsAt(index); | 365 return GetContentsAt(index); |
362 return NULL; | 366 return NULL; |
363 } | 367 } |
364 | 368 |
| 369 content::WebContents* TabStripModel::GetWebContentsAt(int index) const { |
| 370 if (ContainsIndex(index)) |
| 371 return GetContentsAt(index)->web_contents(); |
| 372 return NULL; |
| 373 } |
| 374 |
365 int TabStripModel::GetIndexOfTabContents(const TabContents* contents) const { | 375 int TabStripModel::GetIndexOfTabContents(const TabContents* contents) const { |
366 for (size_t i = 0; i < contents_data_.size(); ++i) { | 376 for (size_t i = 0; i < contents_data_.size(); ++i) { |
367 if (contents_data_[i]->contents == contents) | 377 if (contents_data_[i]->contents == contents) |
368 return i; | 378 return i; |
369 } | 379 } |
370 return kNoTab; | 380 return kNoTab; |
371 } | 381 } |
372 | 382 |
373 int TabStripModel::GetIndexOfWebContents(const WebContents* contents) const { | 383 int TabStripModel::GetIndexOfWebContents(const WebContents* contents) const { |
374 return contents ? | 384 return contents ? |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1329 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
1320 const NavigationController* tab) { | 1330 const NavigationController* tab) { |
1321 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1331 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
1322 i != contents_data_.end(); ++i) { | 1332 i != contents_data_.end(); ++i) { |
1323 if ((*i)->group == tab) | 1333 if ((*i)->group == tab) |
1324 (*i)->group = NULL; | 1334 (*i)->group = NULL; |
1325 if ((*i)->opener == tab) | 1335 if ((*i)->opener == tab) |
1326 (*i)->opener = NULL; | 1336 (*i)->opener = NULL; |
1327 } | 1337 } |
1328 } | 1338 } |
OLD | NEW |