Chromium Code Reviews| 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 <objbase.h> // For CoInitialize(). | 5 #include <objbase.h> // For CoInitialize(). |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 const tracked_objects::Location& location) { | 216 const tracked_objects::Location& location) { |
| 217 BrowserDistribution* distribution = GetDistribution(); | 217 BrowserDistribution* distribution = GetDistribution(); |
| 218 installer::Product product(distribution); | 218 installer::Product product(distribution); |
| 219 ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); | 219 ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); |
| 220 product.AddDefaultShortcutProperties(GetExePath(), &properties); | 220 product.AddDefaultShortcutProperties(GetExePath(), &properties); |
| 221 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 221 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 222 ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, | 222 ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, |
| 223 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); | 223 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); |
| 224 const base::FilePath system_level_shortcut_path = | 224 const base::FilePath system_level_shortcut_path = |
| 225 GetSystemShortcutsDirectory().Append( | 225 GetSystemShortcutsDirectory().Append( |
| 226 distribution->GetAppShortCutName() + installer::kLnkExt); | 226 distribution->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME) |
|
huangs
2013/05/21 21:35:41
What happened to .name?
gab
2013/05/21 21:46:45
This should be using the subfolder anyways.
calamity
2013/05/24 02:03:11
Why? Isn't this chrome.lnk?
gab
2013/05/24 15:01:35
Oh, yes, my bad!
| |
| 227 + installer::kLnkExt); | |
| 227 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)) | 228 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)) |
| 228 << location.ToString(); | 229 << location.ToString(); |
| 229 return system_level_shortcut_path; | 230 return system_level_shortcut_path; |
| 230 } | 231 } |
| 231 | 232 |
| 232 void RenameProfile(const tracked_objects::Location& location, | 233 void RenameProfile(const tracked_objects::Location& location, |
| 233 const base::FilePath& profile_path, | 234 const base::FilePath& profile_path, |
| 234 const string16& new_profile_name) { | 235 const string16& new_profile_name) { |
| 235 const size_t profile_index = | 236 const size_t profile_index = |
| 236 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); | 237 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 profiles::internal::GetShortcutFilenameForProfile(kLongProfileName, | 305 profiles::internal::GetShortcutFilenameForProfile(kLongProfileName, |
| 305 GetDistribution()); | 306 GetDistribution()); |
| 306 EXPECT_LT(file_name.size(), kLongProfileName.size()); | 307 EXPECT_LT(file_name.size(), kLongProfileName.size()); |
| 307 } | 308 } |
| 308 | 309 |
| 309 TEST_F(ProfileShortcutManagerTest, ShortcutFilenameStripsReservedCharacters) { | 310 TEST_F(ProfileShortcutManagerTest, ShortcutFilenameStripsReservedCharacters) { |
| 310 const string16 kProfileName = L"<Harry/>"; | 311 const string16 kProfileName = L"<Harry/>"; |
| 311 const string16 kSanitizedProfileName = L"Harry"; | 312 const string16 kSanitizedProfileName = L"Harry"; |
| 312 BrowserDistribution* distribution = GetDistribution(); | 313 BrowserDistribution* distribution = GetDistribution(); |
| 313 const string16 expected_name = kSanitizedProfileName + L" - " + | 314 const string16 expected_name = kSanitizedProfileName + L" - " + |
| 314 distribution->GetAppShortCutName() + installer::kLnkExt; | 315 distribution->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name |
| 316 + installer::kLnkExt; | |
| 315 EXPECT_EQ(expected_name, | 317 EXPECT_EQ(expected_name, |
| 316 profiles::internal::GetShortcutFilenameForProfile(kProfileName, | 318 profiles::internal::GetShortcutFilenameForProfile(kProfileName, |
| 317 distribution)); | 319 distribution)); |
| 318 } | 320 } |
| 319 | 321 |
| 320 TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { | 322 TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { |
| 321 BrowserDistribution* distribution = GetDistribution(); | 323 BrowserDistribution* distribution = GetDistribution(); |
| 322 EXPECT_EQ(distribution->GetAppShortCutName() + installer::kLnkExt, | 324 EXPECT_EQ( |
| 323 profiles::internal::GetShortcutFilenameForProfile(string16(), | 325 distribution->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name |
| 324 distribution)); | 326 + installer::kLnkExt, |
| 327 profiles::internal::GetShortcutFilenameForProfile(string16(), | |
| 328 distribution)); | |
| 325 } | 329 } |
| 326 | 330 |
| 327 TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { | 331 TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { |
| 328 const string16 kProfileName = L"MyProfileX"; | 332 const string16 kProfileName = L"MyProfileX"; |
| 329 const base::FilePath profile_path = | 333 const base::FilePath profile_path = |
| 330 profile_info_cache_->GetUserDataDir().Append(kProfileName); | 334 profile_info_cache_->GetUserDataDir().Append(kProfileName); |
| 331 EXPECT_EQ(L"--profile-directory=\"" + kProfileName + L"\"", | 335 EXPECT_EQ(L"--profile-directory=\"" + kProfileName + L"\"", |
| 332 profiles::internal::CreateProfileShortcutFlags(profile_path)); | 336 profiles::internal::CreateProfileShortcutFlags(profile_path)); |
| 333 } | 337 } |
| 334 | 338 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 | 576 |
| 573 TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { | 577 TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { |
| 574 SetupDefaultProfileShortcut(FROM_HERE); | 578 SetupDefaultProfileShortcut(FROM_HERE); |
| 575 | 579 |
| 576 // Delete the shortcut that got created for this profile and instead make | 580 // Delete the shortcut that got created for this profile and instead make |
| 577 // a new one without any command-line flags. | 581 // a new one without any command-line flags. |
| 578 ASSERT_TRUE(file_util::Delete(GetDefaultShortcutPathForProfile(string16()), | 582 ASSERT_TRUE(file_util::Delete(GetDefaultShortcutPathForProfile(string16()), |
| 579 false)); | 583 false)); |
| 580 const base::FilePath regular_shortcut_path = | 584 const base::FilePath regular_shortcut_path = |
| 581 CreateRegularShortcutWithName(FROM_HERE, | 585 CreateRegularShortcutWithName(FROM_HERE, |
| 582 GetDistribution()->GetAppShortCutName()); | 586 GetDistribution()->GetShortcutInfo( |
| 587 BrowserDistribution::SHORTCUT_CHROME).name); | |
| 583 | 588 |
| 584 // Add another profile and check that the shortcut was replaced with | 589 // Add another profile and check that the shortcut was replaced with |
| 585 // a badged shortcut with the right command line for the profile | 590 // a badged shortcut with the right command line for the profile |
| 586 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 591 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 587 EXPECT_FALSE(file_util::PathExists(regular_shortcut_path)); | 592 EXPECT_FALSE(file_util::PathExists(regular_shortcut_path)); |
| 588 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 593 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
| 589 } | 594 } |
| 590 | 595 |
| 591 TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { | 596 TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { |
| 592 SetupDefaultProfileShortcut(FROM_HERE); | 597 SetupDefaultProfileShortcut(FROM_HERE); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 771 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
| 767 RunPendingTasks(); | 772 RunPendingTasks(); |
| 768 | 773 |
| 769 // Verify that only the system-level shortcut still exists. | 774 // Verify that only the system-level shortcut still exists. |
| 770 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 775 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); |
| 771 EXPECT_FALSE(file_util::PathExists( | 776 EXPECT_FALSE(file_util::PathExists( |
| 772 GetDefaultShortcutPathForProfile(string16()))); | 777 GetDefaultShortcutPathForProfile(string16()))); |
| 773 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 778 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); |
| 774 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 779 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); |
| 775 } | 780 } |
| OLD | NEW |