| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/idle_timer.h" | 8 #include "base/idle_timer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 PageTransition::Type transition, bool defer_load, | 1391 PageTransition::Type transition, bool defer_load, |
| 1392 SiteInstance* instance) const { | 1392 SiteInstance* instance) const { |
| 1393 // Create an appropriate tab contents. | 1393 // Create an appropriate tab contents. |
| 1394 GURL real_url = url; | 1394 GURL real_url = url; |
| 1395 TabContentsType type = TabContents::TypeForURL(&real_url); | 1395 TabContentsType type = TabContents::TypeForURL(&real_url); |
| 1396 DCHECK(type != TAB_CONTENTS_UNKNOWN_TYPE); | 1396 DCHECK(type != TAB_CONTENTS_UNKNOWN_TYPE); |
| 1397 | 1397 |
| 1398 TabContents* contents = TabContents::CreateWithType(type, profile, instance); | 1398 TabContents* contents = TabContents::CreateWithType(type, profile, instance); |
| 1399 contents->SetupController(profile); | 1399 contents->SetupController(profile); |
| 1400 | 1400 |
| 1401 // Ensure that the new TabContentsView begins at the same size as the |
| 1402 // previous TabContentsView if it existed. Otherwise, the initial WebKit |
| 1403 // layout will be performed based on a width of 0 pixels, causing a |
| 1404 // very long, narrow, inaccurate layout. Because some scripts on pages (as |
| 1405 // well as WebKit's anchor link location calculation) are run on the initial |
| 1406 // layout and not recalculated later, we need to ensure the first layout is |
| 1407 // performed with sane view dimensions even when we're opening a new |
| 1408 // background tab. |
| 1409 if (TabContents* old_contents = tabstrip_model_.GetSelectedTabContents()) |
| 1410 contents->view()->SizeContents(old_contents->view()->GetContainerSize()); |
| 1411 |
| 1401 if (!defer_load) { | 1412 if (!defer_load) { |
| 1402 // Load the initial URL before adding the new tab contents to the tab strip | 1413 // Load the initial URL before adding the new tab contents to the tab strip |
| 1403 // so that the tab contents has navigation state. | 1414 // so that the tab contents has navigation state. |
| 1404 contents->controller()->LoadURL(url, referrer, transition); | 1415 contents->controller()->LoadURL(url, referrer, transition); |
| 1405 } | 1416 } |
| 1406 | 1417 |
| 1407 return contents; | 1418 return contents; |
| 1408 } | 1419 } |
| 1409 | 1420 |
| 1410 bool Browser::CanDuplicateContentsAt(int index) { | 1421 bool Browser::CanDuplicateContentsAt(int index) { |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 | 2649 |
| 2639 // We need to register the window position pref. | 2650 // We need to register the window position pref. |
| 2640 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2651 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2641 window_pref.append(L"_"); | 2652 window_pref.append(L"_"); |
| 2642 window_pref.append(app_name); | 2653 window_pref.append(app_name); |
| 2643 PrefService* prefs = g_browser_process->local_state(); | 2654 PrefService* prefs = g_browser_process->local_state(); |
| 2644 DCHECK(prefs); | 2655 DCHECK(prefs); |
| 2645 | 2656 |
| 2646 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2657 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2647 } | 2658 } |
| OLD | NEW |