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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 DCHECK(opener); | 599 DCHECK(opener); |
600 DCHECK(ContainsIndex(start_index)); | 600 DCHECK(ContainsIndex(start_index)); |
601 | 601 |
602 std::set<const WebContents*> opener_and_descendants; | 602 std::set<const WebContents*> opener_and_descendants; |
603 opener_and_descendants.insert(opener); | 603 opener_and_descendants.insert(opener); |
604 int last_index = kNoTab; | 604 int last_index = kNoTab; |
605 | 605 |
606 for (int i = start_index + 1; i < count(); ++i) { | 606 for (int i = start_index + 1; i < count(); ++i) { |
607 // Test opened by transitively, i.e. include tabs opened by tabs opened by | 607 // Test opened by transitively, i.e. include tabs opened by tabs opened by |
608 // opener, etc. Stop when we find the first non-descendant. | 608 // opener, etc. Stop when we find the first non-descendant. |
609 if (!opener_and_descendants.count(contents_data_[i]->opener())) | 609 if (!opener_and_descendants.count(contents_data_[i]->opener())) { |
| 610 // Skip over pinned tabs as new tabs are added after pinned tabs. |
| 611 if (contents_data_[i]->pinned()) |
| 612 continue; |
610 break; | 613 break; |
| 614 } |
611 opener_and_descendants.insert(contents_data_[i]->web_contents()); | 615 opener_and_descendants.insert(contents_data_[i]->web_contents()); |
612 last_index = i; | 616 last_index = i; |
613 } | 617 } |
614 return last_index; | 618 return last_index; |
615 } | 619 } |
616 | 620 |
617 void TabStripModel::TabNavigating(WebContents* contents, | 621 void TabStripModel::TabNavigating(WebContents* contents, |
618 ui::PageTransition transition) { | 622 ui::PageTransition transition) { |
619 if (ShouldForgetOpenersForTransition(transition)) { | 623 if (ShouldForgetOpenersForTransition(transition)) { |
620 // Don't forget the openers if this tab is a New Tab page opened at the | 624 // Don't forget the openers if this tab is a New Tab page opened at the |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 | 1442 |
1439 void TabStripModel::FixOpenersAndGroupsReferencing(int index) { | 1443 void TabStripModel::FixOpenersAndGroupsReferencing(int index) { |
1440 WebContents* old_contents = GetWebContentsAtImpl(index); | 1444 WebContents* old_contents = GetWebContentsAtImpl(index); |
1441 for (WebContentsData* data : contents_data_) { | 1445 for (WebContentsData* data : contents_data_) { |
1442 if (data->group() == old_contents) | 1446 if (data->group() == old_contents) |
1443 data->set_group(contents_data_[index]->group()); | 1447 data->set_group(contents_data_[index]->group()); |
1444 if (data->opener() == old_contents) | 1448 if (data->opener() == old_contents) |
1445 data->set_opener(contents_data_[index]->opener()); | 1449 data->set_opener(contents_data_[index]->opener()); |
1446 } | 1450 } |
1447 } | 1451 } |
OLD | NEW |