Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 11968034: Enable profile switching for standalone App Launcher via the Settings App. (Closed) Base URL: git://nomatter.syd/chromium/src.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 5 #include <set>
6 6
7 #include "chrome/browser/profiles/profile_manager.h" 7 #include "chrome/browser/profiles/profile_manager.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 DCHECK(local_state); 316 DCHECK(local_state);
317 317
318 if (local_state->HasPrefPath(prefs::kProfileLastUsed)) 318 if (local_state->HasPrefPath(prefs::kProfileLastUsed))
319 last_profile_used = local_state->GetString(prefs::kProfileLastUsed); 319 last_profile_used = local_state->GetString(prefs::kProfileLastUsed);
320 last_used_profile_dir = last_profile_used.empty() ? 320 last_used_profile_dir = last_profile_used.empty() ?
321 last_used_profile_dir.AppendASCII(chrome::kInitialProfile) : 321 last_used_profile_dir.AppendASCII(chrome::kInitialProfile) :
322 last_used_profile_dir.AppendASCII(last_profile_used); 322 last_used_profile_dir.AppendASCII(last_profile_used);
323 return GetProfile(last_used_profile_dir); 323 return GetProfile(last_used_profile_dir);
324 } 324 }
325 325
326 Profile* ProfileManager::GetAppListProfile(const FilePath& user_data_dir) {
327 FilePath app_list_profile_dir(user_data_dir);
328 std::string app_list_profile;
329 PrefService* local_state = g_browser_process->local_state();
330 DCHECK(local_state);
331
332 if (local_state->HasPrefPath(prefs::kAppListProfile))
333 app_list_profile = local_state->GetString(prefs::kAppListProfile);
334 app_list_profile_dir = app_list_profile.empty() ?
335 app_list_profile_dir.AppendASCII(chrome::kInitialProfile) :
tapted 2013/01/17 04:23:31 Should this (as an extra step) first check prefs::
koz (OOO until 15th September) 2013/01/18 05:37:33 That's a good idea. Done.
336 app_list_profile_dir.AppendASCII(app_list_profile);
337 return GetProfile(app_list_profile_dir);
338 }
339
326 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles( 340 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles(
327 const FilePath& user_data_dir) { 341 const FilePath& user_data_dir) {
328 PrefService* local_state = g_browser_process->local_state(); 342 PrefService* local_state = g_browser_process->local_state();
329 DCHECK(local_state); 343 DCHECK(local_state);
330 344
331 std::vector<Profile*> to_return; 345 std::vector<Profile*> to_return;
332 if (local_state->HasPrefPath(prefs::kProfilesLastActive)) { 346 if (local_state->HasPrefPath(prefs::kProfilesLastActive)) {
333 const ListValue* profile_list = 347 const ListValue* profile_list =
334 local_state->GetList(prefs::kProfilesLastActive); 348 local_state->GetList(prefs::kProfilesLastActive);
335 if (profile_list) { 349 if (profile_list) {
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 base::Bind(&OnOpenWindowForNewProfile, 847 base::Bind(&OnOpenWindowForNewProfile,
834 desktop_type, 848 desktop_type,
835 callback), 849 callback),
836 name, 850 name,
837 icon_url, 851 icon_url,
838 is_managed); 852 is_managed);
839 } 853 }
840 854
841 // static 855 // static
842 void ProfileManager::RegisterPrefs(PrefServiceSimple* prefs) { 856 void ProfileManager::RegisterPrefs(PrefServiceSimple* prefs) {
857 prefs->RegisterStringPref(prefs::kAppListProfile, "");
843 prefs->RegisterStringPref(prefs::kProfileLastUsed, ""); 858 prefs->RegisterStringPref(prefs::kProfileLastUsed, "");
844 prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1); 859 prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
845 prefs->RegisterListPref(prefs::kProfilesLastActive); 860 prefs->RegisterListPref(prefs::kProfilesLastActive);
846 } 861 }
847 862
848 size_t ProfileManager::GetNumberOfProfiles() { 863 size_t ProfileManager::GetNumberOfProfiles() {
849 return GetProfileInfoCache().GetNumberOfProfiles(); 864 return GetProfileInfoCache().GetNumberOfProfiles();
850 } 865 }
851 866
852 bool ProfileManager::CompareProfilePathAndName( 867 bool ProfileManager::CompareProfilePathAndName(
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 ProfileManager::ProfileInfo::ProfileInfo( 1086 ProfileManager::ProfileInfo::ProfileInfo(
1072 Profile* profile, 1087 Profile* profile,
1073 bool created) 1088 bool created)
1074 : profile(profile), 1089 : profile(profile),
1075 created(created) { 1090 created(created) {
1076 } 1091 }
1077 1092
1078 ProfileManager::ProfileInfo::~ProfileInfo() { 1093 ProfileManager::ProfileInfo::~ProfileInfo() {
1079 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1094 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1080 } 1095 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698