Commit 77bdb41a authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update OffTheRecord profile APIs in notifications.

Profile API is being updated (issue 1033903) and the usage of
GetOffTheRecordProfile and HasOffTheRecordProfile without argument is
getting deprecated. Use cases of this call that ONLY refer to incognito
or guest mode can use [Get/Has]PrimaryOTRProfile() instead.

c/b/notifications/* are updated to use the new API.

Bug: 1060940
Change-Id: Ic815443fe5d7f3781578813abf4be7470128690b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210982
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771675}
parent 99c42a07
...@@ -326,7 +326,7 @@ TEST_F(NotificationPermissionContextTest, SecureOriginRequirement) { ...@@ -326,7 +326,7 @@ TEST_F(NotificationPermissionContextTest, SecureOriginRequirement) {
// Tests auto-denial after a time delay in incognito. // Tests auto-denial after a time delay in incognito.
TEST_F(NotificationPermissionContextTest, TestDenyInIncognitoAfterDelay) { TEST_F(NotificationPermissionContextTest, TestDenyInIncognitoAfterDelay) {
TestNotificationPermissionContext permission_context( TestNotificationPermissionContext permission_context(
profile()->GetOffTheRecordProfile()); profile()->GetPrimaryOTRProfile());
GURL url("https://www.example.com"); GURL url("https://www.example.com");
NavigateAndCommit(url); NavigateAndCommit(url);
...@@ -392,7 +392,7 @@ TEST_F(NotificationPermissionContextTest, TestDenyInIncognitoAfterDelay) { ...@@ -392,7 +392,7 @@ TEST_F(NotificationPermissionContextTest, TestDenyInIncognitoAfterDelay) {
// Tests how multiple parallel permission requests get auto-denied in incognito. // Tests how multiple parallel permission requests get auto-denied in incognito.
TEST_F(NotificationPermissionContextTest, TestParallelDenyInIncognito) { TEST_F(NotificationPermissionContextTest, TestParallelDenyInIncognito) {
TestNotificationPermissionContext permission_context( TestNotificationPermissionContext permission_context(
profile()->GetOffTheRecordProfile()); profile()->GetPrimaryOTRProfile());
GURL url("https://www.example.com"); GURL url("https://www.example.com");
NavigateAndCommit(url); NavigateAndCommit(url);
web_contents()->WasShown(); web_contents()->WasShown();
......
...@@ -396,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, GetDisplayed) { ...@@ -396,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, GetDisplayed) {
{ {
base::RunLoop run_loop; base::RunLoop run_loop;
bridge->GetDisplayed( bridge->GetDisplayed(
profile1->GetOffTheRecordProfile(), profile1->GetPrimaryOTRProfile(),
base::BindOnce( base::BindOnce(
&NotificationPlatformBridgeWinUITest::DisplayedNotifications, &NotificationPlatformBridgeWinUITest::DisplayedNotifications,
base::Unretained(this), run_loop.QuitClosure())); base::Unretained(this), run_loop.QuitClosure()));
...@@ -422,7 +422,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, GetDisplayed) { ...@@ -422,7 +422,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, GetDisplayed) {
{ {
base::RunLoop run_loop; base::RunLoop run_loop;
bridge->GetDisplayed( bridge->GetDisplayed(
profile2->GetOffTheRecordProfile(), profile2->GetPrimaryOTRProfile(),
base::BindOnce( base::BindOnce(
&NotificationPlatformBridgeWinUITest::DisplayedNotifications, &NotificationPlatformBridgeWinUITest::DisplayedNotifications,
base::Unretained(this), run_loop.QuitClosure())); base::Unretained(this), run_loop.QuitClosure()));
......
...@@ -75,10 +75,14 @@ void NotificationTriggerScheduler::TriggerNotifications() { ...@@ -75,10 +75,14 @@ void NotificationTriggerScheduler::TriggerNotifications() {
auto profiles = g_browser_process->profile_manager()->GetLoadedProfiles(); auto profiles = g_browser_process->profile_manager()->GetLoadedProfiles();
for (Profile* profile : profiles) { for (Profile* profile : profiles) {
TriggerNotificationsForProfile(profile); TriggerNotificationsForProfile(profile);
// Notifications are technically not supported in Incognito, but in case we // Notifications are technically not supported in OffTheRecord, but in case
// ever change that lets handle these profiles too. // weever change that lets handle these profiles too.
if (profile->HasOffTheRecordProfile()) if (profile->HasAnyOffTheRecordProfile()) {
TriggerNotificationsForProfile(profile->GetOffTheRecordProfile()); std::vector<Profile*> otr_profiles =
profile->GetAllOffTheRecordProfiles();
for (Profile* otr : otr_profiles)
TriggerNotificationsForProfile(otr);
}
} }
} }
......
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