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 "extension_prefs_unittest.h" | 5 #include "extension_prefs_unittest.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/extension_prefs.h" | 13 #include "chrome/browser/extensions/extension_prefs.h" |
14 #include "chrome/browser/extensions/extension_pref_value_map.h" | 14 #include "chrome/browser/extensions/extension_pref_value_map.h" |
15 #include "chrome/browser/prefs/pref_change_registrar.h" | 15 #include "chrome/browser/prefs/pref_change_registrar.h" |
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/extensions/extension_manifest_constants.h" | 18 #include "chrome/common/extensions/extension_manifest_constants.h" |
19 #include "chrome/common/extensions/permissions/permission_set.h" | 19 #include "chrome/common/extensions/permissions/permission_set.h" |
20 #include "chrome/common/string_ordinal.h" | 20 #include "chrome/common/string_ordinal.h" |
21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
23 #include "content/public/test/mock_notification_observer.h" | 23 #include "content/public/test/mock_notification_observer.h" |
24 | 24 |
25 using base::Time; | 25 using base::Time; |
26 using base::TimeDelta; | 26 using base::TimeDelta; |
27 using content::BrowserThread; | 27 using content::BrowserThread; |
28 using extensions::APIPermission; | |
29 using extensions::APIPermissionSet; | |
30 using extensions::Extension; | |
31 using extensions::ExtensionList; | |
32 using extensions::PermissionSet; | |
33 | 28 |
34 namespace { | 29 namespace { |
35 | 30 |
36 const char kPref1[] = "path1.subpath"; | 31 const char kPref1[] = "path1.subpath"; |
37 const char kPref2[] = "path2"; | 32 const char kPref2[] = "path2"; |
38 const char kPref3[] = "path3"; | 33 const char kPref3[] = "path3"; |
39 const char kPref4[] = "path4"; | 34 const char kPref4[] = "path4"; |
40 | 35 |
41 // Default values in case an extension pref value is not overridden. | 36 // Default values in case an extension pref value is not overridden. |
42 const char kDefaultPref1[] = "default pref 1"; | 37 const char kDefaultPref1[] = "default pref 1"; |
43 const char kDefaultPref2[] = "default pref 2"; | 38 const char kDefaultPref2[] = "default pref 2"; |
44 const char kDefaultPref3[] = "default pref 3"; | 39 const char kDefaultPref3[] = "default pref 3"; |
45 const char kDefaultPref4[] = "default pref 4"; | 40 const char kDefaultPref4[] = "default pref 4"; |
46 | 41 |
47 } // namespace | 42 } // namespace |
48 | 43 |
| 44 namespace extensions { |
| 45 |
49 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 46 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { |
50 int schemes = URLPattern::SCHEME_ALL; | 47 int schemes = URLPattern::SCHEME_ALL; |
51 extent->AddPattern(URLPattern(schemes, pattern)); | 48 extent->AddPattern(URLPattern(schemes, pattern)); |
52 } | 49 } |
53 | 50 |
54 ExtensionPrefsTest::ExtensionPrefsTest() | 51 ExtensionPrefsTest::ExtensionPrefsTest() |
55 : ui_thread_(BrowserThread::UI, &message_loop_), | 52 : ui_thread_(BrowserThread::UI, &message_loop_), |
56 file_thread_(BrowserThread::FILE, &message_loop_) { | 53 file_thread_(BrowserThread::FILE, &message_loop_) { |
57 } | 54 } |
58 | 55 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 EXPECT_FALSE(prefs()->IsExtensionBlacklisted((*iter)->id())); | 403 EXPECT_FALSE(prefs()->IsExtensionBlacklisted((*iter)->id())); |
407 } | 404 } |
408 | 405 |
409 // Make sure GetInstalledExtensionsInfo returns only the non-blacklisted | 406 // Make sure GetInstalledExtensionsInfo returns only the non-blacklisted |
410 // extensions data. | 407 // extensions data. |
411 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( | 408 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( |
412 prefs()->GetInstalledExtensionsInfo()); | 409 prefs()->GetInstalledExtensionsInfo()); |
413 EXPECT_EQ(4u, info->size()); | 410 EXPECT_EQ(4u, info->size()); |
414 ExtensionPrefs::ExtensionsInfo::iterator info_iter; | 411 ExtensionPrefs::ExtensionsInfo::iterator info_iter; |
415 for (info_iter = info->begin(); info_iter != info->end(); ++info_iter) { | 412 for (info_iter = info->begin(); info_iter != info->end(); ++info_iter) { |
416 extensions::ExtensionInfo* extension_info = info_iter->get(); | 413 ExtensionInfo* extension_info = info_iter->get(); |
417 EXPECT_NE(extensions_[0]->id(), extension_info->extension_id); | 414 EXPECT_NE(extensions_[0]->id(), extension_info->extension_id); |
418 } | 415 } |
419 } | 416 } |
420 | 417 |
421 private: | 418 private: |
422 ExtensionList extensions_; | 419 ExtensionList extensions_; |
423 | 420 |
424 // An id we'll make up that doesn't match any installed extension id. | 421 // An id we'll make up that doesn't match any installed extension id. |
425 std::string not_installed_id_; | 422 std::string not_installed_id_; |
426 }; | 423 }; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 } | 889 } |
893 int iteration_; | 890 int iteration_; |
894 }; | 891 }; |
895 TEST_F(ExtensionPrefsInstallIncognitoSessionOnly, | 892 TEST_F(ExtensionPrefsInstallIncognitoSessionOnly, |
896 ExtensionPrefsInstallOneExtension) {} | 893 ExtensionPrefsInstallOneExtension) {} |
897 | 894 |
898 class ExtensionPrefsUninstallExtension : public ExtensionPrefsPrepopulatedTest { | 895 class ExtensionPrefsUninstallExtension : public ExtensionPrefsPrepopulatedTest { |
899 virtual void Initialize() { | 896 virtual void Initialize() { |
900 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); | 897 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); |
901 InstallExtControlledPref(ext1_, kPref2, Value::CreateStringValue("val2")); | 898 InstallExtControlledPref(ext1_, kPref2, Value::CreateStringValue("val2")); |
902 extensions::ContentSettingsStore* store = prefs()->content_settings_store(); | 899 ContentSettingsStore* store = prefs()->content_settings_store(); |
903 ContentSettingsPattern pattern = | 900 ContentSettingsPattern pattern = |
904 ContentSettingsPattern::FromString("http://[*.]example.com"); | 901 ContentSettingsPattern::FromString("http://[*.]example.com"); |
905 store->SetExtensionContentSetting(ext1_->id(), | 902 store->SetExtensionContentSetting(ext1_->id(), |
906 pattern, pattern, | 903 pattern, pattern, |
907 CONTENT_SETTINGS_TYPE_IMAGES, | 904 CONTENT_SETTINGS_TYPE_IMAGES, |
908 std::string(), | 905 std::string(), |
909 CONTENT_SETTING_BLOCK, | 906 CONTENT_SETTING_BLOCK, |
910 kExtensionPrefsScopeRegular); | 907 kExtensionPrefsScopeRegular); |
911 | 908 |
912 UninstallExtension(ext1_->id()); | 909 UninstallExtension(ext1_->id()); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 string16 error16; | 1159 string16 error16; |
1163 EXPECT_TRUE(prefs()->UserMayLoad(extension_.get(), &error16)); | 1160 EXPECT_TRUE(prefs()->UserMayLoad(extension_.get(), &error16)); |
1164 EXPECT_EQ(string16(), error16); | 1161 EXPECT_EQ(string16(), error16); |
1165 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); | 1162 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); |
1166 EXPECT_EQ(string16(), error16); | 1163 EXPECT_EQ(string16(), error16); |
1167 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); | 1164 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); |
1168 EXPECT_EQ(string16(), error16); | 1165 EXPECT_EQ(string16(), error16); |
1169 } | 1166 } |
1170 }; | 1167 }; |
1171 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} | 1168 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} |
| 1169 |
| 1170 } // namespace extensions |
OLD | NEW |