OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
| 7 #include <utility> |
7 | 8 |
8 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
13 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 15 #include "base/memory/ptr_util.h" |
14 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
15 #include "base/metrics/histogram_samples.h" | 17 #include "base/metrics/histogram_samples.h" |
16 #include "base/metrics/statistics_recorder.h" | 18 #include "base/metrics/statistics_recorder.h" |
17 #include "base/path_service.h" | 19 #include "base/path_service.h" |
18 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
21 #include "base/values.h" | 23 #include "base/values.h" |
22 #include "build/build_config.h" | 24 #include "build/build_config.h" |
23 #include "chrome/browser/extensions/extension_browsertest.h" | 25 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 // Tamper with any installed setting for good.crx | 880 // Tamper with any installed setting for good.crx |
879 base::DictionaryValue* good_crx_dict; | 881 base::DictionaryValue* good_crx_dict; |
880 EXPECT_TRUE(extensions_dict->GetDictionary(kGoodCrxId, &good_crx_dict)); | 882 EXPECT_TRUE(extensions_dict->GetDictionary(kGoodCrxId, &good_crx_dict)); |
881 int good_crx_state; | 883 int good_crx_state; |
882 EXPECT_TRUE(good_crx_dict->GetInteger("state", &good_crx_state)); | 884 EXPECT_TRUE(good_crx_dict->GetInteger("state", &good_crx_state)); |
883 EXPECT_EQ(extensions::Extension::ENABLED, good_crx_state); | 885 EXPECT_EQ(extensions::Extension::ENABLED, good_crx_state); |
884 good_crx_dict->SetInteger("state", extensions::Extension::DISABLED); | 886 good_crx_dict->SetInteger("state", extensions::Extension::DISABLED); |
885 | 887 |
886 // Drop a fake extension (for the purpose of this test, dropped settings | 888 // Drop a fake extension (for the purpose of this test, dropped settings |
887 // don't need to be valid extension settings). | 889 // don't need to be valid extension settings). |
888 base::DictionaryValue* fake_extension = new base::DictionaryValue; | 890 auto fake_extension = base::MakeUnique<base::DictionaryValue>(); |
889 fake_extension->SetString("name", "foo"); | 891 fake_extension->SetString("name", "foo"); |
890 extensions_dict->Set(std::string(32, 'a'), fake_extension); | 892 extensions_dict->Set(std::string(32, 'a'), std::move(fake_extension)); |
891 } | 893 } |
892 | 894 |
893 void VerifyReactionToPrefAttack() override { | 895 void VerifyReactionToPrefAttack() override { |
894 // Expect a single split pref changed report with a count of 2 for tracked | 896 // Expect a single split pref changed report with a count of 2 for tracked |
895 // pref #5 (extensions). | 897 // pref #5 (extensions). |
896 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 898 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
897 GetTrackedPrefHistogramCount( | 899 GetTrackedPrefHistogramCount( |
898 user_prefs::tracked::kTrackedPrefHistogramChanged, | 900 user_prefs::tracked::kTrackedPrefHistogramChanged, |
899 BEGIN_ALLOW_SINGLE_BUCKET + 5)); | 901 BEGIN_ALLOW_SINGLE_BUCKET + 5)); |
900 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 902 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); | 1273 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); |
1272 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); | 1274 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); |
1273 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); | 1275 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); |
1274 EXPECT_NE(current_dse->url(), | 1276 EXPECT_NE(current_dse->url(), |
1275 "http://bad_default_engine/search?q=dirty_user_query"); | 1277 "http://bad_default_engine/search?q=dirty_user_query"); |
1276 } | 1278 } |
1277 } | 1279 } |
1278 }; | 1280 }; |
1279 | 1281 |
1280 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, SearchProtected); | 1282 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, SearchProtected); |
OLD | NEW |