1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/permissions/permissions_client.h"
7 #include "base/functional/callback.h"
8 #include "build/build_config.h"
9 #include "build/chromeos_buildflags.h"
10 #include "components/permissions/permission_request_enums.h"
11 #include "components/permissions/permission_uma_util.h"
12 #include "content/public/browser/web_contents.h"
14 #if !BUILDFLAG(IS_ANDROID)
15 #include "ui/gfx/paint_vector_icon.h"
18 namespace permissions {
20 PermissionsClient* g_client = nullptr;
23 PermissionsClient::PermissionsClient() {
28 PermissionsClient::~PermissionsClient() {
33 PermissionsClient* PermissionsClient::Get() {
38 double PermissionsClient::GetSiteEngagementScore(
39 content::BrowserContext* browser_context,
44 void PermissionsClient::AreSitesImportant(
45 content::BrowserContext* browser_context,
46 std::vector<std::pair<url::Origin, bool>>* origins) {
47 for (auto& entry : *origins)
51 #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH)
52 bool PermissionsClient::IsCookieDeletionDisabled(
53 content::BrowserContext* browser_context,
59 void PermissionsClient::GetUkmSourceId(content::BrowserContext* browser_context,
60 content::WebContents* web_contents,
61 const GURL& requesting_origin,
62 GetUkmSourceIdCallback callback) {
63 std::move(callback).Run(absl::nullopt);
66 IconId PermissionsClient::GetOverrideIconId(RequestType request_type) {
67 #if BUILDFLAG(IS_ANDROID)
70 return gfx::kNoneIcon;
74 std::vector<std::unique_ptr<PermissionUiSelector>>
75 PermissionsClient::CreatePermissionUiSelectors(
76 content::BrowserContext* browser_context) {
77 return std::vector<std::unique_ptr<PermissionUiSelector>>();
80 #if !BUILDFLAG(IS_ANDROID)
81 void PermissionsClient::TriggerPromptHatsSurveyIfEnabled(
82 content::BrowserContext* context,
83 permissions::RequestType request_type,
84 absl::optional<permissions::PermissionAction> action,
85 permissions::PermissionPromptDisposition prompt_disposition,
86 permissions::PermissionPromptDispositionReason prompt_disposition_reason,
87 permissions::PermissionRequestGestureType gesture_type,
88 absl::optional<base::TimeDelta> prompt_display_duration,
91 base::OnceCallback<void()> hats_shown_callback_) {}
94 void PermissionsClient::OnPromptResolved(
95 RequestType request_type,
96 PermissionAction action,
98 PermissionPromptDisposition prompt_disposition,
99 PermissionPromptDispositionReason prompt_disposition_reason,
100 PermissionRequestGestureType gesture_type,
101 absl::optional<QuietUiReason> quiet_ui_reason,
102 base::TimeDelta prompt_display_duration,
103 content::WebContents* web_contents) {}
106 PermissionsClient::HadThreeConsecutiveNotificationPermissionDenies(
107 content::BrowserContext* browser_context) {
108 return absl::nullopt;
111 absl::optional<url::Origin> PermissionsClient::GetAutoApprovalOrigin() {
112 return absl::nullopt;
115 absl::optional<bool> PermissionsClient::HasPreviouslyAutoRevokedPermission(
116 content::BrowserContext* browser_context,
118 ContentSettingsType permission) {
119 return absl::nullopt;
122 bool PermissionsClient::CanBypassEmbeddingOriginCheck(
123 const GURL& requesting_origin,
124 const GURL& embedding_origin) {
128 absl::optional<GURL> PermissionsClient::OverrideCanonicalOrigin(
129 const GURL& requesting_origin,
130 const GURL& embedding_origin) {
131 return absl::nullopt;
134 bool PermissionsClient::DoURLsMatchNewTabPage(const GURL& requesting_origin,
135 const GURL& embedding_origin) {
139 permissions::PermissionIgnoredReason PermissionsClient::DetermineIgnoreReason(
140 content::WebContents* web_contents) {
141 return permissions::PermissionIgnoredReason::UNKNOWN;
144 #if BUILDFLAG(IS_ANDROID)
145 bool PermissionsClient::IsDseOrigin(content::BrowserContext* browser_context,
146 const url::Origin& origin) {
150 infobars::InfoBarManager* PermissionsClient::GetInfoBarManager(
151 content::WebContents* web_contents) {
155 infobars::InfoBar* PermissionsClient::MaybeCreateInfoBar(
156 content::WebContents* web_contents,
157 ContentSettingsType type,
158 base::WeakPtr<PermissionPromptAndroid> prompt) {
162 std::unique_ptr<PermissionsClient::PermissionMessageDelegate>
163 PermissionsClient::MaybeCreateMessageUI(
164 content::WebContents* web_contents,
165 ContentSettingsType type,
166 base::WeakPtr<PermissionPromptAndroid> prompt) {
170 void PermissionsClient::RepromptForAndroidPermissions(
171 content::WebContents* web_contents,
172 const std::vector<ContentSettingsType>& content_settings_types,
173 const std::vector<ContentSettingsType>& filtered_content_settings_types,
174 const std::vector<std::string>& required_permissions,
175 const std::vector<std::string>& optional_permissions,
176 PermissionsUpdatedCallback callback) {
177 std::move(callback).Run(false);
180 int PermissionsClient::MapToJavaDrawableId(int resource_id) {
184 std::unique_ptr<PermissionPrompt> PermissionsClient::CreatePrompt(
185 content::WebContents* web_contents,
186 PermissionPrompt::Delegate* delegate) {
191 bool PermissionsClient::HasDevicePermission(ContentSettingsType type) const {
195 bool PermissionsClient::CanRequestDevicePermission(
196 ContentSettingsType type) const {
200 favicon::FaviconService* PermissionsClient::GetFaviconService(
201 content::BrowserContext* browser_context) {
205 } // namespace permissions