Index: chrome/browser/profiles/profile_shortcut_manager_win.cc |
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc |
index 261944906e32ed3cc543cb5d7de2c7861d2313ce..f8d1341f27a0f446979eee268765ce5a76b17474 100644 |
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc |
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc |
@@ -32,6 +32,7 @@ |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/icon_util.h" |
+#include "ui/gfx/image/image.h" |
using content::BrowserThread; |
@@ -120,9 +121,10 @@ void RenameChromeDesktopShortcutForProfile( |
const string16& old_shortcut_file, |
const string16& new_shortcut_file) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
FilePath shortcut_path; |
- if (ShellUtil::GetDesktopPath(false, // User's directory instead of system. |
- &shortcut_path)) { |
+ if (ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_DESKTOP, dist, false, |
+ &shortcut_path)) { |
FilePath old_shortcut_path = shortcut_path.Append(old_shortcut_file); |
FilePath new_shortcut_path = shortcut_path.Append(new_shortcut_file); |
if (!file_util::Move(old_shortcut_path, new_shortcut_path)) |
@@ -142,25 +144,28 @@ void CreateOrUpdateProfileDesktopShortcut( |
CreateChromeDesktopShortcutIconForProfile(profile_path, avatar_image); |
FilePath chrome_exe; |
- if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
+ if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
+ NOTREACHED(); |
return; |
+ } |
BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
- if (!dist) |
+ if (!dist) { |
+ NOTREACHED(); |
robertshield
2012/10/02 13:08:04
we don't check the return value of GetDistribution
gab
2012/10/03 15:14:59
True, removed!
|
return; |
- string16 description(dist->GetAppDescription()); |
- |
- uint32 options = create ? ShellUtil::SHORTCUT_CREATE_ALWAYS : |
- ShellUtil::SHORTCUT_NO_OPTIONS; |
- ShellUtil::CreateChromeDesktopShortcut( |
- dist, |
- chrome_exe.value(), |
- description, |
- profile_name, |
- CreateProfileShortcutFlags(profile_path), |
- shortcut_icon.empty() ? chrome_exe.value() : shortcut_icon.value(), |
- shortcut_icon.empty() ? dist->GetIconIndex() : 0, |
- ShellUtil::CURRENT_USER, |
- options); |
+ } |
+ |
+ ShellUtil::ChromeShortcutProperties properties; |
+ properties.set_target(chrome_exe); |
+ properties.set_arguments(CreateProfileShortcutFlags(profile_path)); |
+ if (!shortcut_icon.empty()) |
+ properties.set_icon(shortcut_icon); |
+ properties.set_shortcut_name( |
+ ProfileShortcutManager::GetShortcutNameForProfile(profile_name)); |
+ ShellUtil::ChromeShortcutOperation operation = |
+ create ? ShellUtil::SHORTCUT_CREATE_ALWAYS : |
+ ShellUtil::SHORTCUT_REPLACE_EXISTING; |
+ ShellUtil::CreateOrUpdateChromeShortcut( |
+ ShellUtil::SHORTCUT_DESKTOP, dist, properties, operation); |
} |
} // namespace |
@@ -207,6 +212,17 @@ ProfileShortcutManager* ProfileShortcutManager::Create( |
return new ProfileShortcutManagerWin(manager); |
} |
+// static |
+string16 ProfileShortcutManager::GetShortcutNameForProfile( |
+ const string16& profile_name) { |
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
+ string16 shortcut_name(dist->GetAppShortCutName()); |
+ shortcut_name.append(L" ("); |
+ shortcut_name.append(profile_name); |
+ shortcut_name.append(L")"); |
+ return shortcut_name; |
+} |
+ |
ProfileShortcutManagerWin::ProfileShortcutManagerWin(ProfileManager* manager) |
: profile_manager_(manager) { |
profile_manager_->GetProfileInfoCache().AddObserver(this); |
@@ -251,17 +267,15 @@ void ProfileShortcutManagerWin::OnProfileWasRemoved( |
profile_name_updated = profile_name; |
BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
- string16 shortcut; |
- // If we can find the shortcut, delete it |
- if (ShellUtil::GetChromeShortcutName(dist, false, |
- profile_name_updated, &shortcut)) { |
- std::vector<string16> appended_names(1, shortcut); |
- BrowserThread::PostTask( |
- BrowserThread::FILE, FROM_HERE, |
- base::Bind(&CallBoolFunction, base::Bind( |
- &ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames, |
- appended_names))); |
- } |
+ ShellUtil::ChromeShortcutProperties shortcut_properties; |
+ shortcut_properties.set_shortcut_name( |
+ GetShortcutNameForProfile(profile_name_updated)); |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ base::Bind(&CallBoolFunction, base::Bind( |
+ &ShellUtil::RemoveChromeShortcut, ShellUtil::SHORTCUT_DESKTOP, |
+ dist, shortcut_properties))); |
+ |
FilePath icon_path = profile_path.AppendASCII(kProfileIconFileName); |
BrowserThread::PostTask( |
BrowserThread::FILE, FROM_HERE, |
@@ -294,19 +308,14 @@ void ProfileShortcutManagerWin::StartProfileShortcutNameChange( |
profile_manager_->GetProfileInfoCache(). |
GetNameOfProfileAtIndex(profile_index); |
- string16 old_shortcut_file; |
- string16 new_shortcut_file; |
BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
- if (ShellUtil::GetChromeShortcutName( |
- dist, false, old_profile_name, &old_shortcut_file) && |
- ShellUtil::GetChromeShortcutName( |
- dist, false, new_profile_name, &new_shortcut_file)) { |
- BrowserThread::PostTask( |
- BrowserThread::FILE, FROM_HERE, |
- base::Bind(&RenameChromeDesktopShortcutForProfile, |
- old_shortcut_file, |
- new_shortcut_file)); |
- } |
+ string16 old_shortcut_file(GetShortcutNameForProfile(old_profile_name)); |
+ string16 new_shortcut_file(GetShortcutNameForProfile(new_profile_name)); |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ base::Bind(&RenameChromeDesktopShortcutForProfile, |
+ old_shortcut_file, |
+ new_shortcut_file)); |
} |
FilePath ProfileShortcutManagerWin::GetOtherProfilePath( |