| 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 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 return TAB_TEAROFF_ACTION | (tab_count() > 1 ? TAB_MOVE_ACTION : 0); | 1457 return TAB_TEAROFF_ACTION | (tab_count() > 1 ? TAB_MOVE_ACTION : 0); |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 TabContents* Browser::CreateTabContentsForURL( | 1460 TabContents* Browser::CreateTabContentsForURL( |
| 1461 const GURL& url, const GURL& referrer, Profile* profile, | 1461 const GURL& url, const GURL& referrer, Profile* profile, |
| 1462 PageTransition::Type transition, bool defer_load, | 1462 PageTransition::Type transition, bool defer_load, |
| 1463 SiteInstance* instance) const { | 1463 SiteInstance* instance) const { |
| 1464 TabContents* contents = new TabContents(profile, instance, | 1464 TabContents* contents = new TabContents(profile, instance, |
| 1465 MSG_ROUTING_NONE, NULL); | 1465 MSG_ROUTING_NONE, NULL); |
| 1466 | 1466 |
| 1467 // Ensure that the new TabContentsView begins at the same size as the |
| 1468 // previous TabContentsView if it existed. Otherwise, the initial WebKit |
| 1469 // layout will be performed based on a width of 0 pixels, causing a |
| 1470 // very long, narrow, inaccurate layout. Because some scripts on pages (as |
| 1471 // well as WebKit's anchor link location calculation) are run on the initial |
| 1472 // layout and not recalculated later, we need to ensure the first layout is |
| 1473 // performed with sane view dimensions even when we're opening a new |
| 1474 // background tab. |
| 1475 if (TabContents* old_contents = tabstrip_model_.GetSelectedTabContents()) |
| 1476 contents->view()->SizeContents(old_contents->view()->GetContainerSize()); |
| 1477 |
| 1467 if (!defer_load) { | 1478 if (!defer_load) { |
| 1468 // Load the initial URL before adding the new tab contents to the tab strip | 1479 // Load the initial URL before adding the new tab contents to the tab strip |
| 1469 // so that the tab contents has navigation state. | 1480 // so that the tab contents has navigation state. |
| 1470 contents->controller().LoadURL(url, referrer, transition); | 1481 contents->controller().LoadURL(url, referrer, transition); |
| 1471 } | 1482 } |
| 1472 | 1483 |
| 1473 return contents; | 1484 return contents; |
| 1474 } | 1485 } |
| 1475 | 1486 |
| 1476 bool Browser::CanDuplicateContentsAt(int index) { | 1487 bool Browser::CanDuplicateContentsAt(int index) { |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2776 /////////////////////////////////////////////////////////////////////////////// | 2787 /////////////////////////////////////////////////////////////////////////////// |
| 2777 // BrowserToolbarModel (private): | 2788 // BrowserToolbarModel (private): |
| 2778 | 2789 |
| 2779 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2790 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2780 // This |current_tab| can be NULL during the initialization of the | 2791 // This |current_tab| can be NULL during the initialization of the |
| 2781 // toolbar during window creation (i.e. before any tabs have been added | 2792 // toolbar during window creation (i.e. before any tabs have been added |
| 2782 // to the window). | 2793 // to the window). |
| 2783 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2794 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2784 return current_tab ? ¤t_tab->controller() : NULL; | 2795 return current_tab ? ¤t_tab->controller() : NULL; |
| 2785 } | 2796 } |
| OLD | NEW |