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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc

Issue 1690043004: Use GURLs instead of patterns in SetContentSetting() in geolocation and push_messaging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scoping_set_content_setting
Patch Set: remove CustomScope due to depending CL update 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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/push_messaging/push_messaging_permission_context.h" 5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
6 6
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/permissions/permission_request_id.h" 8 #include "chrome/browser/permissions/permission_request_id.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 class PushMessagingPermissionContextTest 55 class PushMessagingPermissionContextTest
56 : public ChromeRenderViewHostTestHarness { 56 : public ChromeRenderViewHostTestHarness {
57 public: 57 public:
58 PushMessagingPermissionContextTest() {} 58 PushMessagingPermissionContextTest() {}
59 59
60 protected: 60 protected:
61 void SetContentSetting(Profile* profile, 61 void SetContentSetting(Profile* profile,
62 ContentSettingsType setting, 62 ContentSettingsType setting,
63 ContentSetting value) { 63 ContentSetting value) {
64 // These patterns must match those in 64 // These urls must match those in
65 // PermissionContextBase::UpdateContentSetting, since the tests below use 65 // PermissionContextBase::UpdateContentSetting, since the tests below use
66 // this method to overwrite patterns set as a result of 66 // this method to overwrite urls set as a result of
67 // PushMessagingPermissionContext::NotifyPermissionSet. 67 // PushMessagingPermissionContext::NotifyPermissionSet.
68 ContentSettingsPattern pattern_a = 68 GURL url_a = GURL(kOriginA);
69 ContentSettingsPattern::FromURLNoWildcard(GURL(kOriginA)); 69 GURL insecure_url = GURL(kInsecureOrigin);
70 ContentSettingsPattern insecure_pattern =
71 ContentSettingsPattern::FromURLNoWildcard(GURL(kInsecureOrigin));
72 HostContentSettingsMap* host_content_settings_map = 70 HostContentSettingsMap* host_content_settings_map =
73 HostContentSettingsMapFactory::GetForProfile(profile); 71 HostContentSettingsMapFactory::GetForProfile(profile);
74 host_content_settings_map->SetContentSetting(pattern_a, pattern_a, setting, 72
75 std::string(), value); 73 host_content_settings_map->SetContentSettingDefaultScope(
76 host_content_settings_map->SetContentSetting( 74 url_a, url_a, setting, std::string(), value);
77 insecure_pattern, insecure_pattern, setting, std::string(), value); 75 host_content_settings_map->SetContentSettingDefaultScope(
76 insecure_url, insecure_url, setting, std::string(), value);
78 } 77 }
79 }; 78 };
80 79
81 } // namespace 80 } // namespace
82 81
83 TEST_F(PushMessagingPermissionContextTest, HasPermissionPrompt) { 82 TEST_F(PushMessagingPermissionContextTest, HasPermissionPrompt) {
84 TestingProfile profile; 83 TestingProfile profile;
85 PushMessagingPermissionContext context(&profile); 84 PushMessagingPermissionContext context(&profile);
86 EXPECT_EQ(CONTENT_SETTING_ASK, 85 EXPECT_EQ(CONTENT_SETTING_ASK,
87 context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA))); 86 context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA)));
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 EXPECT_EQ(CONTENT_SETTING_BLOCK, 291 EXPECT_EQ(CONTENT_SETTING_BLOCK,
293 context.GetPermissionStatus(GURL(kInsecureOrigin), 292 context.GetPermissionStatus(GURL(kInsecureOrigin),
294 GURL(kInsecureOrigin))); 293 GURL(kInsecureOrigin)));
295 294
296 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 295 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
297 CONTENT_SETTING_ASK); 296 CONTENT_SETTING_ASK);
298 EXPECT_EQ(CONTENT_SETTING_BLOCK, 297 EXPECT_EQ(CONTENT_SETTING_BLOCK,
299 context.GetPermissionStatus(GURL(kInsecureOrigin), 298 context.GetPermissionStatus(GURL(kInsecureOrigin),
300 GURL(kInsecureOrigin))); 299 GURL(kInsecureOrigin)));
301 } 300 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698