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_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/deferred_sequenced_task_runner.h" | 11 #include "base/deferred_sequenced_task_runner.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/bookmarks/bookmark_model.h" | 20 #include "chrome/browser/bookmarks/bookmark_model.h" |
21 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 21 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/content_settings/host_content_settings_map.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 24 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
24 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 25 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
25 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | 26 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" |
26 #include "chrome/browser/profiles/profile_destroyer.h" | 27 #include "chrome/browser/profiles/profile_destroyer.h" |
27 #include "chrome/browser/profiles/profile_info_cache.h" | 28 #include "chrome/browser/profiles/profile_info_cache.h" |
28 #include "chrome/browser/profiles/profile_metrics.h" | 29 #include "chrome/browser/profiles/profile_metrics.h" |
29 #include "chrome/browser/profiles/startup_task_runner_service.h" | 30 #include "chrome/browser/profiles/startup_task_runner_service.h" |
30 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 31 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
31 #include "chrome/browser/sync/profile_sync_service.h" | 32 #include "chrome/browser/sync/profile_sync_service.h" |
32 #include "chrome/browser/sync/profile_sync_service_factory.h" | 33 #include "chrome/browser/sync/profile_sync_service_factory.h" |
33 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return profile; | 266 return profile; |
266 } | 267 } |
267 | 268 |
268 // static | 269 // static |
269 Profile* ProfileManager::GetLastUsedProfile() { | 270 Profile* ProfileManager::GetLastUsedProfile() { |
270 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 271 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
271 return profile_manager->GetLastUsedProfile(profile_manager->user_data_dir_); | 272 return profile_manager->GetLastUsedProfile(profile_manager->user_data_dir_); |
272 } | 273 } |
273 | 274 |
274 // static | 275 // static |
| 276 Profile* ProfileManager::GetLastUsedProfileAllowedByPolicy() { |
| 277 Profile* profile = GetLastUsedProfile(); |
| 278 if (IncognitoModePrefs::GetAvailability(profile->GetPrefs()) == |
| 279 IncognitoModePrefs::FORCED) { |
| 280 return profile->GetOffTheRecordProfile(); |
| 281 } |
| 282 return profile; |
| 283 } |
| 284 |
| 285 // static |
275 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles() { | 286 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles() { |
276 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 287 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
277 return profile_manager->GetLastOpenedProfiles( | 288 return profile_manager->GetLastOpenedProfiles( |
278 profile_manager->user_data_dir_); | 289 profile_manager->user_data_dir_); |
279 } | 290 } |
280 | 291 |
281 ProfileManager::ProfileManager(const base::FilePath& user_data_dir) | 292 ProfileManager::ProfileManager(const base::FilePath& user_data_dir) |
282 : user_data_dir_(user_data_dir), | 293 : user_data_dir_(user_data_dir), |
283 logged_in_(false), | 294 logged_in_(false), |
284 will_import_(false), | 295 will_import_(false), |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 ProfileManager::ProfileInfo::ProfileInfo( | 1181 ProfileManager::ProfileInfo::ProfileInfo( |
1171 Profile* profile, | 1182 Profile* profile, |
1172 bool created) | 1183 bool created) |
1173 : profile(profile), | 1184 : profile(profile), |
1174 created(created) { | 1185 created(created) { |
1175 } | 1186 } |
1176 | 1187 |
1177 ProfileManager::ProfileInfo::~ProfileInfo() { | 1188 ProfileManager::ProfileInfo::~ProfileInfo() { |
1178 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1189 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1179 } | 1190 } |
OLD | NEW |