OLD | NEW |
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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const GURL& url, | 33 const GURL& url, |
34 BackgroundSyncPermissionContext* permission_context) { | 34 BackgroundSyncPermissionContext* permission_context) { |
35 content::WebContentsTester::For(web_contents())->NavigateAndCommit(url); | 35 content::WebContentsTester::For(web_contents())->NavigateAndCommit(url); |
36 | 36 |
37 base::RunLoop run_loop; | 37 base::RunLoop run_loop; |
38 | 38 |
39 const PermissionRequestID id( | 39 const PermissionRequestID id( |
40 web_contents()->GetRenderProcessHost()->GetID(), | 40 web_contents()->GetRenderProcessHost()->GetID(), |
41 web_contents()->GetMainFrame()->GetRoutingID(), -1 /* request_id */); | 41 web_contents()->GetMainFrame()->GetRoutingID(), -1 /* request_id */); |
42 permission_context->RequestPermission( | 42 permission_context->RequestPermission( |
43 web_contents(), id, url, | 43 web_contents(), id, url, false /* user_gesture */, |
44 base::Bind( | 44 base::Bind( |
45 &BackgroundSyncPermissionContextTest::TrackPermissionDecision, | 45 &BackgroundSyncPermissionContextTest::TrackPermissionDecision, |
46 base::Unretained(this), run_loop.QuitClosure())); | 46 base::Unretained(this), run_loop.QuitClosure())); |
47 | 47 |
48 run_loop.Run(); | 48 run_loop.Run(); |
49 } | 49 } |
50 | 50 |
51 void TrackPermissionDecision(base::Closure done_closure, | 51 void TrackPermissionDecision(base::Closure done_closure, |
52 ContentSetting content_setting) { | 52 ContentSetting content_setting) { |
53 permission_granted_ = content_setting == CONTENT_SETTING_ALLOW; | 53 permission_granted_ = content_setting == CONTENT_SETTING_ALLOW; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 std::string(), CONTENT_SETTING_BLOCK); | 93 std::string(), CONTENT_SETTING_BLOCK); |
94 | 94 |
95 NavigateAndRequestPermission(url1, &permission_context); | 95 NavigateAndRequestPermission(url1, &permission_context); |
96 | 96 |
97 EXPECT_FALSE(permission_granted()); | 97 EXPECT_FALSE(permission_granted()); |
98 | 98 |
99 NavigateAndRequestPermission(url2, &permission_context); | 99 NavigateAndRequestPermission(url2, &permission_context); |
100 | 100 |
101 EXPECT_TRUE(permission_granted()); | 101 EXPECT_TRUE(permission_granted()); |
102 } | 102 } |
OLD | NEW |