| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 466 |
| 467 CloseAllTabs(); | 467 CloseAllTabs(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 /////////////////////////////////////////////////////////////////////////////// | 470 /////////////////////////////////////////////////////////////////////////////// |
| 471 // Browser, Tab adding/showing functions: | 471 // Browser, Tab adding/showing functions: |
| 472 | 472 |
| 473 TabContents* Browser::AddTabWithURL( | 473 TabContents* Browser::AddTabWithURL( |
| 474 const GURL& url, const GURL& referrer, PageTransition::Type transition, | 474 const GURL& url, const GURL& referrer, PageTransition::Type transition, |
| 475 bool foreground, SiteInstance* instance) { | 475 bool foreground, SiteInstance* instance) { |
| 476 if ((type_ & TYPE_APP) != 0 && tabstrip_model_.count() == 1) { | 476 TabContents* contents = NULL; |
| 477 NOTREACHED() << "Cannot add a tab in a mono tab application."; | 477 if (type_ == TYPE_NORMAL) { |
| 478 return NULL; | 478 GURL url_to_load = url; |
| 479 if (url_to_load.is_empty()) |
| 480 url_to_load = GetHomePage(); |
| 481 contents = CreateTabContentsForURL(url_to_load, referrer, profile_, |
| 482 transition, false, instance); |
| 483 tabstrip_model_.AddTabContents(contents, -1, transition, foreground); |
| 484 // By default, content believes it is not hidden. When adding contents |
| 485 // in the background, tell it that it's hidden. |
| 486 if (!foreground) |
| 487 contents->WasHidden(); |
| 488 } else { |
| 489 // We're in an app window or a popup window. Find an existing browser to |
| 490 // open this URL in, creating one if none exists. |
| 491 Browser* b = GetOrCreateTabbedBrowser(); |
| 492 contents = b->AddTabWithURL(url, referrer, transition, foreground, |
| 493 instance); |
| 494 b->window()->Show(); |
| 479 } | 495 } |
| 480 | |
| 481 GURL url_to_load = url; | |
| 482 if (url_to_load.is_empty()) | |
| 483 url_to_load = GetHomePage(); | |
| 484 TabContents* contents = | |
| 485 CreateTabContentsForURL(url_to_load, referrer, profile_, transition, | |
| 486 false, instance); | |
| 487 tabstrip_model_.AddTabContents(contents, -1, transition, foreground); | |
| 488 // By default, content believes it is not hidden. When adding contents | |
| 489 // in the background, tell it that it's hidden. | |
| 490 if (!foreground) | |
| 491 contents->WasHidden(); | |
| 492 return contents; | 496 return contents; |
| 493 } | 497 } |
| 494 | 498 |
| 495 TabContents* Browser::AddTabWithNavigationController( | 499 TabContents* Browser::AddTabWithNavigationController( |
| 496 NavigationController* ctrl, PageTransition::Type type) { | 500 NavigationController* ctrl, PageTransition::Type type) { |
| 497 TabContents* tc = ctrl->active_contents(); | 501 TabContents* tc = ctrl->active_contents(); |
| 498 tabstrip_model_.AddTabContents(tc, -1, type, true); | 502 tabstrip_model_.AddTabContents(tc, -1, type, true); |
| 499 return tc; | 503 return tc; |
| 500 } | 504 } |
| 501 | 505 |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 | 2513 |
| 2510 // We need to register the window position pref. | 2514 // We need to register the window position pref. |
| 2511 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2515 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2512 window_pref.append(L"_"); | 2516 window_pref.append(L"_"); |
| 2513 window_pref.append(app_name); | 2517 window_pref.append(app_name); |
| 2514 PrefService* prefs = g_browser_process->local_state(); | 2518 PrefService* prefs = g_browser_process->local_state(); |
| 2515 DCHECK(prefs); | 2519 DCHECK(prefs); |
| 2516 | 2520 |
| 2517 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2521 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2518 } | 2522 } |
| OLD | NEW |