Commit 0d02a04d authored by Andy Paicu's avatar Andy Paicu Committed by Commit Bot

Removed unnecessary notification permission logic

Since permission delegation is enabled by default and the flag is soon
to be entirely removed, this CL removes specific notification permission
logic that pre-dates permission delegation.

The CL should be a no-op except for file origins which currently have
issues in the permission architecture (see towards the end of
crbug.com/444047).

Bug: 995457
Change-Id: I9d502b4ffbb18789b07ef5c336714aba5c05157f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315692Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791387}
parent a03dd6dd
......@@ -262,13 +262,6 @@ ContentSetting NotificationPermissionContext::GetPermissionStatusForExtension(
}
#endif
void NotificationPermissionContext::ResetPermission(
const GURL& requesting_origin,
const GURL& embedder_origin) {
UpdatePermission(browser_context(), requesting_origin,
CONTENT_SETTING_DEFAULT);
}
void NotificationPermissionContext::DecidePermission(
content::WebContents* web_contents,
const permissions::PermissionRequestID& id,
......@@ -316,20 +309,6 @@ void NotificationPermissionContext::DecidePermission(
std::move(callback));
}
// Unlike other permission types, granting a notification for a given origin
// will not take into account the |embedder_origin|, it will only be based
// on the requesting iframe origin.
// TODO(mukai) Consider why notifications behave differently than
// other permissions. https://crbug.com/416894
void NotificationPermissionContext::UpdateContentSetting(
const GURL& requesting_origin,
const GURL& embedder_origin,
ContentSetting content_setting) {
DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
content_setting == CONTENT_SETTING_BLOCK);
UpdatePermission(browser_context(), requesting_origin, content_setting);
}
bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const {
return true;
}
......@@ -99,8 +99,6 @@ class NotificationPermissionContext
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
const GURL& embedding_origin) const override;
void ResetPermission(const GURL& requesting_origin,
const GURL& embedder_origin) override;
private:
FRIEND_TEST_ALL_PREFIXES(NotificationPermissionContextTest,
......@@ -122,9 +120,6 @@ class NotificationPermissionContext
const GURL& embedding_origin,
bool user_gesture,
permissions::BrowserPermissionCallback callback) override;
void UpdateContentSetting(const GURL& requesting_origin,
const GURL& embedder_origin,
ContentSetting content_setting) override;
bool IsRestrictedToSecureOrigins() const override;
base::WeakPtrFactory<NotificationPermissionContext> weak_factory_ui_thread_{
......
......@@ -680,53 +680,6 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
->service_worker_scope);
}
IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
CheckFilePermissionNotGranted) {
// This case should succeed because a normal page URL is used.
std::string script_result;
permissions::PermissionManager* permission_manager =
PermissionManagerFactory::GetForProfile(browser()->profile());
EXPECT_EQ(CONTENT_SETTING_ASK,
permission_manager
->GetPermissionStatus(ContentSettingsType::NOTIFICATIONS,
TestPageUrl(), TestPageUrl())
.content_setting);
RequestAndAcceptPermission();
EXPECT_EQ(CONTENT_SETTING_ALLOW,
permission_manager
->GetPermissionStatus(ContentSettingsType::NOTIFICATIONS,
TestPageUrl(), TestPageUrl())
.content_setting);
// This case should fail because a file URL is used.
base::FilePath dir_source_root;
EXPECT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root));
base::FilePath full_file_path =
dir_source_root.Append(server_root_).AppendASCII(kTestFileName);
GURL file_url(net::FilePathToFileURL(full_file_path));
ui_test_utils::NavigateToURL(browser(), file_url);
EXPECT_EQ(CONTENT_SETTING_ASK,
permission_manager
->GetPermissionStatus(ContentSettingsType::NOTIFICATIONS,
file_url, file_url)
.content_setting);
RequestAndAcceptPermission();
EXPECT_EQ(CONTENT_SETTING_ASK,
permission_manager
->GetPermissionStatus(ContentSettingsType::NOTIFICATIONS,
file_url, file_url)
.content_setting)
<< "If this test fails, you may have fixed a bug preventing file origins "
<< "from sending their origin from Blink; if so you need to update the "
<< "display function for notification origins to show the file path.";
}
IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
DataUrlAsNotificationImage) {
GrantNotificationPermissionForTest();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment