| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/scoped_path_override.h" | 10 #include "base/test/scoped_path_override.h" |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 TEST_F(ProfileResetterTest, CheckSnapshots) { | 857 TEST_F(ProfileResetterTest, CheckSnapshots) { |
| 858 ResettableSettingsSnapshot empty_snap(profile()); | 858 ResettableSettingsSnapshot empty_snap(profile()); |
| 859 EXPECT_EQ(0, empty_snap.FindDifferentFields(empty_snap)); | 859 EXPECT_EQ(0, empty_snap.FindDifferentFields(empty_snap)); |
| 860 | 860 |
| 861 scoped_refptr<Extension> ext = CreateExtension( | 861 scoped_refptr<Extension> ext = CreateExtension( |
| 862 base::ASCIIToUTF16("example"), | 862 base::ASCIIToUTF16("example"), |
| 863 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), | 863 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), |
| 864 Manifest::INVALID_LOCATION, | 864 Manifest::INVALID_LOCATION, |
| 865 extensions::Manifest::TYPE_EXTENSION, | 865 extensions::Manifest::TYPE_EXTENSION, |
| 866 false); | 866 false); |
| 867 ASSERT_TRUE(ext); | 867 ASSERT_TRUE(ext.get()); |
| 868 service_->AddExtension(ext.get()); | 868 service_->AddExtension(ext.get()); |
| 869 | 869 |
| 870 std::string master_prefs(kDistributionConfig); | 870 std::string master_prefs(kDistributionConfig); |
| 871 std::string ext_id = ext->id(); | 871 std::string ext_id = ext->id(); |
| 872 ReplaceString(&master_prefs, "placeholder_for_id", ext_id); | 872 ReplaceString(&master_prefs, "placeholder_for_id", ext_id); |
| 873 | 873 |
| 874 // Reset to non organic defaults. | 874 // Reset to non organic defaults. |
| 875 ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | | 875 ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | |
| 876 ProfileResetter::HOMEPAGE | | 876 ProfileResetter::HOMEPAGE | |
| 877 ProfileResetter::STARTUP_PAGES, | 877 ProfileResetter::STARTUP_PAGES, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 ProfileResetter::HOMEPAGE | | 946 ProfileResetter::HOMEPAGE | |
| 947 ProfileResetter::STARTUP_PAGES, | 947 ProfileResetter::STARTUP_PAGES, |
| 948 kDistributionConfig); | 948 kDistributionConfig); |
| 949 | 949 |
| 950 scoped_refptr<Extension> ext = CreateExtension( | 950 scoped_refptr<Extension> ext = CreateExtension( |
| 951 base::ASCIIToUTF16("example"), | 951 base::ASCIIToUTF16("example"), |
| 952 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), | 952 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), |
| 953 Manifest::INVALID_LOCATION, | 953 Manifest::INVALID_LOCATION, |
| 954 extensions::Manifest::TYPE_EXTENSION, | 954 extensions::Manifest::TYPE_EXTENSION, |
| 955 false); | 955 false); |
| 956 ASSERT_TRUE(ext); | 956 ASSERT_TRUE(ext.get()); |
| 957 service_->AddExtension(ext.get()); | 957 service_->AddExtension(ext.get()); |
| 958 | 958 |
| 959 ShortcutHandler shortcut; | 959 ShortcutHandler shortcut; |
| 960 ShortcutCommand command_line = shortcut.CreateWithArguments( | 960 ShortcutCommand command_line = shortcut.CreateWithArguments( |
| 961 base::ASCIIToUTF16("chrome.lnk"), | 961 base::ASCIIToUTF16("chrome.lnk"), |
| 962 base::ASCIIToUTF16("--profile-directory=Default foo.com")); | 962 base::ASCIIToUTF16("--profile-directory=Default foo.com")); |
| 963 | 963 |
| 964 ResettableSettingsSnapshot nonorganic_snap(profile()); | 964 ResettableSettingsSnapshot nonorganic_snap(profile()); |
| 965 nonorganic_snap.RequestShortcuts(base::Closure()); | 965 nonorganic_snap.RequestShortcuts(base::Closure()); |
| 966 // Let it enumerate shortcuts on the FILE thread. | 966 // Let it enumerate shortcuts on the FILE thread. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 }; | 1025 }; |
| 1026 | 1026 |
| 1027 // Make sure GetReadableFeedback handles non-ascii letters. | 1027 // Make sure GetReadableFeedback handles non-ascii letters. |
| 1028 TEST_F(ProfileResetterTest, GetReadableFeedback) { | 1028 TEST_F(ProfileResetterTest, GetReadableFeedback) { |
| 1029 scoped_refptr<Extension> ext = CreateExtension( | 1029 scoped_refptr<Extension> ext = CreateExtension( |
| 1030 base::WideToUTF16(L"Tiësto"), | 1030 base::WideToUTF16(L"Tiësto"), |
| 1031 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), | 1031 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), |
| 1032 Manifest::INVALID_LOCATION, | 1032 Manifest::INVALID_LOCATION, |
| 1033 extensions::Manifest::TYPE_EXTENSION, | 1033 extensions::Manifest::TYPE_EXTENSION, |
| 1034 false); | 1034 false); |
| 1035 ASSERT_TRUE(ext); | 1035 ASSERT_TRUE(ext.get()); |
| 1036 service_->AddExtension(ext.get()); | 1036 service_->AddExtension(ext.get()); |
| 1037 | 1037 |
| 1038 PrefService* prefs = profile()->GetPrefs(); | 1038 PrefService* prefs = profile()->GetPrefs(); |
| 1039 DCHECK(prefs); | 1039 DCHECK(prefs); |
| 1040 // The URL is "http://россия.рф". | 1040 // The URL is "http://россия.рф". |
| 1041 std::wstring url(L"http://" | 1041 std::wstring url(L"http://" |
| 1042 L"\u0440\u043e\u0441\u0441\u0438\u044f.\u0440\u0444"); | 1042 L"\u0440\u043e\u0441\u0441\u0438\u044f.\u0440\u0444"); |
| 1043 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); | 1043 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); |
| 1044 prefs->SetString(prefs::kHomePage, base::WideToUTF8(url)); | 1044 prefs->SetString(prefs::kHomePage, base::WideToUTF8(url)); |
| 1045 | 1045 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 new ResettableSettingsSnapshot(profile())); | 1096 new ResettableSettingsSnapshot(profile())); |
| 1097 deleted_snapshot->RequestShortcuts(base::Bind(&FeedbackCapture::Fail, | 1097 deleted_snapshot->RequestShortcuts(base::Bind(&FeedbackCapture::Fail, |
| 1098 base::Unretained(&capture))); | 1098 base::Unretained(&capture))); |
| 1099 deleted_snapshot.reset(); | 1099 deleted_snapshot.reset(); |
| 1100 // Running remaining tasks shouldn't trigger the callback to be called as | 1100 // Running remaining tasks shouldn't trigger the callback to be called as |
| 1101 // |deleted_snapshot| was deleted before it could run. | 1101 // |deleted_snapshot| was deleted before it could run. |
| 1102 base::MessageLoop::current()->RunUntilIdle(); | 1102 base::MessageLoop::current()->RunUntilIdle(); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 } // namespace | 1105 } // namespace |
| OLD | NEW |