| 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 "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
| 15 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
| 16 #include "chrome/browser/extensions/tab_helper.h" | 16 #include "chrome/browser/extensions/tab_helper.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 19 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 19 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 23 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_contents_observer.h" | 27 #include "content/public/browser/web_contents_observer.h" |
| 28 #include "content/public/browser/web_contents_view.h" | 28 #include "content/public/browser/web_contents_view.h" |
| 29 #include "ui/gfx/layout_util.h" |
| 29 | 30 |
| 30 using base::UserMetricsAction; | 31 using base::UserMetricsAction; |
| 31 using content::WebContents; | 32 using content::WebContents; |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 // Returns true if the specified transition is one of the types that cause the | 36 // Returns true if the specified transition is one of the types that cause the |
| 36 // opener relationships for the tab in which the transition occurred to be | 37 // opener relationships for the tab in which the transition occurred to be |
| 37 // forgotten. This is generally any navigation that isn't a link click (i.e. | 38 // forgotten. This is generally any navigation that isn't a link click (i.e. |
| 38 // any navigation that can be considered to be the start of a new task distinct | 39 // any navigation that can be considered to be the start of a new task distinct |
| (...skipping 791 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 gfx::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 |