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

Unified Diff: chrome/browser/ui/browser_navigator.cc

Issue 8588013: Fix crash in SyncSetupWizard::IsVisible() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add browser test Created 9 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/ui/browser_navigator.cc
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc
index ad0a54163d3cd15e40b1e1e328da00627fd02dd4..25e8f77f6dfd0a3cc5b795cf2b43f615c2594c8f 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -71,36 +71,36 @@ bool CompareURLsWithReplacements(
}
// Change some of the navigation parameters based on the particular URL.
-// Currently this applies to chrome://settings, the bookmark manager,
-// and chrome://extensions, which we always want to open in a normal
-// (not incognito) window. Guest session is an exception.
-// chrome://extensions is on the list because it redirects to
-// chrome://settings.
+// Currently this applies to some chrome:// pages which we always want to open
+// in a non-incognito window. Note that even though a ChromeOS guest session is
+// technically an incognito window, these URLs are allowed.
// Returns true on success. Otherwise, if changing params leads the browser into
// an erroneous state, returns false.
bool AdjustNavigateParamsForURL(browser::NavigateParams* params) {
- if (!params->target_contents &&
- browser::IsURLAllowedInIncognito(params->url)) {
- Profile* profile =
- params->browser ? params->browser->profile() : params->profile;
-
- if ((profile->IsOffTheRecord() && !Profile::IsGuestSession()) ||
- params->disposition == OFF_THE_RECORD) {
- profile = profile->GetOriginalProfile();
-
- // If incognito is forced, we punt.
- PrefService* prefs = profile->GetPrefs();
- if (prefs && IncognitoModePrefs::GetAvailability(prefs) ==
- IncognitoModePrefs::FORCED) {
- return false;
- }
+ if (params->target_contents != NULL ||
+ browser::IsURLAllowedInIncognito(params->url) ||
+ Profile::IsGuestSession())
James Hawkins 2011/11/22 00:59:27 Multi-line logic requires braces on the if block.
+ return true;
+
+ Profile* profile =
+ params->browser ? params->browser->profile() : params->profile;
- params->disposition = SINGLETON_TAB;
- params->profile = profile;
- params->browser = Browser::GetOrCreateTabbedBrowser(profile);
- params->window_action = browser::NavigateParams::SHOW_WINDOW;
+ if (profile->IsOffTheRecord() || params->disposition == OFF_THE_RECORD) {
+ profile = profile->GetOriginalProfile();
+
+ // If incognito is forced, we punt.
+ PrefService* prefs = profile->GetPrefs();
+ if (prefs && IncognitoModePrefs::GetAvailability(prefs) ==
+ IncognitoModePrefs::FORCED) {
+ return false;
}
+
+ params->disposition = SINGLETON_TAB;
+ params->profile = profile;
+ params->browser = Browser::GetOrCreateTabbedBrowser(profile);
+ params->window_action = browser::NavigateParams::SHOW_WINDOW;
}
+
return true;
}
@@ -632,10 +632,15 @@ int GetIndexOfSingletonTab(browser::NavigateParams* params) {
}
bool IsURLAllowedInIncognito(const GURL& url) {
- return url.scheme() == chrome::kChromeUIScheme &&
+ // Most URLs are allowed in incognito; the following are exceptions.
+ // chrome://extensions is on the list because it redirects to
+ // chrome://settings.
+
+ return !(url.scheme() == chrome::kChromeUIScheme &&
(url.host() == chrome::kChromeUISettingsHost ||
url.host() == chrome::kChromeUIExtensionsHost ||
- url.host() == chrome::kChromeUIBookmarksHost);
+ url.host() == chrome::kChromeUIBookmarksHost ||
+ url.host() == chrome::kChromeUISyncPromoHost));
}
} // namespace browser

Powered by Google App Engine
This is Rietveld 408576698