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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const url_canon::Replacements<char>& replacements) { 64 const url_canon::Replacements<char>& replacements) {
65 if (url == other) 65 if (url == other)
66 return true; 66 return true;
67 67
68 GURL url_replaced = url.ReplaceComponents(replacements); 68 GURL url_replaced = url.ReplaceComponents(replacements);
69 GURL other_replaced = other.ReplaceComponents(replacements); 69 GURL other_replaced = other.ReplaceComponents(replacements);
70 return url_replaced == other_replaced; 70 return url_replaced == other_replaced;
71 } 71 }
72 72
73 // Change some of the navigation parameters based on the particular URL. 73 // Change some of the navigation parameters based on the particular URL.
74 // Currently this applies to chrome://settings, the bookmark manager, 74 // Currently this applies to some chrome:// pages which we always want to open
75 // and chrome://extensions, which we always want to open in a normal 75 // in a normal (not incognito) window. Guest session is an exception.
James Hawkins 2011/11/17 02:23:53 s/normal (non incognito)/non-incognito/
James Hawkins 2011/11/17 02:23:53 While you're here, can you clarify the guest sessi
binji 2011/11/17 21:02:09 Done.
binji 2011/11/17 21:02:09 Done.
76 // (not incognito) window. Guest session is an exception.
77 // chrome://extensions is on the list because it redirects to 76 // chrome://extensions is on the list because it redirects to
78 // chrome://settings. 77 // chrome://settings.
79 // Returns true on success. Otherwise, if changing params leads the browser into 78 // Returns true on success. Otherwise, if changing params leads the browser into
80 // an erroneous state, returns false. 79 // an erroneous state, returns false.
81 bool AdjustNavigateParamsForURL(browser::NavigateParams* params) { 80 bool AdjustNavigateParamsForURL(browser::NavigateParams* params) {
82 if (!params->target_contents && 81 if (params->target_contents != NULL ||
binji 2011/11/17 01:23:51 I think it is clearer to early out here.
James Hawkins 2011/11/17 02:23:53 Always and forever.
83 browser::IsURLAllowedInIncognito(params->url)) { 82 browser::IsURLAllowedInIncognito(params->url))
84 Profile* profile = 83 return true;
85 params->browser ? params->browser->profile() : params->profile;
86 84
87 if ((profile->IsOffTheRecord() && !Profile::IsGuestSession()) || 85 Profile* profile =
88 params->disposition == OFF_THE_RECORD) { 86 params->browser ? params->browser->profile() : params->profile;
89 profile = profile->GetOriginalProfile();
90 87
91 // If incognito is forced, we punt. 88 if ((profile->IsOffTheRecord() && !Profile::IsGuestSession()) ||
92 PrefService* prefs = profile->GetPrefs(); 89 params->disposition == OFF_THE_RECORD) {
93 if (prefs && IncognitoModePrefs::GetAvailability(prefs) == 90 profile = profile->GetOriginalProfile();
94 IncognitoModePrefs::FORCED) {
95 return false;
96 }
97 91
98 params->disposition = SINGLETON_TAB; 92 // If incognito is forced, we punt.
99 params->profile = profile; 93 PrefService* prefs = profile->GetPrefs();
100 params->browser = Browser::GetOrCreateTabbedBrowser(profile); 94 if (prefs && IncognitoModePrefs::GetAvailability(prefs) ==
101 params->window_action = browser::NavigateParams::SHOW_WINDOW; 95 IncognitoModePrefs::FORCED) {
96 return false;
102 } 97 }
98
99 params->disposition = SINGLETON_TAB;
100 params->profile = profile;
101 params->browser = Browser::GetOrCreateTabbedBrowser(profile);
102 params->window_action = browser::NavigateParams::SHOW_WINDOW;
103 } 103 }
104
104 return true; 105 return true;
105 } 106 }
106 107
107 // Returns a Browser that can host the navigation or tab addition specified in 108 // Returns a Browser that can host the navigation or tab addition specified in
108 // |params|. This might just return the same Browser specified in |params|, or 109 // |params|. This might just return the same Browser specified in |params|, or
109 // some other if that Browser is deemed incompatible. 110 // some other if that Browser is deemed incompatible.
110 Browser* GetBrowserForDisposition(browser::NavigateParams* params) { 111 Browser* GetBrowserForDisposition(browser::NavigateParams* params) {
111 // If no source TabContents was specified, we use the selected one from the 112 // If no source TabContents was specified, we use the selected one from the
112 // target browser. This must happen first, before GetBrowserForDisposition() 113 // target browser. This must happen first, before GetBrowserForDisposition()
113 // has a chance to replace |params->browser| with another one. 114 // has a chance to replace |params->browser| with another one.
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 rewritten_url, replacements)) { 626 rewritten_url, replacements)) {
626 params->target_contents = tab; 627 params->target_contents = tab;
627 return tab_index; 628 return tab_index;
628 } 629 }
629 } 630 }
630 631
631 return -1; 632 return -1;
632 } 633 }
633 634
634 bool IsURLAllowedInIncognito(const GURL& url) { 635 bool IsURLAllowedInIncognito(const GURL& url) {
635 return url.scheme() == chrome::kChromeUIScheme && 636 // Most URLs are allowed in incognito; the following are exceptions.
637 return !(url.scheme() == chrome::kChromeUIScheme &&
binji 2011/11/17 01:23:51 Reversed the logic here because the name was incon
James Hawkins 2011/11/17 02:23:53 Don't you need to reverse the call sites too?
binji 2011/11/17 21:02:09 Good catch.
636 (url.host() == chrome::kChromeUISettingsHost || 638 (url.host() == chrome::kChromeUISettingsHost ||
637 url.host() == chrome::kChromeUIExtensionsHost || 639 url.host() == chrome::kChromeUIExtensionsHost ||
638 url.host() == chrome::kChromeUIBookmarksHost); 640 url.host() == chrome::kChromeUIBookmarksHost ||
641 url.host() == chrome::kChromeUISyncPromoHost));
639 } 642 }
640 643
641 } // namespace browser 644 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698