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

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

Issue 2493573002: Make sure that the browser will always restore settings page instead of sign out page after user si… (Closed)
Patch Set: rebase from master 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_common_utils.h" 5 #include "chrome/browser/sessions/session_common_utils.h"
6 6
7 #include <algorithm>
8 #include <string>
9
7 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "components/sessions/core/session_types.h"
8 #include "url/gurl.h" 12 #include "url/gurl.h"
9 13
10 bool ShouldTrackURLForRestore(const GURL& url) { 14 bool ShouldTrackURLForRestore(const GURL& url) {
11 return url.is_valid() && 15 return url.is_valid() &&
12 !(url.SchemeIs(content::kChromeUIScheme) && 16 !(url.SchemeIs(content::kChromeUIScheme) &&
13 (url.host_piece() == chrome::kChromeUIQuitHost || 17 (url.host_piece() == chrome::kChromeUIQuitHost ||
14 url.host_piece() == chrome::kChromeUIRestartHost)); 18 url.host_piece() == chrome::kChromeUIRestartHost));
15 } 19 }
20
21 int GetNavigationIndexToSelect(const sessions::SessionTab& tab) {
22 DCHECK(!tab.navigations.empty());
23 const int selected_index =
24 std::max(0, std::min(tab.current_navigation_index,
25 static_cast<int>(tab.navigations.size() - 1)));
26
27 // After user sign out, Chrome may navigate to the setting page from the
28 // sign out page asynchronously. The browser may be closed before the
29 // navigation callback finished.
30 std::string setting_page_url = std::string(chrome::kChromeUISettingsURL);
31 std::string sign_out_page_url =
32 setting_page_url + std::string(chrome::kSignOutSubPage);
33 if (selected_index > 0 &&
34 tab.navigations[selected_index].virtual_url().spec() ==
35 sign_out_page_url &&
36 tab.navigations[selected_index - 1].virtual_url().spec() ==
37 setting_page_url) {
38 return selected_index - 1;
39 }
40
41 return selected_index;
42 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_common_utils.h ('k') | chrome/browser/sessions/session_common_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698