OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/metrics/user_metrics.h" | 10 #include "chrome/browser/metrics/user_metrics.h" |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 508 |
509 bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const { | 509 bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const { |
510 return LowerCaseEqualsASCII(contents->GetURL().spec(), | 510 return LowerCaseEqualsASCII(contents->GetURL().spec(), |
511 chrome::kChromeUINewTabURL) && | 511 chrome::kChromeUINewTabURL) && |
512 contents == GetContentsAt(count() - 1) && | 512 contents == GetContentsAt(count() - 1) && |
513 contents->controller().entry_count() == 1; | 513 contents->controller().entry_count() == 1; |
514 } | 514 } |
515 | 515 |
516 bool TabStripModel::InternalCloseTabContentsAt(int index, | 516 bool TabStripModel::InternalCloseTabContentsAt(int index, |
517 bool create_historical_tab) { | 517 bool create_historical_tab) { |
| 518 if (!delegate_->CanCloseContentsAt(index)) |
| 519 return false; |
| 520 |
518 TabContents* detached_contents = GetContentsAt(index); | 521 TabContents* detached_contents = GetContentsAt(index); |
519 | 522 |
520 if (delegate_->RunUnloadListenerBeforeClosing(detached_contents)) | 523 if (delegate_->RunUnloadListenerBeforeClosing(detached_contents)) |
521 return false; | 524 return false; |
522 | 525 |
523 // TODO: Now that we know the tab has no unload/beforeunload listeners, | 526 // TODO: Now that we know the tab has no unload/beforeunload listeners, |
524 // we should be able to do a fast shutdown of the RenderViewProcess. | 527 // we should be able to do a fast shutdown of the RenderViewProcess. |
525 // Make sure that we actually do. | 528 // Make sure that we actually do. |
526 | 529 |
527 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 530 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 int index = GetIndexOfTabContents(contents); | 568 int index = GetIndexOfTabContents(contents); |
566 contents_data_.at(index)->opener = &opener->controller(); | 569 contents_data_.at(index)->opener = &opener->controller(); |
567 } | 570 } |
568 | 571 |
569 // static | 572 // static |
570 bool TabStripModel::OpenerMatches(const TabContentsData* data, | 573 bool TabStripModel::OpenerMatches(const TabContentsData* data, |
571 const NavigationController* opener, | 574 const NavigationController* opener, |
572 bool use_group) { | 575 bool use_group) { |
573 return data->opener == opener || (use_group && data->group == opener); | 576 return data->opener == opener || (use_group && data->group == opener); |
574 } | 577 } |
OLD | NEW |