| OLD | NEW |
| 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/services/gcm/push_messaging_permission_context.h" | 5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" |
| 6 #include "chrome/test/base/testing_profile.h" | 6 #include "chrome/test/base/testing_profile.h" |
| 7 #include "components/content_settings/core/browser/host_content_settings_map.h" | 7 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 8 #include "components/content_settings/core/common/content_settings.h" | 8 #include "components/content_settings/core/common/content_settings.h" |
| 9 #include "components/content_settings/core/common/content_settings_types.h" | 9 #include "components/content_settings/core/common/content_settings_types.h" |
| 10 #include "components/content_settings/core/common/permission_request_id.h" | 10 #include "components/content_settings/core/common/permission_request_id.h" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 const char kOriginA[] = "https://origina.org"; | 14 const char kOriginA[] = "https://origina.org"; |
| 15 const char kOriginB[] = "https://originb.org"; | 15 const char kOriginB[] = "https://originb.org"; |
| 16 | 16 |
| 17 namespace gcm { | |
| 18 | |
| 19 class TestPushMessagingPermissionContext | 17 class TestPushMessagingPermissionContext |
| 20 : public PushMessagingPermissionContext { | 18 : public PushMessagingPermissionContext { |
| 21 public: | 19 public: |
| 22 explicit TestPushMessagingPermissionContext(Profile* profile) | 20 explicit TestPushMessagingPermissionContext(Profile* profile) |
| 23 : PushMessagingPermissionContext(profile), | 21 : PushMessagingPermissionContext(profile), |
| 24 was_persisted_(false), | 22 was_persisted_(false), |
| 25 permission_granted_(false) {} | 23 permission_granted_(false) {} |
| 26 | 24 |
| 27 bool was_persisted() const { return was_persisted_; } | 25 bool was_persisted() const { return was_persisted_; } |
| 28 bool was_granted() const { return permission_granted_; } | 26 bool was_granted() const { return permission_granted_; } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 EXPECT_TRUE(context.was_persisted()); | 153 EXPECT_TRUE(context.was_persisted()); |
| 156 EXPECT_FALSE(context.was_granted()); | 154 EXPECT_FALSE(context.was_granted()); |
| 157 | 155 |
| 158 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 156 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
| 159 CONTENT_SETTING_ASK); | 157 CONTENT_SETTING_ASK); |
| 160 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), | 158 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), |
| 161 callback, CONTENT_SETTING_ALLOW); | 159 callback, CONTENT_SETTING_ALLOW); |
| 162 EXPECT_TRUE(context.was_persisted()); | 160 EXPECT_TRUE(context.was_persisted()); |
| 163 EXPECT_TRUE(context.was_granted()); | 161 EXPECT_TRUE(context.was_granted()); |
| 164 } | 162 } |
| 165 | |
| 166 } // namespace gcm | |
| OLD | NEW |