Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: chrome/browser/sessions/session_restore.cc

Issue 2714483003: cros: Fix restoring session windows after crash inconsistent minimized window counts (Closed)
Patch Set: SetInitialFocus when active Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 Browser* browser = nullptr; 403 Browser* browser = nullptr;
404 if (!has_tabbed_browser && 404 if (!has_tabbed_browser &&
405 (*i)->type == sessions::SessionWindow::TYPE_TABBED) 405 (*i)->type == sessions::SessionWindow::TYPE_TABBED)
406 has_tabbed_browser = true; 406 has_tabbed_browser = true;
407 if (i == windows->begin() && 407 if (i == windows->begin() &&
408 (*i)->type == sessions::SessionWindow::TYPE_TABBED && browser_ && 408 (*i)->type == sessions::SessionWindow::TYPE_TABBED && browser_ &&
409 browser_->is_type_tabbed() && 409 browser_->is_type_tabbed() &&
410 !browser_->profile()->IsOffTheRecord()) { 410 !browser_->profile()->IsOffTheRecord()) {
411 // The first set of tabs is added to the existing browser. 411 // The first set of tabs is added to the existing browser.
412 browser = browser_; 412 browser = browser_;
413
414 // If the existing browser is not nullptr and tabbed, the tabs from the
415 // session window with |active_window_id| should be restored to this
416 // existing browser. Therefore, the existing browser is the
417 // |browser_to_activate|.
418 for (auto j = windows->begin(); j != windows->end(); ++j) {
sky 2017/03/07 01:05:36 It's confusing to have this logic here. Could you
Qiang(Joe) Xu 2017/03/07 01:19:31 Done.
419 if ((*j)->window_id.id() == active_window_id) {
420 std::iter_swap(i, j);
421 break;
422 }
423 }
413 } else { 424 } else {
414 #if defined(OS_CHROMEOS) 425 #if defined(OS_CHROMEOS)
415 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( 426 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker(
416 "SessionRestore-CreateRestoredBrowser-Start", false); 427 "SessionRestore-CreateRestoredBrowser-Start", false);
417 #endif 428 #endif
418 // Show the first window if none are visible. 429 // Show the first window if none are visible.
419 ui::WindowShowState show_state = (*i)->show_state; 430 ui::WindowShowState show_state = (*i)->show_state;
420 if (!has_visible_browser) { 431 if (!has_visible_browser) {
421 show_state = ui::SHOW_STATE_NORMAL; 432 show_state = ui::SHOW_STATE_NORMAL;
422 has_visible_browser = true; 433 has_visible_browser = true;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 browser->tab_strip_model()->ActivateTabAt(selected_tab_index, true); 660 browser->tab_strip_model()->ActivateTabAt(selected_tab_index, true);
650 661
651 if (browser_ == browser) 662 if (browser_ == browser)
652 return; 663 return;
653 664
654 browser->window()->Show(); 665 browser->window()->Show();
655 browser->set_is_session_restore(false); 666 browser->set_is_session_restore(false);
656 667
657 // TODO(jcampan): http://crbug.com/8123 we should not need to set the 668 // TODO(jcampan): http://crbug.com/8123 we should not need to set the
658 // initial focus explicitly. 669 // initial focus explicitly.
659 browser->tab_strip_model()->GetActiveWebContents()->SetInitialFocus(); 670 if (browser->window()->IsActive())
671 browser->tab_strip_model()->GetActiveWebContents()->SetInitialFocus();
660 } 672 }
661 673
662 // Appends the urls in |urls| to |browser|. 674 // Appends the urls in |urls| to |browser|.
663 void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { 675 void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) {
664 for (size_t i = 0; i < urls.size(); ++i) { 676 for (size_t i = 0; i < urls.size(); ++i) {
665 int add_types = TabStripModel::ADD_FORCE_INDEX; 677 int add_types = TabStripModel::ADD_FORCE_INDEX;
666 if (i == 0) 678 if (i == 0)
667 add_types |= TabStripModel::ADD_ACTIVE; 679 add_types |= TabStripModel::ADD_ACTIVE;
668 chrome::NavigateParams params(browser, urls[i], 680 chrome::NavigateParams params(browser, urls[i],
669 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); 681 ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 // static 856 // static
845 SessionRestore::CallbackSubscription 857 SessionRestore::CallbackSubscription
846 SessionRestore::RegisterOnSessionRestoredCallback( 858 SessionRestore::RegisterOnSessionRestoredCallback(
847 const base::Callback<void(int)>& callback) { 859 const base::Callback<void(int)>& callback) {
848 return on_session_restored_callbacks()->Add(callback); 860 return on_session_restored_callbacks()->Add(callback);
849 } 861 }
850 862
851 // static 863 // static
852 base::CallbackList<void(int)>* 864 base::CallbackList<void(int)>*
853 SessionRestore::on_session_restored_callbacks_ = nullptr; 865 SessionRestore::on_session_restored_callbacks_ = nullptr;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698