| 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 <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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 registrar_.Add( | 262 registrar_.Add( |
| 263 this, | 263 this, |
| 264 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 264 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
| 265 content::NotificationService::AllSources()); | 265 content::NotificationService::AllSources()); |
| 266 registrar_.Add( | 266 registrar_.Add( |
| 267 this, | 267 this, |
| 268 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, | 268 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, |
| 269 content::NotificationService::AllSources()); | 269 content::NotificationService::AllSources()); |
| 270 | 270 |
| 271 if (ProfileShortcutManager::IsFeatureEnabled()) | 271 if (ProfileShortcutManager::IsFeatureEnabled()) |
| 272 profile_shortcut_manager_.reset(ProfileShortcutManager::Create()); | 272 profile_shortcut_manager_.reset(ProfileShortcutManager::Create( |
| 273 GetProfileInfoCache())); |
| 273 } | 274 } |
| 274 | 275 |
| 275 ProfileManager::~ProfileManager() { | 276 ProfileManager::~ProfileManager() { |
| 276 } | 277 } |
| 277 | 278 |
| 278 FilePath ProfileManager::GetDefaultProfileDir( | 279 FilePath ProfileManager::GetDefaultProfileDir( |
| 279 const FilePath& user_data_dir) { | 280 const FilePath& user_data_dir) { |
| 280 FilePath default_profile_dir(user_data_dir); | 281 FilePath default_profile_dir(user_data_dir); |
| 281 default_profile_dir = | 282 default_profile_dir = |
| 282 default_profile_dir.AppendASCII(chrome::kInitialProfile); | 283 default_profile_dir.AppendASCII(chrome::kInitialProfile); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // Get the icon index from the user's icon url | 450 // Get the icon index from the user's icon url |
| 450 size_t icon_index; | 451 size_t icon_index; |
| 451 std::string icon_url_std = UTF16ToASCII(icon_url); | 452 std::string icon_url_std = UTF16ToASCII(icon_url); |
| 452 if (cache.IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) { | 453 if (cache.IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) { |
| 453 // add profile to cache with user selected name and avatar | 454 // add profile to cache with user selected name and avatar |
| 454 cache.AddProfileToCache(profile_path, name, string16(), icon_index); | 455 cache.AddProfileToCache(profile_path, name, string16(), icon_index); |
| 455 } | 456 } |
| 456 info->callbacks.push_back(callback); | 457 info->callbacks.push_back(callback); |
| 457 if (profile_shortcut_manager_.get() && !name.empty() && | 458 if (profile_shortcut_manager_.get() && !name.empty() && |
| 458 !icon_url.empty()) { | 459 !icon_url.empty()) { |
| 459 BrowserThread::PostTask( | 460 profile_shortcut_manager_->StartProfileDesktopShortcutCreation( |
| 460 BrowserThread::FILE, FROM_HERE, | 461 profile_path, name, |
| 461 base::Bind(&ProfileShortcutManager::CreateChromeDesktopShortcut, | |
| 462 base::Unretained(profile_shortcut_manager_.get()), profile_path, name, | |
| 463 ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 462 ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 464 cache.GetDefaultAvatarIconResourceIDAtIndex(icon_index)))); | 463 cache.GetDefaultAvatarIconResourceIDAtIndex(icon_index))); |
| 465 } | 464 } |
| 466 } | 465 } |
| 467 } | 466 } |
| 468 | 467 |
| 469 // static | 468 // static |
| 470 void ProfileManager::CreateDefaultProfileAsync(const CreateCallback& callback) { | 469 void ProfileManager::CreateDefaultProfileAsync(const CreateCallback& callback) { |
| 471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 472 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 471 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 473 | 472 |
| 474 FilePath default_profile_dir = profile_manager->user_data_dir_; | 473 FilePath default_profile_dir = profile_manager->user_data_dir_; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 BrowserList::CloseAllBrowsersWithProfile(profile); | 946 BrowserList::CloseAllBrowsersWithProfile(profile); |
| 948 | 947 |
| 949 // Disable sync for doomed profile. | 948 // Disable sync for doomed profile. |
| 950 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( | 949 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( |
| 951 profile)) { | 950 profile)) { |
| 952 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 951 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 953 profile)->DisableForUser(); | 952 profile)->DisableForUser(); |
| 954 } | 953 } |
| 955 } | 954 } |
| 956 | 955 |
| 956 // Delete possible shortcuts for this profile |
| 957 if (profile_shortcut_manager_.get()) |
| 958 profile_shortcut_manager_->DeleteProfileDesktopShortcut( |
| 959 profile_dir, cache.GetNameOfProfileAtIndex( |
| 960 cache.GetIndexOfProfileWithPath(profile_dir))); |
| 961 |
| 957 QueueProfileDirectoryForDeletion(profile_dir); | 962 QueueProfileDirectoryForDeletion(profile_dir); |
| 958 cache.DeleteProfileFromCache(profile_dir); | 963 cache.DeleteProfileFromCache(profile_dir); |
| 959 | 964 |
| 960 // Delete possible shortcuts for this profile | |
| 961 if (profile_shortcut_manager_.get()) | |
| 962 profile_shortcut_manager_->DeleteChromeDesktopShortcut(profile_dir); | |
| 963 | |
| 964 ProfileMetrics::LogNumberOfProfiles(this, | 965 ProfileMetrics::LogNumberOfProfiles(this, |
| 965 ProfileMetrics::DELETE_PROFILE_EVENT); | 966 ProfileMetrics::DELETE_PROFILE_EVENT); |
| 966 } | 967 } |
| 967 | 968 |
| 968 // static | 969 // static |
| 969 bool ProfileManager::IsMultipleProfilesEnabled() { | 970 bool ProfileManager::IsMultipleProfilesEnabled() { |
| 970 #if defined(OS_CHROMEOS) | 971 #if defined(OS_CHROMEOS) |
| 971 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) | 972 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) |
| 972 return false; | 973 return false; |
| 973 #endif | 974 #endif |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 ProfileManager::ProfileInfo::ProfileInfo(Profile* profile, bool created) | 1017 ProfileManager::ProfileInfo::ProfileInfo(Profile* profile, bool created) |
| 1017 : profile(profile), | 1018 : profile(profile), |
| 1018 created(created) { | 1019 created(created) { |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 ProfileManager::ProfileInfo::~ProfileInfo() { | 1022 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1022 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1023 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1023 } | 1024 } |
| OLD | NEW |