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

Unified Diff: chrome/browser/sessions/session_restore.cc

Issue 2493573002: Make sure that the browser will always restore settings page instead of sign out page after user si… (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/session_restore.cc
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 87a44c4fb57615b643b7c68324c40ebcf61fa76f..bac02f29e030e0ca785cfe4b2a5e977032576c5f 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -575,6 +575,29 @@ class SessionRestoreImpl : public content::NotificationObserver {
}
}
+ int GetSelectedIndex(const sessions::SessionTab& tab) {
sky 2016/11/09 22:24:04 I have a mild preference for moving this to Sessio
sky 2016/11/09 22:24:04 This only effects session restore, what about tab
zmin 2016/11/10 22:36:07 I want to scope the affect of this change as littl
zmin 2016/11/10 22:36:07 OnGotSessionCommands is a simple function. Moving
+ int selected_index = tab.current_navigation_index;
+ selected_index = std::max(
+ 0,
+ std::min(selected_index, static_cast<int>(tab.navigations.size() - 1)));
+
+ // After user sign out, Chrome may navigate to the setting page from the
+ // sign out page asynchronously. The browser may be closed before the
+ // navigation callback finished.
+ std::string setting_page_url = std::string(chrome::kChromeUISettingsURL);
+ std::string sign_out_page_url =
+ setting_page_url + std::string(chrome::kSignOutSubPage);
sky 2016/11/09 22:24:04 Is there a reason you care about this case, and sa
zmin 2016/11/10 22:36:07 There're some edge cases I'm thinking about. For e
+ if (selected_index > 0 &&
+ tab.navigations.at(selected_index).virtual_url().spec() ==
sky 2016/11/09 22:24:04 at() -> [] (same comment below).
zmin 2016/11/10 22:36:07 Done.
+ sign_out_page_url &&
+ tab.navigations.at(selected_index - 1).virtual_url().spec() ==
+ setting_page_url) {
+ selected_index -= 1;
+ }
+
+ return selected_index;
+ }
+
// |tab_index| is ignored for pinned tabs which will always be pushed behind
// the last existing pinned tab.
// |tab_loader_| will schedule this tab for loading if |is_selected_tab| is
@@ -588,10 +611,7 @@ class SessionRestoreImpl : public content::NotificationObserver {
// See crbug.com/154129.
if (tab.navigations.empty())
return nullptr;
- int selected_index = tab.current_navigation_index;
- selected_index = std::max(
- 0,
- std::min(selected_index, static_cast<int>(tab.navigations.size() - 1)));
+ int selected_index = GetSelectedIndex(tab);
RecordAppLaunchForTab(browser, tab, selected_index);

Powered by Google App Engine
This is Rietveld 408576698