Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/permissions/permission_util_unittest.cc

Issue 1803973002: Content Settings: Add RevocationObserver to measure when permissions are revoked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrite patch in permissions layer Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
6 #include "chrome/browser/permissions/permission_util.h"
7 #include "chrome/test/base/testing_profile.h"
8 #include "components/content_settings/core/browser/host_content_settings_map.h"
9 #include "content/public/test/test_browser_thread_bundle.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 class PermissionUtilTest : public testing::Test {
13 content::TestBrowserThreadBundle thread_bundle_;
14 };
15
16 TEST_F(PermissionUtilTest, SetContentSettingRecordRevocation) {
17 TestingProfile profile;
18 HostContentSettingsMap* map =
19 HostContentSettingsMapFactory::GetForProfile(&profile);
20 GURL host("https://example.com");
21 ContentSettingsType type = CONTENT_SETTINGS_TYPE_GEOLOCATION;
22
23 // Allow->Block triggers a revocation.
24 map->SetContentSettingDefaultScope(host, host, type, "",
Bernhard Bauer 2016/03/22 10:13:30 Nit: Use an empty std::string() constructor instea
tsergeant 2016/03/22 23:55:20 Done.
25 CONTENT_SETTING_ALLOW);
26 EXPECT_TRUE(PermissionUtil::SetContentSettingRecordRevocation(
Bernhard Bauer 2016/03/22 10:13:29 If the return value is only used for tests, it mig
tsergeant 2016/03/22 23:55:20 Done. I don't want to get too deep into testing th
27 &profile, host, host, type, "", CONTENT_SETTING_BLOCK));
28
29 // Block->Allow does not trigger a revocation.
30 EXPECT_FALSE(PermissionUtil::SetContentSettingRecordRevocation(
31 &profile, host, host, type, "", CONTENT_SETTING_ALLOW));
32
33 // Allow->Default triggers a revocation when default is 'ask'.
34 map->SetDefaultContentSetting(type, CONTENT_SETTING_ASK);
35 EXPECT_TRUE(PermissionUtil::SetContentSettingRecordRevocation(
36 &profile, host, host, type, "", CONTENT_SETTING_DEFAULT));
37
38 // Allow->Default does not trigger a revocation when default is 'allow'.
39 map->SetDefaultContentSetting(type, CONTENT_SETTING_ALLOW);
40 EXPECT_FALSE(PermissionUtil::SetContentSettingRecordRevocation(
41 &profile, host, host, type, "", CONTENT_SETTING_DEFAULT));
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698