| 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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/views/tabs/tab_strip.h" |
| 6 | 6 |
| 7 #include "base/gfx/size.h" | 7 #include "base/gfx/size.h" |
| 8 #include "chrome/browser/metrics/user_metrics.h" | 8 #include "chrome/browser/metrics/user_metrics.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 799 |
| 800 // Otherwise we need to make a new Tab. | 800 // Otherwise we need to make a new Tab. |
| 801 if (!tab) | 801 if (!tab) |
| 802 tab = new Tab(this); | 802 tab = new Tab(this); |
| 803 | 803 |
| 804 // Only insert if we're not already in the list. | 804 // Only insert if we're not already in the list. |
| 805 if (!contains_tab) { | 805 if (!contains_tab) { |
| 806 if (index == TabStripModel::kNoTab) { | 806 if (index == TabStripModel::kNoTab) { |
| 807 TabData d = { tab, gfx::Rect() }; | 807 TabData d = { tab, gfx::Rect() }; |
| 808 tab_data_.push_back(d); | 808 tab_data_.push_back(d); |
| 809 tab->UpdateData(contents); | 809 tab->UpdateData(contents, false); |
| 810 } else { | 810 } else { |
| 811 TabData d = { tab, gfx::Rect() }; | 811 TabData d = { tab, gfx::Rect() }; |
| 812 tab_data_.insert(tab_data_.begin() + index, d); | 812 tab_data_.insert(tab_data_.begin() + index, d); |
| 813 tab->UpdateData(contents); | 813 tab->UpdateData(contents, false); |
| 814 } | 814 } |
| 815 } | 815 } |
| 816 | 816 |
| 817 // We only add the tab to the child list if it's not already - an invisible | 817 // We only add the tab to the child list if it's not already - an invisible |
| 818 // tab maintained by the DraggedTabController will already be parented. | 818 // tab maintained by the DraggedTabController will already be parented. |
| 819 if (!tab->GetParent()) | 819 if (!tab->GetParent()) |
| 820 AddChildView(tab); | 820 AddChildView(tab); |
| 821 | 821 |
| 822 // Don't animate the first tab, it looks weird, and don't animate anything | 822 // Don't animate the first tab, it looks weird, and don't animate anything |
| 823 // if the containing window isn't visible yet. | 823 // if the containing window isn't visible yet. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index) { | 860 void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index) { |
| 861 Tab* tab = GetTabAt(from_index); | 861 Tab* tab = GetTabAt(from_index); |
| 862 Tab* other_tab = GetTabAt(to_index); | 862 Tab* other_tab = GetTabAt(to_index); |
| 863 tab_data_.erase(tab_data_.begin() + from_index); | 863 tab_data_.erase(tab_data_.begin() + from_index); |
| 864 TabData data = {tab, gfx::Rect()}; | 864 TabData data = {tab, gfx::Rect()}; |
| 865 tab_data_.insert(tab_data_.begin() + to_index, data); | 865 tab_data_.insert(tab_data_.begin() + to_index, data); |
| 866 GenerateIdealBounds(); | 866 GenerateIdealBounds(); |
| 867 StartMoveTabAnimation(from_index, to_index); | 867 StartMoveTabAnimation(from_index, to_index); |
| 868 } | 868 } |
| 869 | 869 |
| 870 void TabStrip::TabChangedAt(TabContents* contents, int index) { | 870 void TabStrip::TabChangedAt(TabContents* contents, int index, |
| 871 bool loading_only) { |
| 871 // Index is in terms of the model. Need to make sure we adjust that index in | 872 // Index is in terms of the model. Need to make sure we adjust that index in |
| 872 // case we have an animation going. | 873 // case we have an animation going. |
| 873 Tab* tab = GetTabAtAdjustForAnimation(index); | 874 Tab* tab = GetTabAtAdjustForAnimation(index); |
| 874 tab->UpdateData(contents); | 875 tab->UpdateData(contents, loading_only); |
| 875 tab->UpdateFromModel(); | 876 tab->UpdateFromModel(); |
| 876 } | 877 } |
| 877 | 878 |
| 878 /////////////////////////////////////////////////////////////////////////////// | 879 /////////////////////////////////////////////////////////////////////////////// |
| 879 // TabStrip, Tab::Delegate implementation: | 880 // TabStrip, Tab::Delegate implementation: |
| 880 | 881 |
| 881 bool TabStrip::IsTabSelected(const Tab* tab) const { | 882 bool TabStrip::IsTabSelected(const Tab* tab) const { |
| 882 if (tab->closing()) | 883 if (tab->closing()) |
| 883 return false; | 884 return false; |
| 884 | 885 |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 // If the TabContents being detached was removed as a result of a drag | 1528 // If the TabContents being detached was removed as a result of a drag |
| 1528 // gesture from its corresponding Tab, we don't want to remove the Tab from | 1529 // gesture from its corresponding Tab, we don't want to remove the Tab from |
| 1529 // the child list, because if we do so it'll stop receiving events and the | 1530 // the child list, because if we do so it'll stop receiving events and the |
| 1530 // drag will stall. So we only remove if a drag isn't active, or the Tab | 1531 // drag will stall. So we only remove if a drag isn't active, or the Tab |
| 1531 // was for some other TabContents. | 1532 // was for some other TabContents. |
| 1532 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { | 1533 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { |
| 1533 removed->GetParent()->RemoveChildView(removed); | 1534 removed->GetParent()->RemoveChildView(removed); |
| 1534 delete removed; | 1535 delete removed; |
| 1535 } | 1536 } |
| 1536 } | 1537 } |
| OLD | NEW |