Prevent new Browser windows from violating the IncognitoModeAvailability policy.

This policy may disable incognito mode, or set it to enforced (i.e. disable
non-incognito windows). This change introduces a CHECK that prevents any code
paths from opening a disabled window type; such code paths should still be
fixed, but this CHECK prevents working around the policy.

BUG=244246

Review URL: https://chromiumcodereview.appspot.com/15670011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204011 0039d316-1c4b-4281-b951-d872f2087c98
parent b13ae482
......@@ -345,6 +345,11 @@ Browser::Browser(const CreateParams& params)
command_controller_(new chrome::BrowserCommandController(
this, g_browser_process->profile_manager())),
window_has_shown_(false) {
// If this causes a crash then a window is being opened using a profile type
// that is disallowed by policy. The crash prevents the disabled window type
// from opening at all, but the path that triggered it should be fixed.
CHECK(IncognitoModePrefs::CanOpenBrowser(profile_));
if (!app_name_.empty())
chrome::RegisterAppPrefs(app_name_, profile_);
tab_strip_model_->AddObserver(this);
......
......@@ -1353,8 +1353,9 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) {
// Create a new browser.
Browser* new_browser =
new Browser(Browser::CreateParams(browser()->profile(),
browser()->host_desktop_type()));
new Browser(Browser::CreateParams(
browser()->profile()->GetOffTheRecordProfile(),
browser()->host_desktop_type()));
CommandUpdater* new_command_updater =
new_browser->command_controller()->command_updater();
// It should have Bookmarks & Settings commands disabled by default.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment