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

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 10823217: Create/Delete windows profile shortcuts (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
===================================================================
--- chrome/browser/profiles/profile_manager.cc (revision 150342)
+++ chrome/browser/profiles/profile_manager.cc (working copy)
@@ -239,6 +239,7 @@
: user_data_dir_(user_data_dir),
logged_in_(false),
will_import_(false),
+ profile_shortcut_manager_(NULL),
#if !defined(OS_ANDROID)
ALLOW_THIS_IN_INITIALIZER_LIST(
browser_list_observer_(this)),
@@ -266,13 +267,12 @@
this,
chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
content::NotificationService::AllSources());
+
+ if (ProfileShortcutManager::IsFeatureEnabled())
+ profile_shortcut_manager_.reset(ProfileShortcutManager::Create());
SteveT 2012/08/15 19:49:31 Oops - my bad. I didn't describe this properly. I
Halli 2012/08/15 19:51:57 Done.
}
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 +454,15 @@
cache.AddProfileToCache(profile_path, name, string16(), icon_index);
}
info->callbacks.push_back(callback);
+ if (profile_shortcut_manager_.get() && !name.empty() &&
+ !icon_url.empty()) {
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&ProfileShortcutManager::CreateChromeDesktopShortcut,
+ base::Unretained(profile_shortcut_manager_.get()), profile_path, name,
+ ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ cache.GetDefaultAvatarIconResourceIDAtIndex(icon_index))));
+ }
}
}
@@ -673,9 +682,6 @@
InitProfileUserPrefs(profile);
AddProfileToCache(profile);
DoFinalInitLogging(profile);
-#if defined(OS_WIN)
- CreateDesktopShortcut(profile);
-#endif
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_.get())
+ profile_shortcut_manager_->DeleteChromeDesktopShortcut(profile_dir);
+
ProfileMetrics::LogNumberOfProfiles(this,
ProfileMetrics::DELETE_PROFILE_EVENT);
}
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698