Peter Kotwicz | 90c0dc22 | 2022-03-09 18:24:45 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/webid/federated_identity_api_permission_context.h" |
| 6 | |
Nicolás Peña Moreno | 0c974faf | 2022-03-10 16:05:12 | [diff] [blame^] | 7 | #include "chrome/browser/content_settings/cookie_settings_factory.h" |
Peter Kotwicz | 90c0dc22 | 2022-03-09 18:24:45 | [diff] [blame] | 8 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
Nicolás Peña Moreno | 0c974faf | 2022-03-10 16:05:12 | [diff] [blame^] | 9 | #include "chrome/browser/profiles/profile.h" |
Peter Kotwicz | 90c0dc22 | 2022-03-09 18:24:45 | [diff] [blame] | 10 | #include "components/content_settings/core/common/content_settings_types.h" |
| 11 | |
| 12 | FederatedIdentityApiPermissionContext::FederatedIdentityApiPermissionContext( |
| 13 | content::BrowserContext* browser_context) |
| 14 | : host_content_settings_map_( |
Nicolás Peña Moreno | 0c974faf | 2022-03-10 16:05:12 | [diff] [blame^] | 15 | HostContentSettingsMapFactory::GetForProfile(browser_context)), |
| 16 | cookie_settings_(CookieSettingsFactory::GetForProfile( |
| 17 | Profile::FromBrowserContext(browser_context))) {} |
Peter Kotwicz | 90c0dc22 | 2022-03-09 18:24:45 | [diff] [blame] | 18 | |
| 19 | FederatedIdentityApiPermissionContext:: |
| 20 | ~FederatedIdentityApiPermissionContext() = default; |
| 21 | |
| 22 | bool FederatedIdentityApiPermissionContext::HasApiPermission() { |
| 23 | return host_content_settings_map_->GetDefaultContentSetting( |
| 24 | ContentSettingsType::FEDERATED_IDENTITY_API, nullptr) != |
| 25 | ContentSetting::CONTENT_SETTING_BLOCK; |
| 26 | } |
Nicolás Peña Moreno | 0c974faf | 2022-03-10 16:05:12 | [diff] [blame^] | 27 | |
| 28 | bool FederatedIdentityApiPermissionContext::AreThirdPartyCookiesBlocked() { |
| 29 | return cookie_settings_->ShouldBlockThirdPartyCookies(); |
| 30 | } |