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

Side by Side Diff: chrome/browser/background_sync/background_sync_permission_context_unittest.cc

Issue 1726323002: Have Permission{Manager,Service} use Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/background_sync/background_sync_permission_context.h" 5 #include "chrome/browser/background_sync/background_sync_permission_context.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
13 #include "chrome/browser/permissions/permission_request_id.h" 13 #include "chrome/browser/permissions/permission_request_id.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
16 #include "components/content_settings/core/browser/host_content_settings_map.h" 16 #include "components/content_settings/core/browser/host_content_settings_map.h"
17 #include "components/content_settings/core/common/content_settings.h" 17 #include "components/content_settings/core/common/content_settings.h"
18 #include "components/content_settings/core/common/content_settings_pattern.h" 18 #include "components/content_settings/core/common/content_settings_pattern.h"
19 #include "components/content_settings/core/common/content_settings_types.h" 19 #include "components/content_settings/core/common/content_settings_types.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/test/mock_render_process_host.h" 21 #include "content/public/test/mock_render_process_host.h"
22 #include "content/public/test/web_contents_tester.h" 22 #include "content/public/test/web_contents_tester.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "url/origin.h"
24 25
25 class BackgroundSyncPermissionContextTest 26 class BackgroundSyncPermissionContextTest
26 : public ChromeRenderViewHostTestHarness { 27 : public ChromeRenderViewHostTestHarness {
27 protected: 28 protected:
28 BackgroundSyncPermissionContextTest() = default; 29 BackgroundSyncPermissionContextTest() = default;
29 30
30 ~BackgroundSyncPermissionContextTest() override = default; 31 ~BackgroundSyncPermissionContextTest() override = default;
31 32
32 void NavigateAndRequestPermission( 33 void NavigateAndRequestPermission(
33 const GURL& url, 34 const GURL& url,
34 BackgroundSyncPermissionContext* permission_context) { 35 BackgroundSyncPermissionContext* permission_context) {
35 content::WebContentsTester::For(web_contents())->NavigateAndCommit(url); 36 content::WebContentsTester::For(web_contents())->NavigateAndCommit(url);
36 37
37 base::RunLoop run_loop; 38 base::RunLoop run_loop;
38 39
39 const PermissionRequestID id( 40 const PermissionRequestID id(
40 web_contents()->GetRenderProcessHost()->GetID(), 41 web_contents()->GetRenderProcessHost()->GetID(),
41 web_contents()->GetMainFrame()->GetRoutingID(), -1 /* request_id */); 42 web_contents()->GetMainFrame()->GetRoutingID(), -1 /* request_id */);
42 permission_context->RequestPermission( 43 permission_context->RequestPermission(
43 web_contents(), id, url, 44 web_contents(), id, url::Origin(url),
44 base::Bind( 45 base::Bind(
45 &BackgroundSyncPermissionContextTest::TrackPermissionDecision, 46 &BackgroundSyncPermissionContextTest::TrackPermissionDecision,
46 base::Unretained(this), run_loop.QuitClosure())); 47 base::Unretained(this), run_loop.QuitClosure()));
47 48
48 run_loop.Run(); 49 run_loop.Run();
49 } 50 }
50 51
51 void TrackPermissionDecision(base::Closure done_closure, 52 void TrackPermissionDecision(base::Closure done_closure,
52 ContentSetting content_setting) { 53 ContentSetting content_setting) {
53 permission_granted_ = content_setting == CONTENT_SETTING_ALLOW; 54 permission_granted_ = content_setting == CONTENT_SETTING_ALLOW;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 std::string(), CONTENT_SETTING_BLOCK); 94 std::string(), CONTENT_SETTING_BLOCK);
94 95
95 NavigateAndRequestPermission(url1, &permission_context); 96 NavigateAndRequestPermission(url1, &permission_context);
96 97
97 EXPECT_FALSE(permission_granted()); 98 EXPECT_FALSE(permission_granted());
98 99
99 NavigateAndRequestPermission(url2, &permission_context); 100 NavigateAndRequestPermission(url2, &permission_context);
100 101
101 EXPECT_TRUE(permission_granted()); 102 EXPECT_TRUE(permission_granted());
102 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698