| 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 "chrome/browser/profiles/profile_shortcut_manager_win.h" | 5 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace | 208 } // namespace |
| 209 | 209 |
| 210 ProfileShortcutManagerWin::ProfileShortcutManagerWin() { | 210 ProfileShortcutManagerWin::ProfileShortcutManagerWin() { |
| 211 } | 211 } |
| 212 | 212 |
| 213 ProfileShortcutManagerWin::~ProfileShortcutManagerWin() { | 213 ProfileShortcutManagerWin::~ProfileShortcutManagerWin() { |
| 214 } | 214 } |
| 215 | 215 |
| 216 void ProfileShortcutManagerWin::OnProfileAdded( | 216 void ProfileShortcutManagerWin::AddProfileShortcut( |
| 217 const FilePath& profile_path) { | 217 const FilePath& profile_path) { |
| 218 ProfileInfoCache& cache = | 218 ProfileInfoCache& cache = |
| 219 g_browser_process->profile_manager()->GetProfileInfoCache(); | 219 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 220 size_t index = cache.GetIndexOfProfileWithPath(profile_path); | 220 size_t index = cache.GetIndexOfProfileWithPath(profile_path); |
| 221 | 221 |
| 222 // Launch task to add shortcut to desktop on Windows. If this is the very | 222 // Launch task to add shortcut to desktop on Windows. If this is the very |
| 223 // first profile created, don't add the user name to the shortcut. | 223 // first profile created, don't add the user name to the shortcut. |
| 224 // TODO(mirandac): respect master_preferences choice to create no shortcuts | 224 // TODO(mirandac): respect master_preferences choice to create no shortcuts |
| 225 // (see http://crbug.com/104463) | 225 // (see http://crbug.com/104463) |
| 226 if (g_browser_process->profile_manager()->GetNumberOfProfiles() > 1) { | 226 if (g_browser_process->profile_manager()->GetNumberOfProfiles() > 1) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 } else { // Only one profile, so create original shortcut, with no avatar. | 281 } else { // Only one profile, so create original shortcut, with no avatar. |
| 282 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 282 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 283 base::Bind(&CreateChromeDesktopShortcutForProfile, | 283 base::Bind(&CreateChromeDesktopShortcutForProfile, |
| 284 string16(), string16(), FilePath(), | 284 string16(), string16(), FilePath(), |
| 285 static_cast<gfx::Image*>(NULL), true)); | 285 static_cast<gfx::Image*>(NULL), true)); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 void ProfileShortcutManagerWin::OnProfileAdded( |
| 290 const FilePath& profile_path) { |
| 291 } |
| 292 |
| 289 void ProfileShortcutManagerWin::OnProfileWillBeRemoved( | 293 void ProfileShortcutManagerWin::OnProfileWillBeRemoved( |
| 290 const FilePath& profile_path) { | 294 const FilePath& profile_path) { |
| 291 ProfileInfoCache& cache = | 295 ProfileInfoCache& cache = |
| 292 g_browser_process->profile_manager()->GetProfileInfoCache(); | 296 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 293 string16 profile_name = cache.GetNameOfProfileAtIndex( | 297 string16 profile_name = cache.GetNameOfProfileAtIndex( |
| 294 cache.GetIndexOfProfileWithPath(profile_path)); | 298 cache.GetIndexOfProfileWithPath(profile_path)); |
| 295 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 299 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 296 string16 shortcut; | 300 string16 shortcut; |
| 297 if (ShellUtil::GetChromeShortcutName(dist, false, profile_name, &shortcut)) { | 301 if (ShellUtil::GetChromeShortcutName(dist, false, profile_name, &shortcut)) { |
| 298 std::vector<string16> shortcuts(1, shortcut); | 302 std::vector<string16> shortcuts(1, shortcut); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 shortcuts.reserve(profile_names.size()); | 399 shortcuts.reserve(profile_names.size()); |
| 396 for (std::vector<string16>::const_iterator it = profile_names.begin(); | 400 for (std::vector<string16>::const_iterator it = profile_names.begin(); |
| 397 it != profile_names.end(); | 401 it != profile_names.end(); |
| 398 ++it) { | 402 ++it) { |
| 399 string16 shortcut; | 403 string16 shortcut; |
| 400 if (ShellUtil::GetChromeShortcutName(dist, false, *it, &shortcut)) | 404 if (ShellUtil::GetChromeShortcutName(dist, false, *it, &shortcut)) |
| 401 shortcuts.push_back(shortcut); | 405 shortcuts.push_back(shortcut); |
| 402 } | 406 } |
| 403 return shortcuts; | 407 return shortcuts; |
| 404 } | 408 } |
| OLD | NEW |