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 |
| 11 #include "apps/ui/web_contents_sizer.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
14 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
15 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
16 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 19 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
19 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 20 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 // Ensure that the new WebContentsView begins at the same size as the | 831 // Ensure that the new WebContentsView begins at the same size as the |
831 // previous WebContentsView if it existed. Otherwise, the initial WebKit | 832 // previous WebContentsView if it existed. Otherwise, the initial WebKit |
832 // layout will be performed based on a width of 0 pixels, causing a | 833 // layout will be performed based on a width of 0 pixels, causing a |
833 // very long, narrow, inaccurate layout. Because some scripts on pages (as | 834 // very long, narrow, inaccurate layout. Because some scripts on pages (as |
834 // well as WebKit's anchor link location calculation) are run on the | 835 // well as WebKit's anchor link location calculation) are run on the |
835 // initial layout and not recalculated later, we need to ensure the first | 836 // initial layout and not recalculated later, we need to ensure the first |
836 // layout is performed with sane view dimensions even when we're opening a | 837 // layout is performed with sane view dimensions even when we're opening a |
837 // new background tab. | 838 // new background tab. |
838 if (WebContents* old_contents = GetActiveWebContents()) { | 839 if (WebContents* old_contents = GetActiveWebContents()) { |
839 if ((add_types & ADD_ACTIVE) == 0) { | 840 if ((add_types & ADD_ACTIVE) == 0) { |
840 contents->GetView()->SizeContents( | 841 apps::ResizeWebContents(contents, |
841 old_contents->GetView()->GetContainerSize()); | 842 old_contents->GetView()->GetContainerSize()); |
842 } | 843 } |
843 } | 844 } |
844 } | 845 } |
845 | 846 |
846 void TabStripModel::CloseSelectedTabs() { | 847 void TabStripModel::CloseSelectedTabs() { |
847 InternalCloseTabs(selection_model_.selected_indices(), | 848 InternalCloseTabs(selection_model_.selected_indices(), |
848 CLOSE_CREATE_HISTORICAL_TAB | CLOSE_USER_GESTURE); | 849 CLOSE_CREATE_HISTORICAL_TAB | CLOSE_USER_GESTURE); |
849 } | 850 } |
850 | 851 |
851 void TabStripModel::SelectNextTab() { | 852 void TabStripModel::SelectNextTab() { |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1398 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
1398 const WebContents* tab) { | 1399 const WebContents* tab) { |
1399 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); | 1400 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); |
1400 i != contents_data_.end(); ++i) { | 1401 i != contents_data_.end(); ++i) { |
1401 if ((*i)->group() == tab) | 1402 if ((*i)->group() == tab) |
1402 (*i)->set_group(NULL); | 1403 (*i)->set_group(NULL); |
1403 if ((*i)->opener() == tab) | 1404 if ((*i)->opener() == tab) |
1404 (*i)->set_opener(NULL); | 1405 (*i)->set_opener(NULL); |
1405 } | 1406 } |
1406 } | 1407 } |
OLD | NEW |