| 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" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/app_icon_win.h" | 13 #include "chrome/browser/app_icon_win.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/profiles/profile_info_cache.h" | 16 #include "chrome/browser/profiles/profile_info_cache.h" |
| 17 #include "chrome/browser/profiles/profile_info_util.h" | 17 #include "chrome/browser/profiles/profile_info_util.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/installer/util/auto_launch_util.h" |
| 22 #include "chrome/installer/util/browser_distribution.h" | 23 #include "chrome/installer/util/browser_distribution.h" |
| 23 #include "chrome/installer/util/shell_util.h" | 24 #include "chrome/installer/util/shell_util.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 26 #include "skia/ext/image_operations.h" | 27 #include "skia/ext/image_operations.h" |
| 27 #include "skia/ext/platform_canvas.h" | 28 #include "skia/ext/platform_canvas.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/gfx/icon_util.h" | 31 #include "ui/gfx/icon_util.h" |
| 31 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 dist, | 199 dist, |
| 199 chrome_exe.value(), | 200 chrome_exe.value(), |
| 200 shortcut_path.value(), | 201 shortcut_path.value(), |
| 201 arguments, | 202 arguments, |
| 202 description, | 203 description, |
| 203 icon_path.empty() ? chrome_exe.value() : icon_path.value(), | 204 icon_path.empty() ? chrome_exe.value() : icon_path.value(), |
| 204 icon_path.empty() ? dist->GetIconIndex() : 0, | 205 icon_path.empty() ? dist->GetIconIndex() : 0, |
| 205 false); | 206 false); |
| 206 } | 207 } |
| 207 | 208 |
| 209 void DeleteAutoLaunchValueForProfile( |
| 210 const FilePath& profile_path) { |
| 211 if (auto_launch_util::WillLaunchAtLogin(FilePath(), |
| 212 profile_path.BaseName().value())) { |
| 213 auto_launch_util::SetWillLaunchAtLogin( |
| 214 false, FilePath(), profile_path.BaseName().value()); |
| 215 } |
| 216 } |
| 217 |
| 208 } // namespace | 218 } // namespace |
| 209 | 219 |
| 210 ProfileShortcutManagerWin::ProfileShortcutManagerWin() { | 220 ProfileShortcutManagerWin::ProfileShortcutManagerWin() { |
| 211 } | 221 } |
| 212 | 222 |
| 213 ProfileShortcutManagerWin::~ProfileShortcutManagerWin() { | 223 ProfileShortcutManagerWin::~ProfileShortcutManagerWin() { |
| 214 } | 224 } |
| 215 | 225 |
| 216 void ProfileShortcutManagerWin::AddProfileShortcut( | 226 void ProfileShortcutManagerWin::AddProfileShortcut( |
| 217 const FilePath& profile_path) { | 227 const FilePath& profile_path) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 base::Bind(&CallShellUtilBoolFunction, | 318 base::Bind(&CallShellUtilBoolFunction, |
| 309 base::Bind( | 319 base::Bind( |
| 310 &ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames, | 320 &ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames, |
| 311 shortcuts))); | 321 shortcuts))); |
| 312 } | 322 } |
| 313 } | 323 } |
| 314 | 324 |
| 315 void ProfileShortcutManagerWin::OnProfileWasRemoved( | 325 void ProfileShortcutManagerWin::OnProfileWasRemoved( |
| 316 const FilePath& profile_path, | 326 const FilePath& profile_path, |
| 317 const string16& profile_name) { | 327 const string16& profile_name) { |
| 328 BrowserThread::PostTask( |
| 329 BrowserThread::FILE, FROM_HERE, |
| 330 base::Bind(&DeleteAutoLaunchValueForProfile, profile_path)); |
| 331 |
| 318 // If there is one profile left, we want to remove the badge and name from it. | 332 // If there is one profile left, we want to remove the badge and name from it. |
| 319 ProfileInfoCache& cache = | 333 ProfileInfoCache& cache = |
| 320 g_browser_process->profile_manager()->GetProfileInfoCache(); | 334 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 321 if (cache.GetNumberOfProfiles() != 1) | 335 if (cache.GetNumberOfProfiles() != 1) |
| 322 return; | 336 return; |
| 323 | 337 |
| 324 FilePath last_profile_path = cache.GetPathOfProfileAtIndex(0); | 338 FilePath last_profile_path = cache.GetPathOfProfileAtIndex(0); |
| 325 string16 old_shortcut; | 339 string16 old_shortcut; |
| 326 string16 new_shortcut; | 340 string16 new_shortcut; |
| 327 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 341 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 shortcuts.reserve(profile_names.size()); | 421 shortcuts.reserve(profile_names.size()); |
| 408 for (std::vector<string16>::const_iterator it = profile_names.begin(); | 422 for (std::vector<string16>::const_iterator it = profile_names.begin(); |
| 409 it != profile_names.end(); | 423 it != profile_names.end(); |
| 410 ++it) { | 424 ++it) { |
| 411 string16 shortcut; | 425 string16 shortcut; |
| 412 if (ShellUtil::GetChromeShortcutName(dist, false, *it, &shortcut)) | 426 if (ShellUtil::GetChromeShortcutName(dist, false, *it, &shortcut)) |
| 413 shortcuts.push_back(shortcut); | 427 shortcuts.push_back(shortcut); |
| 414 } | 428 } |
| 415 return shortcuts; | 429 return shortcuts; |
| 416 } | 430 } |
| OLD | NEW |