OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #include "app/animation.h" | 7 #include "app/animation.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" |
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 } | 1785 } |
1786 | 1786 |
1787 if (disposition == NEW_POPUP) { | 1787 if (disposition == NEW_POPUP) { |
1788 BuildPopupWindow(source, new_contents, initial_pos); | 1788 BuildPopupWindow(source, new_contents, initial_pos); |
1789 } else if (disposition == NEW_WINDOW) { | 1789 } else if (disposition == NEW_WINDOW) { |
1790 Browser* browser = Browser::Create(profile_); | 1790 Browser* browser = Browser::Create(profile_); |
1791 browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, | 1791 browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, |
1792 initial_pos, user_gesture); | 1792 initial_pos, user_gesture); |
1793 browser->window()->Show(); | 1793 browser->window()->Show(); |
1794 } else if (disposition != SUPPRESS_OPEN) { | 1794 } else if (disposition != SUPPRESS_OPEN) { |
| 1795 // Ensure that the new TabContentsView begins at the same size as the |
| 1796 // previous TabContentsView if it existed. Otherwise, the initial WebKit |
| 1797 // layout will be performed based on a width of 0 pixels, causing a |
| 1798 // very long, narrow, inaccurate layout. Because some scripts on pages (as |
| 1799 // well as WebKit's anchor link location calculation) are run on the |
| 1800 // initial layout and not recalculated later, we need to ensure the first |
| 1801 // layout is performed with sane view dimensions even when we're opening a |
| 1802 // new background tab. |
| 1803 if (TabContents* old_contents = tabstrip_model_.GetSelectedTabContents()) { |
| 1804 new_contents->view()->SizeContents( |
| 1805 old_contents->view()->GetContainerSize()); |
| 1806 } |
1795 tabstrip_model_.AddTabContents(new_contents, -1, false, | 1807 tabstrip_model_.AddTabContents(new_contents, -1, false, |
1796 PageTransition::LINK, | 1808 PageTransition::LINK, |
1797 disposition == NEW_FOREGROUND_TAB); | 1809 disposition == NEW_FOREGROUND_TAB); |
1798 } | 1810 } |
1799 } | 1811 } |
1800 | 1812 |
1801 void Browser::ActivateContents(TabContents* contents) { | 1813 void Browser::ActivateContents(TabContents* contents) { |
1802 tabstrip_model_.SelectTabContentsAt( | 1814 tabstrip_model_.SelectTabContentsAt( |
1803 tabstrip_model_.GetIndexOfTabContents(contents), false); | 1815 tabstrip_model_.GetIndexOfTabContents(contents), false); |
1804 window_->Activate(); | 1816 window_->Activate(); |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2785 /////////////////////////////////////////////////////////////////////////////// | 2797 /////////////////////////////////////////////////////////////////////////////// |
2786 // BrowserToolbarModel (private): | 2798 // BrowserToolbarModel (private): |
2787 | 2799 |
2788 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2800 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
2789 // This |current_tab| can be NULL during the initialization of the | 2801 // This |current_tab| can be NULL during the initialization of the |
2790 // toolbar during window creation (i.e. before any tabs have been added | 2802 // toolbar during window creation (i.e. before any tabs have been added |
2791 // to the window). | 2803 // to the window). |
2792 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2804 TabContents* current_tab = browser_->GetSelectedTabContents(); |
2793 return current_tab ? ¤t_tab->controller() : NULL; | 2805 return current_tab ? ¤t_tab->controller() : NULL; |
2794 } | 2806 } |
OLD | NEW |