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 |
22 Profile::Profile() | 26 Profile::Profile() |
23 : restored_last_session_(false), | 27 : restored_last_session_(false), |
24 accessibility_pause_level_(0) { | 28 accessibility_pause_level_(0) { |
25 } | 29 } |
26 | 30 |
27 // static | 31 // static |
28 Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) { | 32 Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) { |
29 // This is safe; this is the only implementation of the browser context. | 33 // This is safe; this is the only implementation of the browser context. |
30 return static_cast<Profile*>(browser_context); | 34 return static_cast<Profile*>(browser_context); |
31 } | 35 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 PrefService::SYNCABLE_PREF); | 87 PrefService::SYNCABLE_PREF); |
84 prefs->RegisterStringPref(prefs::kApplicationLocaleBackup, | 88 prefs->RegisterStringPref(prefs::kApplicationLocaleBackup, |
85 "", | 89 "", |
86 PrefService::UNSYNCABLE_PREF); | 90 PrefService::UNSYNCABLE_PREF); |
87 prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted, | 91 prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted, |
88 "", | 92 "", |
89 PrefService::UNSYNCABLE_PREF); | 93 PrefService::UNSYNCABLE_PREF); |
90 #endif | 94 #endif |
91 } | 95 } |
92 | 96 |
| 97 // static |
| 98 net::URLRequestContextGetter* Profile::GetDefaultRequestContext() { |
| 99 return default_request_context_; |
| 100 } |
93 | 101 |
94 std::string Profile::GetDebugName() { | 102 std::string Profile::GetDebugName() { |
95 std::string name = GetPath().BaseName().MaybeAsASCII(); | 103 std::string name = GetPath().BaseName().MaybeAsASCII(); |
96 if (name.empty()) { | 104 if (name.empty()) { |
97 name = "UnknownProfile"; | 105 name = "UnknownProfile"; |
98 } | 106 } |
99 return name; | 107 return name; |
100 } | 108 } |
101 | 109 |
102 // static | 110 // static |
103 bool Profile::IsGuestSession() { | 111 bool Profile::IsGuestSession() { |
104 #if defined(OS_CHROMEOS) | 112 #if defined(OS_CHROMEOS) |
105 static bool is_guest_session = | 113 static bool is_guest_session = |
106 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); | 114 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); |
107 return is_guest_session; | 115 return is_guest_session; |
108 #else | 116 #else |
109 return false; | 117 return false; |
110 #endif | 118 #endif |
111 } | 119 } |
112 | 120 |
113 bool Profile::IsSyncAccessible() { | 121 bool Profile::IsSyncAccessible() { |
114 browser_sync::SyncPrefs prefs(GetPrefs()); | 122 browser_sync::SyncPrefs prefs(GetPrefs()); |
115 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); | 123 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); |
116 } | 124 } |
OLD | NEW |