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

Side by Side Diff: chrome/browser/prefs/incognito_mode_prefs.cc

Issue 15670011: Prevent new Browser windows from violating the IncognitoModeAvailability policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests Created 7 years, 6 months 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
« no previous file with comments | « chrome/browser/prefs/incognito_mode_prefs.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/incognito_mode_prefs.h" 5 #include "chrome/browser/prefs/incognito_mode_prefs.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
12 #include "components/user_prefs/pref_registry_syncable.h" 13 #include "components/user_prefs/pref_registry_syncable.h"
13 14
14 #if defined(OS_WIN) 15 #if defined(OS_WIN)
15 #include "base/win/metro.h" 16 #include "base/win/metro.h"
16 #endif // OS_WIN 17 #endif // OS_WIN
17 18
18 // static 19 // static
19 bool IncognitoModePrefs::IntToAvailability(int in_value, 20 bool IncognitoModePrefs::IntToAvailability(int in_value,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 // static 65 // static
65 bool IncognitoModePrefs::ShouldLaunchIncognito( 66 bool IncognitoModePrefs::ShouldLaunchIncognito(
66 const CommandLine& command_line, 67 const CommandLine& command_line,
67 const PrefService* prefs) { 68 const PrefService* prefs) {
68 Availability incognito_avail = GetAvailability(prefs); 69 Availability incognito_avail = GetAvailability(prefs);
69 return incognito_avail != IncognitoModePrefs::DISABLED && 70 return incognito_avail != IncognitoModePrefs::DISABLED &&
70 (command_line.HasSwitch(switches::kIncognito) || 71 (command_line.HasSwitch(switches::kIncognito) ||
71 incognito_avail == IncognitoModePrefs::FORCED); 72 incognito_avail == IncognitoModePrefs::FORCED);
72 } 73 }
74
75 // static
76 bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) {
77 // If this causes a crash in Browser then a window is being opened using a
78 // profile type that is disallowed by policy. The crash prevents the
79 // "forbidden" window type from opening at all, but the path that triggered
80 // it should be fixed.
Mattias Nissler (ping if slow) 2013/05/29 11:33:08 Shouldn't this comment go with the CHECK()?
Joao da Silva 2013/05/29 11:40:40 Done.
81 switch (GetAvailability(profile->GetPrefs())) {
82 case IncognitoModePrefs::ENABLED:
83 return true;
84 case IncognitoModePrefs::DISABLED:
85 return !profile->IsOffTheRecord();
86 case IncognitoModePrefs::FORCED:
87 return profile->IsOffTheRecord();
88 case IncognitoModePrefs::AVAILABILITY_NUM_TYPES:
89 NOTREACHED();
90 }
91 NOTREACHED();
92 return false;
93 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/incognito_mode_prefs.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698