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 "chrome/browser/notifications/notification_permission_context.h" | 5 #include "chrome/browser/notifications/notification_permission_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/test/scoped_mock_time_message_loop_task_runner.h" | 9 #include "base/test/scoped_mock_time_message_loop_task_runner.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 ContentSetting GetContentSettingFromMap(const GURL& url_a, | 50 ContentSetting GetContentSettingFromMap(const GURL& url_a, |
51 const GURL& url_b) { | 51 const GURL& url_b) { |
52 return HostContentSettingsMapFactory::GetForProfile(profile()) | 52 return HostContentSettingsMapFactory::GetForProfile(profile()) |
53 ->GetContentSetting(url_a.GetOrigin(), url_b.GetOrigin(), | 53 ->GetContentSetting(url_a.GetOrigin(), url_b.GetOrigin(), |
54 content_settings_type(), std::string()); | 54 content_settings_type(), std::string()); |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 // NotificationPermissionContext: | 58 // NotificationPermissionContext: |
59 void NotifyPermissionSet(const PermissionRequestID& id, | 59 void NotifyPermissionSet(content::WebContents* web_contents, |
| 60 const PermissionRequestID& id, |
60 const GURL& requesting_origin, | 61 const GURL& requesting_origin, |
61 const GURL& embedder_origin, | 62 const GURL& embedder_origin, |
62 const BrowserPermissionCallback& callback, | 63 const BrowserPermissionCallback& callback, |
63 bool persist, | 64 bool persist, |
64 ContentSetting content_setting) override { | 65 ContentSetting content_setting) override { |
65 permission_set_count_++; | 66 permission_set_count_++; |
66 last_permission_set_persisted_ = persist; | 67 last_permission_set_persisted_ = persist; |
67 last_permission_set_setting_ = content_setting; | 68 last_permission_set_setting_ = content_setting; |
68 NotificationPermissionContext::NotifyPermissionSet( | 69 NotificationPermissionContext::NotifyPermissionSet( |
69 id, requesting_origin, embedder_origin, callback, persist, | 70 web_contents, id, requesting_origin, embedder_origin, callback, persist, |
70 content_setting); | 71 content_setting); |
71 } | 72 } |
72 | 73 |
73 int permission_set_count_; | 74 int permission_set_count_; |
74 bool last_permission_set_persisted_; | 75 bool last_permission_set_persisted_; |
75 ContentSetting last_permission_set_setting_; | 76 ContentSetting last_permission_set_setting_; |
76 }; | 77 }; |
77 | 78 |
78 } // namespace | 79 } // namespace |
79 | 80 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // After another 2.5 seconds, the second permission request should also have | 351 // After another 2.5 seconds, the second permission request should also have |
351 // received a response. | 352 // received a response. |
352 task_runner->FastForwardBy(base::TimeDelta::FromMilliseconds(2500)); | 353 task_runner->FastForwardBy(base::TimeDelta::FromMilliseconds(2500)); |
353 EXPECT_EQ(2, permission_context.permission_set_count()); | 354 EXPECT_EQ(2, permission_context.permission_set_count()); |
354 EXPECT_TRUE(permission_context.last_permission_set_persisted()); | 355 EXPECT_TRUE(permission_context.last_permission_set_persisted()); |
355 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 356 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
356 permission_context.last_permission_set_setting()); | 357 permission_context.last_permission_set_setting()); |
357 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 358 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
358 permission_context.GetContentSettingFromMap(url, url)); | 359 permission_context.GetContentSettingFromMap(url, url)); |
359 } | 360 } |
OLD | NEW |