OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/extension_service_test_base.h" | 8 #include "chrome/browser/extensions/extension_service_test_base.h" |
9 #include "chrome/browser/extensions/extension_util.h" | 9 #include "chrome/browser/extensions/extension_util.h" |
10 #include "chrome/browser/extensions/permissions_updater.h" | 10 #include "chrome/browser/extensions/permissions_updater.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 PermissionsUpdater(profile()).InitializePermissions(extension.get()); | 350 PermissionsUpdater(profile()).InitializePermissions(extension.get()); |
351 | 351 |
352 ScriptingPermissionsModifier modifier(profile(), extension); | 352 ScriptingPermissionsModifier modifier(profile(), extension); |
353 EXPECT_TRUE(modifier.IsAllowedOnAllUrls()); | 353 EXPECT_TRUE(modifier.IsAllowedOnAllUrls()); |
354 | 354 |
355 // Simulate preferences being incorrectly set. | 355 // Simulate preferences being incorrectly set. |
356 const char* kAllowedPref = "extension_can_script_all_urls"; | 356 const char* kAllowedPref = "extension_can_script_all_urls"; |
357 const char* kHasSetPref = "has_set_script_all_urls"; | 357 const char* kHasSetPref = "has_set_script_all_urls"; |
358 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 358 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
359 prefs->UpdateExtensionPref(extension->id(), kAllowedPref, | 359 prefs->UpdateExtensionPref(extension->id(), kAllowedPref, |
360 new base::FundamentalValue(false)); | 360 new base::Value(false)); |
361 prefs->UpdateExtensionPref(extension->id(), kHasSetPref, | 361 prefs->UpdateExtensionPref(extension->id(), kHasSetPref, |
362 new base::FundamentalValue(true)); | 362 new base::Value(true)); |
363 | 363 |
364 // The modifier should still return the correct value and should fix the | 364 // The modifier should still return the correct value and should fix the |
365 // preferences. | 365 // preferences. |
366 EXPECT_TRUE(modifier.IsAllowedOnAllUrls()); | 366 EXPECT_TRUE(modifier.IsAllowedOnAllUrls()); |
367 bool stored_allowed = false; | 367 bool stored_allowed = false; |
368 EXPECT_TRUE( | 368 EXPECT_TRUE( |
369 prefs->ReadPrefAsBoolean(extension->id(), kAllowedPref, &stored_allowed)); | 369 prefs->ReadPrefAsBoolean(extension->id(), kAllowedPref, &stored_allowed)); |
370 EXPECT_TRUE(stored_allowed); | 370 EXPECT_TRUE(stored_allowed); |
371 bool has_set = false; | 371 bool has_set = false; |
372 EXPECT_FALSE( | 372 EXPECT_FALSE( |
373 prefs->ReadPrefAsBoolean(extension->id(), kHasSetPref, &has_set)); | 373 prefs->ReadPrefAsBoolean(extension->id(), kHasSetPref, &has_set)); |
374 } | 374 } |
375 | 375 |
376 } // namespace extensions | 376 } // namespace extensions |
OLD | NEW |