blob: 958140b2ed46cb71dd280c632f94c3f789c92658 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#if defined(OS_WIN)
#include "base/win/metro.h"
#endif // OS_WIN
// static
bool IncognitoModePrefs::IntToAvailability(int in_value,
Availability* out_value) {
if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) {
*out_value = ENABLED;
return false;
}
*out_value = static_cast<Availability>(in_value);
return true;
}
// static
IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability(
const PrefService* pref_service) {
DCHECK(pref_service);
int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability);
Availability result = IncognitoModePrefs::ENABLED;
bool valid = IntToAvailability(pref_value, &result);
DCHECK(valid);
#if defined(OS_WIN)
// Disable incognito mode windows if parental controls are on. This is only
// for Windows Vista and above.
if (base::win::IsParentalControlActivityLoggingOn()) {
if (result == IncognitoModePrefs::FORCED)
LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on";
return IncognitoModePrefs::DISABLED;
}
#endif // OS_WIN
return result;
}
// static
void IncognitoModePrefs::SetAvailability(PrefService* prefs,
const Availability availability) {
prefs->SetInteger(prefs::kIncognitoModeAvailability, availability);
}
// static
void IncognitoModePrefs::RegisterUserPrefs(PrefServiceSyncable* pref_service) {
DCHECK(pref_service);
pref_service->RegisterIntegerPref(prefs::kIncognitoModeAvailability,
IncognitoModePrefs::ENABLED,
PrefServiceSyncable::UNSYNCABLE_PREF);
}
// static
bool IncognitoModePrefs::ShouldLaunchIncognito(
const CommandLine& command_line,
const PrefService* prefs) {
Availability incognito_avail = GetAvailability(prefs);
return incognito_avail != IncognitoModePrefs::DISABLED &&
(command_line.HasSwitch(switches::kIncognito) ||
incognito_avail == IncognitoModePrefs::FORCED);
}
|