Chromium Code Reviews| Index: chrome/browser/profiles/profile_manager.cc |
| =================================================================== |
| --- chrome/browser/profiles/profile_manager.cc (revision 150342) |
| +++ chrome/browser/profiles/profile_manager.cc (working copy) |
| @@ -269,10 +269,6 @@ |
| } |
| ProfileManager::~ProfileManager() { |
| -#if defined(OS_WIN) |
| - if (profile_shortcut_manager_.get()) |
| - profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); |
| -#endif |
| } |
| FilePath ProfileManager::GetDefaultProfileDir( |
| @@ -454,6 +450,15 @@ |
| cache.AddProfileToCache(profile_path, name, string16(), icon_index); |
| } |
| info->callbacks.push_back(callback); |
| + if (profile_shortcut_manager_ && !name.empty() && |
| + !icon_url.empty()) { |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&ProfileShortcutManager::CreateChromeDesktopShortcut, |
| + base::Unretained(profile_shortcut_manager_), profile_path, name, |
| + ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| + cache.GetDefaultAvatarIconResourceIDAtIndex(icon_index)))); |
| + } |
| } |
| } |
| @@ -673,9 +678,10 @@ |
| InitProfileUserPrefs(profile); |
| AddProfileToCache(profile); |
| DoFinalInitLogging(profile); |
| -#if defined(OS_WIN) |
| - CreateDesktopShortcut(profile); |
| -#endif |
| + profile_shortcut_manager_ = NULL; |
|
sail
2012/08/13 22:09:36
this should be in the constructor's initializer li
Halli
2012/08/14 18:25:57
Done.
|
| + if (ProfileShortcutManager::IsFeatureEnabled()) { |
|
sail
2012/08/13 22:09:36
don't need braces
also, this probably belongs in t
Halli
2012/08/14 18:25:57
Done.
|
| + profile_shortcut_manager_ = ProfileShortcutManager::Create(); |
| + } |
| ProfileMetrics::LogNumberOfProfiles(this, ProfileMetrics::ADD_PROFILE_EVENT); |
| content::NotificationService::current()->Notify( |
| @@ -725,12 +731,6 @@ |
| Profile::CREATE_MODE_ASYNCHRONOUS); |
| } |
| -#if defined(OS_WIN) |
| -ProfileShortcutManagerWin* ProfileManager::CreateShortcutManager() { |
| - return new ProfileShortcutManagerWin(); |
| -} |
| -#endif |
| - |
| void ProfileManager::OnProfileCreated(Profile* profile, |
| bool success, |
| bool is_new_profile) { |
| @@ -831,16 +831,6 @@ |
| if (!profile_info_cache_.get()) { |
| profile_info_cache_.reset(new ProfileInfoCache( |
| g_browser_process->local_state(), user_data_dir_)); |
| -#if defined(OS_WIN) |
| - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| - ProfileShortcutManagerWin* shortcut_manager = CreateShortcutManager(); |
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| - if (dist && dist->CanCreateDesktopShortcuts() && shortcut_manager && |
| - !command_line.HasSwitch(switches::kDisableDesktopShortcuts)) { |
| - profile_shortcut_manager_.reset(shortcut_manager); |
| - profile_info_cache_->AddObserver(profile_shortcut_manager_.get()); |
| - } |
| -#endif |
| } |
| return *profile_info_cache_.get(); |
| } |
| @@ -870,28 +860,6 @@ |
| icon_index); |
| } |
| -#if defined(OS_WIN) |
| -void ProfileManager::CreateDesktopShortcut(Profile* profile) { |
| - // TODO(sail): Disable creating new shortcuts for now. |
| - return; |
| - |
| - // Some distributions and tests cannot create desktop shortcuts, in which case |
| - // profile_shortcut_manager_ will not be set. |
| - if (!profile_shortcut_manager_.get()) |
| - return; |
| - |
| - bool shortcut_created = |
| - profile->GetPrefs()->GetBoolean(prefs::kProfileShortcutCreated); |
| - if (!shortcut_created && GetNumberOfProfiles() > 1) { |
| - profile_shortcut_manager_->AddProfileShortcut(profile->GetPath()); |
| - |
| - // We only ever create the shortcut for a profile once, so set a pref |
| - // reminding us to skip this in the future. |
| - profile->GetPrefs()->SetBoolean(prefs::kProfileShortcutCreated, true); |
| - } |
| -} |
| -#endif |
| - |
| void ProfileManager::InitProfileUserPrefs(Profile* profile) { |
| ProfileInfoCache& cache = GetProfileInfoCache(); |
| @@ -982,6 +950,10 @@ |
| QueueProfileDirectoryForDeletion(profile_dir); |
| cache.DeleteProfileFromCache(profile_dir); |
| + // Delete possible shortcuts for this profile |
| + if (profile_shortcut_manager_) |
| + profile_shortcut_manager_->DeleteChromeDesktopShortcut(profile_dir); |
| + |
| ProfileMetrics::LogNumberOfProfiles(this, |
| ProfileMetrics::DELETE_PROFILE_EVENT); |
| } |