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/sessions/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 browser->SelectTabContentsAt(browser->tab_count() - 1, true); | 352 browser->SelectTabContentsAt(browser->tab_count() - 1, true); |
353 return; | 353 return; |
354 } | 354 } |
355 | 355 |
356 DCHECK(browser); | 356 DCHECK(browser); |
357 DCHECK(browser->tab_count()); | 357 DCHECK(browser->tab_count()); |
358 browser->SelectTabContentsAt( | 358 browser->SelectTabContentsAt( |
359 std::min(initial_tab_count + std::max(0, selected_session_index), | 359 std::min(initial_tab_count + std::max(0, selected_session_index), |
360 browser->tab_count() - 1), true); | 360 browser->tab_count() - 1), true); |
361 browser->window()->Show(); | 361 browser->window()->Show(); |
| 362 // Showing the browser focuses the location bar, let the tab decide where |
| 363 // it wants the focus to be. |
| 364 browser->GetSelectedTabContents()->SetInitialFocus(); |
362 } | 365 } |
363 | 366 |
364 void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { | 367 void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { |
365 for (size_t i = 0; i < urls.size(); ++i) { | 368 for (size_t i = 0; i < urls.size(); ++i) { |
366 browser->AddTabWithURL(urls[i], GURL(), PageTransition::START_PAGE, | 369 browser->AddTabWithURL(urls[i], GURL(), PageTransition::START_PAGE, |
367 (i == 0), NULL); | 370 (i == 0), NULL); |
368 } | 371 } |
369 } | 372 } |
370 | 373 |
371 // Invokes TabRestored on the SessionService for all tabs in browser after | 374 // Invokes TabRestored on the SessionService for all tabs in browser after |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 Restore(profile, browser, false, clobber_existing_window, | 447 Restore(profile, browser, false, clobber_existing_window, |
445 always_create_tabbed_browser, urls_to_open); | 448 always_create_tabbed_browser, urls_to_open); |
446 } | 449 } |
447 | 450 |
448 // static | 451 // static |
449 void SessionRestore::RestoreSessionSynchronously( | 452 void SessionRestore::RestoreSessionSynchronously( |
450 Profile* profile, | 453 Profile* profile, |
451 const std::vector<GURL>& urls_to_open) { | 454 const std::vector<GURL>& urls_to_open) { |
452 Restore(profile, NULL, true, false, true, urls_to_open); | 455 Restore(profile, NULL, true, false, true, urls_to_open); |
453 } | 456 } |
OLD | NEW |