Commit 34fc0083 authored by Azeem Arshad's avatar Azeem Arshad Committed by Commit Bot

[WebPush] Fix silent push exception for Android Messages for Web

The ShouldSkipUserVisibleOnlyRequirements method compares messages
app url against the origin. This breaks the whitelisting since the
app is now hosted at non-root path. Fixed this by comparing the
origin of the app url.

Bug: 936285
Change-Id: I5f71017148ec34cfbb45ae0c74aeffff96b88614
Reviewed-on: https://chromium-review.googlesource.com/c/1490755Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Commit-Queue: Azeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636108}
parent e79dfb63
...@@ -339,7 +339,7 @@ bool PushMessagingNotificationManager::ShouldSkipUserVisibleOnlyRequirements( ...@@ -339,7 +339,7 @@ bool PushMessagingNotificationManager::ShouldSkipUserVisibleOnlyRequirements(
if (!app_url) if (!app_url)
app_url = chromeos::android_sms::GetAndroidMessagesURL(); app_url = chromeos::android_sms::GetAndroidMessagesURL();
if (!origin.EqualsIgnoringRef(*app_url)) if (!origin.EqualsIgnoringRef(app_url->GetOrigin()))
return false; return false;
return true; return true;
......
...@@ -56,11 +56,11 @@ TEST_F(PushMessagingNotificationManagerTest, IsTabVisibleViewSource) { ...@@ -56,11 +56,11 @@ TEST_F(PushMessagingNotificationManagerTest, IsTabVisibleViewSource) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
TEST_F(PushMessagingNotificationManagerTest, TEST_F(PushMessagingNotificationManagerTest,
SkipEnforceUserVisibleOnlyRequirementsForAndroidMessages) { SkipEnforceUserVisibleOnlyRequirementsForAndroidMessages) {
GURL origin("https://example.com"); GURL app_url("https://example.com/test/");
chromeos::android_sms::FakeAndroidSmsAppManager* chromeos::android_sms::FakeAndroidSmsAppManager*
fake_android_sms_app_manager = fake_android_sms_app_manager =
new chromeos::android_sms::FakeAndroidSmsAppManager(); new chromeos::android_sms::FakeAndroidSmsAppManager();
fake_android_sms_app_manager->SetInstalledAppUrl(origin); fake_android_sms_app_manager->SetInstalledAppUrl(app_url);
chromeos::multidevice_setup::FakeMultiDeviceSetupClient* chromeos::multidevice_setup::FakeMultiDeviceSetupClient*
fake_multidevice_setup_client = fake_multidevice_setup_client =
...@@ -75,7 +75,7 @@ TEST_F(PushMessagingNotificationManagerTest, ...@@ -75,7 +75,7 @@ TEST_F(PushMessagingNotificationManagerTest,
bool was_called = false; bool was_called = false;
manager.EnforceUserVisibleOnlyRequirements( manager.EnforceUserVisibleOnlyRequirements(
origin, 0l, app_url.GetOrigin(), 0l,
base::BindRepeating([](bool* was_called) { *was_called = true; }, base::BindRepeating([](bool* was_called) { *was_called = true; },
&was_called)); &was_called));
EXPECT_TRUE(was_called); EXPECT_TRUE(was_called);
......
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