Content-Length: 822422 | pFad | http://github.com/chromium/chromium/commit/#start-of-content

68B5F216 [iOS] Change all Default Browser settings entry points to Default Apps · chromium/chromium@30b4681 · GitHub
Skip to content

Commit 30b4681

Browse files
guillaumejenkinsChromium LUCI CQ
authored andcommitted
[iOS] Change all Default Browser settings entry points to Default Apps
Updates all Default Browser-related promos of all types to send users to the Default Apps page in iOS settings rather than to Chromium- specific settings, if the current device supports it (iOS 18.3+). Also updates the Experimental Settings plist to clean up outdated forced promos to display that aren't available anymore, and to add promos that weren't there yet. Bug: 440049578 Change-Id: I6fc82bc15f295407948b54f5527c5a2199a544e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6897046 Reviewed-by: Gauthier Ambard <gambard@chromium.org> Commit-Queue: Guillaume Jenkins <gujen@google.com> Cr-Commit-Position: refs/heads/main@{#1509274}
1 parent b8550fd commit 30b4681

20 files changed

+204
-109
lines changed

ios/chrome/app/resources/Settings.bundle/Experimental.plist

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,27 @@
182182
<string></string>
183183
<string>promos_manager::Promo::AppStoreRating</string>
184184
<string>promos_manager::Promo::DefaultBrowser</string>
185+
<string>promos_manager::Promo::DefaultBrowserRemindMeLater</string>
186+
<string>promos_manager::Promo::AllTabsDefaultBrowser</string>
187+
<string>promos_manager::Promo::MadeForIOSDefaultBrowser</string>
188+
<string>promos_manager::Promo::StaySafeDefaultBrowser</string>
189+
<string>promos_manager::Promo::DefaultBrowserOffCycle</string>
185190
<string>promos_manager::Promo::PostRestoreDefaultBrowserAlert</string>
186-
<string>promos_manager::Promo::OmniboxPosition</string>
187191
<string>promos_manager::Promo::DockingPromo</string>
188-
<string>promos_manager::Promo::PostDefaultAbandonment</string>
189192
<string>promos_manager::Promo::BWGPromo</string>
190193
</array>
191194
<key>Titles</key>
192195
<array>
193196
<string>Disabled (No Promos Forced)</string>
194197
<string>App Store Rating</string>
195198
<string>Default Browser</string>
199+
<string>Default Browser Reminder</string>
200+
<string>Default Browser "All Tabs" version</string>
201+
<string>Default Browser "Made for iOS" version</string>
202+
<string>Default Browser "Stay safe" version</string>
203+
<string>Default Browser off-cycle version</string>
196204
<string>Post Restore Default Browser Alert</string>
197-
<string>Omnibox Position</string>
198205
<string>Docking Promo</string>
199-
<string>Post-Default Browser Abandonment Alert</string>
200206
<string>BWG Promo</string>
201207
</array>
202208
</dict>

ios/chrome/browser/content_suggestions/ui_bundled/set_up_list/set_up_list_default_browser_promo_coordinator.mm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ - (void)didTapPrimaryActionButton {
9090
RecordAction(UserMetricsAction("IOS.DefaultBrowserPromo.SetUpList.Accepted"));
9191
[self logDefaultBrowserFullscreenPromoHistogramForAction:
9292
IOSDefaultBrowserPromoAction::kActionButton];
93-
[_application openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
94-
options:{}
95-
completionHandler:nil];
93+
94+
OpenIOSDefaultBrowserSettingsPage(/*force_default_apps_if_available=*/false,
95+
_application);
96+
9697
_markItemComplete = YES;
9798
[self.delegate setUpListDefaultBrowserPromoDidFinish:YES];
9899
}

ios/chrome/browser/content_suggestions/ui_bundled/set_up_list/set_up_list_default_browser_promo_coordinator_unittest.mm

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "ios/chrome/browser/shared/model/application_context/application_context.h"
1818
#import "ios/chrome/browser/shared/model/browser/test/test_browser.h"
1919
#import "ios/chrome/browser/shared/model/profile/test/test_profile_ios.h"
20+
#import "ios/chrome/browser/shared/public/features/features.h"
2021
#import "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
2122
#import "ios/web/public/test/web_task_environment.h"
2223
#import "testing/platform_test.h"
@@ -88,10 +89,16 @@ void WaitForItemCompletePref() {
8889
[coordinator_ start];
8990

9091
OCMExpect([delegate_ setUpListDefaultBrowserPromoDidFinish:YES]);
91-
OCMExpect([mock_application_
92-
openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
93-
options:{}
94-
completionHandler:nil]);
92+
93+
NSURL* url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
94+
if (@available(iOS 18.3, *)) {
95+
if (IsDefaultAppsDestinationAvailable() &&
96+
IsUseDefaultAppsDestinationForPromosEnabled()) {
97+
url = [NSURL
98+
URLWithString:UIApplicationOpenDefaultApplicationsSettingsURLString];
99+
}
100+
}
101+
OCMExpect([mock_application_ openURL:url options:{} completionHandler:nil]);
95102
[coordinator_ didTapPrimaryActionButton];
96103
[delegate_ verify];
97104

ios/chrome/browser/default_browser/model/utils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,14 @@ NSDate* LastTimeUserInteractedWithNonModalPromo();
429429
// Promo was presented.
430430
std::optional<IOSDefaultBrowserPromoAction> DefaultBrowserPromoLastAction();
431431

432+
// Opens the appropriate iOS settings to set Chromium as default browser. If
433+
// the relevant feature flags are enabled or if
434+
// `force_default_apps_if_available` is set to true, the new Default Apps page
435+
// will be used as the destination if the device supports it. Otherwise, the
436+
// Chromium settings will be used. The second parameter is to facilitate mocking
437+
// in unit testing.
438+
void OpenIOSDefaultBrowserSettingsPage(
439+
bool force_default_apps_if_available = false,
440+
UIApplication* ui_application_to_use = nil);
441+
432442
#endif // IOS_CHROME_BROWSER_DEFAULT_BROWSER_MODEL_UTILS_H_

ios/chrome/browser/default_browser/model/utils.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,3 +1028,20 @@ void RecordDefaultBrowserPromoLastAction(IOSDefaultBrowserPromoAction action) {
10281028
return GetObjectFromStorageForKey<NSDate>(
10291029
kLastTimeUserInteractedWithNonModalPromo);
10301030
}
1031+
1032+
void OpenIOSDefaultBrowserSettingsPage(bool force_default_apps_if_available,
1033+
UIApplication* ui_application_to_use) {
1034+
NSURL* url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
1035+
if (@available(iOS 18.3, *)) {
1036+
if (IsDefaultAppsDestinationAvailable() &&
1037+
(force_default_apps_if_available ||
1038+
IsUseDefaultAppsDestinationForPromosEnabled())) {
1039+
url = [NSURL
1040+
URLWithString:UIApplicationOpenDefaultApplicationsSettingsURLString];
1041+
}
1042+
}
1043+
if (!ui_application_to_use) {
1044+
ui_application_to_use = [UIApplication sharedApplication];
1045+
}
1046+
[ui_application_to_use openURL:url options:{} completionHandler:nil];
1047+
}

ios/chrome/browser/default_promo/ui_bundled/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ source_set("coordinator") {
2929
"//ios/chrome/browser/promos_manager/model:constants",
3030
"//ios/chrome/browser/promos_manager/model:types",
3131
"//ios/chrome/browser/promos_manager/ui_bundled:promos",
32+
"//ios/chrome/browser/shared/public/features",
3233
"//ios/chrome/browser/shared/ui/util",
3334
"//ios/chrome/common/ui/colors",
3435
"//ios/chrome/common/ui/confirmation_alert",

ios/chrome/browser/default_promo/ui_bundled/base_default_browser_promo_view_provider.mm

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ - (void)standardPromoPrimaryAction {
7777
IOSDefaultBrowserPromoAction::kActionButton);
7878
LogUserInteractionWithTailoredFullscreenPromo();
7979

80-
[self openSettings];
80+
OpenIOSDefaultBrowserSettingsPage();
8181
[self dissmissPromo];
8282
}
8383

@@ -122,13 +122,6 @@ - (ConfirmationAlertViewController*)viewController {
122122
}
123123

124124
#pragma mark - Private
125-
// Open settings.
126-
- (void)openSettings {
127-
[[UIApplication sharedApplication]
128-
openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
129-
options:{}
130-
completionHandler:nil];
131-
}
132125

133126
// Show learn more view.
134127
- (void)showLearnMoreView {

ios/chrome/browser/default_promo/ui_bundled/default_browser_instructions_view_controller.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#import "base/check.h"
88
#import "base/i18n/rtl.h"
9+
#import "ios/chrome/browser/shared/public/features/features.h"
910
#import "ios/chrome/browser/shared/ui/util/uikit_ui_util.h"
1011
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
1112
#import "ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h"
@@ -76,6 +77,8 @@ - (instancetype)initWithDismissButton:(BOOL)hasDismissButton
7677
(id<ConfirmationAlertActionHandler>)actionHandler
7778
titleText:(NSString*)titleText {
7879
if ((self = [super init])) {
80+
useDefaultAppsDestination |= IsDefaultAppsDestinationAvailable() &&
81+
IsUseDefaultAppsDestinationForPromosEnabled();
7982
[self addVideoSection:useDefaultAppsDestination];
8083
[self addInformationSectionWithDismissButton:hasDismissButton
8184
hasRemindMeLater:hasRemindMeLater

ios/chrome/browser/default_promo/ui_bundled/generic/default_browser_generic_promo_mediator.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
// The mediator for the generic default browser promo.
1111
@interface DefaultBrowserGenericPromoMediator : NSObject
1212

13-
// Handles user tap on primary action. Sends the user to the iOS settings.
14-
- (void)didTapPrimaryActionButton;
15-
1613
// Handles user tap on primary action. Sends the user to the iOS settings. If
17-
// `useDefaultAppsDestination` is set to YES, the user is sent to the Default
18-
// Apps settings page. If set to NO, or the device is running iOS 18.2 or older,
19-
// then the user is sent to the current app's iOS settings page.
14+
// `useDefaultAppsDestination` is set to YES, and the current device supports
15+
// it, the user is sent to the Default Apps settings page rather than the
16+
// Chromium settings.
2017
- (void)didTapPrimaryActionButton:(BOOL)useDefaultAppsDestination;
2118

2219
@end

ios/chrome/browser/default_promo/ui_bundled/generic/default_browser_generic_promo_mediator.mm

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,15 @@
44

55
#import "ios/chrome/browser/default_promo/ui_bundled/generic/default_browser_generic_promo_mediator.h"
66

7-
#import "ios/chrome/browser/shared/public/features/features.h"
7+
#import "ios/chrome/browser/default_browser/model/utils.h"
88
#import "ui/base/l10n/l10n_util_mac.h"
99

1010
@implementation DefaultBrowserGenericPromoMediator
1111

1212
#pragma mark - Public
1313

14-
- (void)didTapPrimaryActionButton {
15-
[self didTapPrimaryActionButton:/*useDefaultAppsDestination=*/NO];
16-
}
17-
1814
- (void)didTapPrimaryActionButton:(BOOL)useDefaultAppsDestination {
19-
NSURL* url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
20-
#if defined(__IPHONE_18_3) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_18_3
21-
if (@available(iOS 18.3, *)) {
22-
if (useDefaultAppsDestination) {
23-
url = [NSURL
24-
URLWithString:UIApplicationOpenDefaultApplicationsSettingsURLString];
25-
}
26-
}
27-
#endif
28-
[[UIApplication sharedApplication] openURL:url
29-
options:{}
30-
completionHandler:nil];
15+
OpenIOSDefaultBrowserSettingsPage(useDefaultAppsDestination);
3116
}
3217

3318
@end

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/chromium/chromium/commit/#start-of-content

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy