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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
// 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.
// This class gathers state related to a single user profile.
#ifndef CHROME_BROWSER_PROFILES_PROFILE_IMPL_H_
#define CHROME_BROWSER_PROFILES_PROFILE_IMPL_H_
#include <string>
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_change_registrar.h"
#include "base/timer/timer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_impl_io_data.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/host_zoom_map.h"
class NetPrefObserver;
class PrefService;
class PrefServiceSyncable;
class ShortcutsBackend;
class SSLConfigServiceManager;
class TrackedPreferenceValidationDelegate;
#if defined(OS_CHROMEOS)
namespace chromeos {
class KioskTest;
class LocaleChangeGuard;
class Preferences;
class SupervisedUserTestBase;
}
#endif
namespace base {
class SequencedTaskRunner;
}
namespace domain_reliability {
class DomainReliabilityMonitor;
}
namespace extensions {
class ExtensionSystem;
}
namespace policy {
class CloudPolicyManager;
class ProfilePolicyConnector;
class SchemaRegistryService;
}
namespace user_prefs {
class refRegistrySyncable;
}
// The default profile implementation.
class ProfileImpl : public Profile {
public:
// Value written to prefs when the exit type is EXIT_NORMAL. Public for tests.
static const char* const kPrefExitTypeNormal;
~ProfileImpl() override;
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
// content::BrowserContext implementation:
scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;
base::FilePath GetPath() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
net::URLRequestContextGetter* GetRequestContext() override;
net::URLRequestContextGetter* GetRequestContextForRenderProcess(
int renderer_child_id) override;
net::URLRequestContextGetter* GetMediaRequestContext() override;
net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
int renderer_child_id) override;
net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) override;
content::ResourceContext* GetResourceContext() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionManager* GetPermissionManager() override;
// Profile implementation:
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
// Note that this implementation returns the Google-services username, if any,
// not the Chrome user's display name.
std::string GetProfileUserName() const override;
ProfileType GetProfileType() const override;
bool IsOffTheRecord() const override;
Profile* GetOffTheRecordProfile() override;
void DestroyOffTheRecordProfile() override;
bool HasOffTheRecordProfile() override;
Profile* GetOriginalProfile() override;
bool IsSupervised() override;
bool IsChild() override;
bool IsLegacySupervised() override;
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
PrefService* GetPrefs() override;
const PrefService* GetPrefs() const override;
chrome::ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
PrefService* GetOffTheRecordPrefs() override;
net::URLRequestContextGetter* GetRequestContextForExtensions() override;
net::SSLConfigService* GetSSLConfigService() override;
HostContentSettingsMap* GetHostContentSettingsMap() override;
bool IsSameProfile(Profile* profile) override;
base::Time GetStartTime() const override;
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
base::FilePath last_selected_directory() override;
void set_last_selected_directory(const base::FilePath& path) override;
chrome_browser_net::Predictor* GetNetworkPredictor() override;
DevToolsNetworkController* GetDevToolsNetworkController() override;
void ClearNetworkingHistorySince(base::Time time,
const base::Closure& completion) override;
GURL GetHomePage() override;
bool WasCreatedByVersionOrLater(const std::string& version) override;
void SetExitType(ExitType exit_type) override;
ExitType GetLastSessionExitType() override;
#if defined(OS_CHROMEOS)
void ChangeAppLocale(const std::string& locale, AppLocaleChangedVia) override;
void OnLogin() override;
void InitChromeOSPreferences() override;
#endif // defined(OS_CHROMEOS)
PrefProxyConfigTracker* GetProxyConfigTracker() override;
private:
#if defined(OS_CHROMEOS)
friend class chromeos::KioskTest;
friend class chromeos::SupervisedUserTestBase;
#endif
friend class Profile;
FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest,
ProfilesLaunchedAfterCrash);
FRIEND_TEST_ALL_PREFIXES(ProfileBrowserTest, DISABLED_ProfileReadmeCreated);
FRIEND_TEST_ALL_PREFIXES(ProfileBrowserTest,
ProfileDeletedBeforeReadmeCreated);
ProfileImpl(const base::FilePath& path,
Delegate* delegate,
CreateMode create_mode,
base::SequencedTaskRunner* sequenced_task_runner);
// Does final initialization. Should be called after prefs were loaded.
void DoFinalInit();
// Switch locale (when possible) and proceed to OnLocaleReady().
void OnPrefsLoaded(CreateMode create_mode, bool success);
// Does final prefs initialization and calls Init().
void OnLocaleReady();
#if defined(ENABLE_SESSION_SERVICE)
void StopCreateSessionServiceTimer();
void EnsureSessionServiceCreated();
#endif
void EnsureRequestContextCreated() {
GetRequestContext();
}
// Updates the ProfileInfoCache with data from this profile.
void UpdateProfileSupervisedUserIdCache();
void UpdateProfileNameCache();
void UpdateProfileAvatarCache();
void UpdateProfileIsEphemeralCache();
void GetCacheParameters(bool is_media_context,
base::FilePath* cache_path,
int* max_size);
PrefProxyConfigTracker* CreateProxyConfigTracker();
scoped_ptr<domain_reliability::DomainReliabilityMonitor>
CreateDomainReliabilityMonitor(PrefService* local_state);
PrefChangeRegistrar pref_change_registrar_;
base::FilePath path_;
base::FilePath base_cache_path_;
// !!! BIG HONKING WARNING !!!
// The order of the members below is important. Do not change it unless
// you know what you're doing. Also, if adding a new member here make sure
// that the declaration occurs AFTER things it depends on as destruction
// happens in reverse order of declaration.
// TODO(mnissler, joaodasilva): The |profile_policy_connector_| provides the
// PolicyService that the |prefs_| depend on, and must outlive |prefs_|.
// This can be removed once |prefs_| becomes a KeyedService too.
// |profile_policy_connector_| in turn depends on |cloud_policy_manager_|,
// which depends on |schema_registry_service_|.
#if defined(ENABLE_CONFIGURATION_POLICY)
scoped_ptr<policy::SchemaRegistryService> schema_registry_service_;
scoped_ptr<policy::CloudPolicyManager> cloud_policy_manager_;
#endif
scoped_ptr<policy::ProfilePolicyConnector> profile_policy_connector_;
// Keep |pref_validation_delegate_| above |prefs_| so that the former outlives
// the latter.
scoped_ptr<TrackedPreferenceValidationDelegate> pref_validation_delegate_;
// Keep |prefs_| on top for destruction order because |extension_prefs_|,
// |net_pref_observer_|, |io_data_| and others store pointers to |prefs_| and
// shall be destructed first.
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_;
scoped_ptr<PrefServiceSyncable> prefs_;
scoped_ptr<PrefServiceSyncable> otr_prefs_;
ProfileImplIOData::Handle io_data_;
#if defined(ENABLE_EXTENSIONS)
scoped_refptr<ExtensionSpecialStoragePolicy>
extension_special_storage_policy_;
#endif
scoped_ptr<NetPrefObserver> net_pref_observer_;
scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
scoped_refptr<ShortcutsBackend> shortcuts_backend_;
// Exit type the last time the profile was opened. This is set only once from
// prefs.
ExitType last_session_exit_type_;
#if defined(ENABLE_SESSION_SERVICE)
base::OneShotTimer<ProfileImpl> create_session_service_timer_;
#endif
scoped_ptr<Profile> off_the_record_profile_;
// See GetStartTime for details.
base::Time start_time_;
#if defined(OS_CHROMEOS)
scoped_ptr<chromeos::Preferences> chromeos_preferences_;
scoped_ptr<chromeos::LocaleChangeGuard> locale_change_guard_;
#endif
scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
// STOP!!!! DO NOT ADD ANY MORE ITEMS HERE!!!!
//
// Instead, make your Service/Manager/whatever object you're hanging off the
// Profile use our new BrowserContextKeyedServiceFactory system instead.
// You can find the design document here:
//
// https://sites.google.com/a/chromium.org/dev/developers/design-documents/profile-architecture
//
// and you can read the raw headers here:
//
// components/keyed_service/content/browser_context_dependency_manager.*
// components/keyed_service/core/keyed_service.h
// components/keyed_service/content/browser_context_keyed_service_factory.*
Profile::Delegate* delegate_;
chrome_browser_net::Predictor* predictor_;
DISALLOW_COPY_AND_ASSIGN(ProfileImpl);
};
#endif // CHROME_BROWSER_PROFILES_PROFILE_IMPL_H_
|