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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
// 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/profiles/profile.h"
#include <string>
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/off_the_record_profile_io_data.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_prefs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/resource/resource_bundle.h"
using base::Time;
using base::TimeDelta;
// A pointer to the request context for the default profile. See comments on
// Profile::GetDefaultRequestContext.
net::URLRequestContextGetter* Profile::default_request_context_;
namespace {
} // namespace
Profile::Profile()
: restored_last_session_(false),
accessibility_pause_level_(0) {
}
// static
Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) {
// This is safe; this is the only implementation of the browser context.
return static_cast<Profile*>(browser_context);
}
// static
Profile* Profile::FromWebUI(content::WebUI* web_ui) {
// TODO(dhollowa): Crash diagnosis http://crbug.com/97802
CHECK(web_ui);
CHECK(web_ui->GetWebContents());
CHECK(web_ui->GetWebContents()->GetBrowserContext());
return FromBrowserContext(web_ui->GetWebContents()->GetBrowserContext());
}
TestingProfile* Profile::AsTestingProfile() {
return NULL;
}
// static
const char* const Profile::kProfileKey = "__PROFILE__";
// static
void Profile::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled,
true,
PrefService::SYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly,
true,
PrefService::UNSYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled,
true,
PrefService::SYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kSafeBrowsingReportingEnabled,
false,
PrefService::UNSYNCABLE_PREF);
// TODO(erg): kSpeechRecognitionFilterProfanities should also be moved to
// speech_input_extension_manager.cc, but is more involved because of
// BrowserContext/Profile confusion because of ChromeSpeechInputPreferences.
prefs->RegisterBooleanPref(prefs::kSpeechRecognitionFilterProfanities,
true,
PrefService::UNSYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kDisableExtensions,
false,
PrefService::UNSYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kExtensionAlertsInitializedPref,
false, PrefService::UNSYNCABLE_PREF);
prefs->RegisterStringPref(prefs::kSelectFileLastDirectory,
"",
PrefService::UNSYNCABLE_PREF);
prefs->RegisterDoublePref(prefs::kDefaultZoomLevel,
0.0,
PrefService::UNSYNCABLE_PREF);
prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels,
PrefService::UNSYNCABLE_PREF);
prefs->RegisterStringPref(prefs::kDefaultApps,
"install",
PrefService::UNSYNCABLE_PREF);
#if defined(OS_CHROMEOS)
// TODO(dilmah): For OS_CHROMEOS we maintain kApplicationLocale in both
// local state and user's profile. For other platforms we maintain
// kApplicationLocale only in local state.
// In the future we may want to maintain kApplicationLocale
// in user's profile for other platforms as well.
prefs->RegisterStringPref(prefs::kApplicationLocale,
"",
PrefService::SYNCABLE_PREF);
prefs->RegisterStringPref(prefs::kApplicationLocaleBackup,
"",
PrefService::UNSYNCABLE_PREF);
prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted,
"",
PrefService::UNSYNCABLE_PREF);
#endif
}
// static
net::URLRequestContextGetter* Profile::GetDefaultRequestContext() {
return default_request_context_;
}
std::string Profile::GetDebugName() {
std::string name = GetPath().BaseName().MaybeAsASCII();
if (name.empty()) {
name = "UnknownProfile";
}
return name;
}
// static
bool Profile::IsGuestSession() {
#if defined(OS_CHROMEOS)
static bool is_guest_session =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession);
return is_guest_session;
#else
return false;
#endif
}
bool Profile::IsSyncAccessible() {
browser_sync::SyncPrefs prefs(GetPrefs());
return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged();
}
|