OLD | NEW |
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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/sync/profile_sync_service.h" | 11 #include "chrome/browser/sync/profile_sync_service.h" |
12 #include "chrome/browser/sync/sync_prefs.h" | 12 #include "chrome/browser/sync/sync_prefs.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
16 | 16 |
17 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #endif | 20 #endif |
21 | 21 |
22 // A pointer to the request context for the default profile. See comments on | |
23 // Profile::GetDefaultRequestContext. | |
24 net::URLRequestContextGetter* Profile::default_request_context_; | |
25 | |
26 Profile::Profile() | 22 Profile::Profile() |
27 : restored_last_session_(false), | 23 : restored_last_session_(false), |
28 accessibility_pause_level_(0) { | 24 accessibility_pause_level_(0) { |
29 } | 25 } |
30 | 26 |
31 // static | 27 // static |
32 Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) { | 28 Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) { |
33 // This is safe; this is the only implementation of the browser context. | 29 // This is safe; this is the only implementation of the browser context. |
34 return static_cast<Profile*>(browser_context); | 30 return static_cast<Profile*>(browser_context); |
35 } | 31 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 PrefService::SYNCABLE_PREF); | 83 PrefService::SYNCABLE_PREF); |
88 prefs->RegisterStringPref(prefs::kApplicationLocaleBackup, | 84 prefs->RegisterStringPref(prefs::kApplicationLocaleBackup, |
89 "", | 85 "", |
90 PrefService::UNSYNCABLE_PREF); | 86 PrefService::UNSYNCABLE_PREF); |
91 prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted, | 87 prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted, |
92 "", | 88 "", |
93 PrefService::UNSYNCABLE_PREF); | 89 PrefService::UNSYNCABLE_PREF); |
94 #endif | 90 #endif |
95 } | 91 } |
96 | 92 |
97 // static | |
98 net::URLRequestContextGetter* Profile::GetDefaultRequestContext() { | |
99 return default_request_context_; | |
100 } | |
101 | 93 |
102 std::string Profile::GetDebugName() { | 94 std::string Profile::GetDebugName() { |
103 std::string name = GetPath().BaseName().MaybeAsASCII(); | 95 std::string name = GetPath().BaseName().MaybeAsASCII(); |
104 if (name.empty()) { | 96 if (name.empty()) { |
105 name = "UnknownProfile"; | 97 name = "UnknownProfile"; |
106 } | 98 } |
107 return name; | 99 return name; |
108 } | 100 } |
109 | 101 |
110 // static | 102 // static |
111 bool Profile::IsGuestSession() { | 103 bool Profile::IsGuestSession() { |
112 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
113 static bool is_guest_session = | 105 static bool is_guest_session = |
114 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); | 106 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); |
115 return is_guest_session; | 107 return is_guest_session; |
116 #else | 108 #else |
117 return false; | 109 return false; |
118 #endif | 110 #endif |
119 } | 111 } |
120 | 112 |
121 bool Profile::IsSyncAccessible() { | 113 bool Profile::IsSyncAccessible() { |
122 browser_sync::SyncPrefs prefs(GetPrefs()); | 114 browser_sync::SyncPrefs prefs(GetPrefs()); |
123 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); | 115 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); |
124 } | 116 } |
OLD | NEW |