Skip to content

Commit ab28842

Browse files
Rafał GodlewskiChromium LUCI CQ
authored andcommitted
[iOS] Handle app launch for credential exchange import
On high-level this CL adds handling Bling being launched by the OS to perform import in the credential exchange flow (triggered by exporting the data in a different credential manager app). More important highlights: * Adds new user activity handling in user_activity_browser_agent for the ASCredentialExchangeActivity type, protected by a compile time flag * Extracts UUID from the user activity, which is a token passed by the OS and required to access the credential data * Adds new command for handling the start of the import flow * Adds a skeleton of coordinator / mediator which will be responsible for faciliting the import flow (view controller will be added later) * Adds new Swift class responsible for communicating with the OS import API (available only in Swift) * Adds skeleton of a credential importer class, responsible for owning the Swift class and in later patches - for translating the received Swift data into C++ structs used by storage layer For now, the code only handles the app being launched and passing the received UUID all the way to the Swift class, which in turn uses it to access credential data. Importing the data will be implemented in the follow-up patches. Bug: 444111277 Change-Id: Ic37a1562cce73ed17e9b2d74da77a5e206eaf540 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6938606 Reviewed-by: Mark Cogan <[email protected]> Commit-Queue: Rafał Godlewski <[email protected]> Cr-Commit-Position: refs/heads/main@{#1516450}
1 parent f57cc21 commit ab28842

20 files changed

+307
-2
lines changed

ios/chrome/app/app_startup_parameters.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum TabOpeningPostOpeningAction {
4949
ADD_READING_LIST_ITEMS,
5050
EXTERNAL_ACTION_SHOW_BROWSER_SETTINGS,
5151
START_LENS_FROM_SHARE_EXTENSION,
52+
CREDENTIAL_EXCHANGE_IMPORT,
5253
};
5354

5455
// Represents the status of a request to change the application mode.
@@ -100,6 +101,9 @@ class GURL;
100101
@property(nonatomic, readwrite, copy) NSString* textQuery;
101102
// Data for UIImage for image query that should be executed on startup.
102103
@property(nonatomic, readwrite, strong) NSData* imageSearchData;
104+
// Token received from the OS during the app launch for the credential exchange
105+
// import, needed to be passed back to the OS to receive the credential data.
106+
@property(nonatomic, readwrite, copy) NSUUID* credentialExchangeImportUUID;
103107
// Boolean to track if the app is open in an user unexpected mode.
104108
// When a certain enterprise policy has been set, it's possible that one browser
105109
// mode is disabled. When the user intends to open an unavailable mode of

ios/chrome/app/app_startup_parameters.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ - (BOOL)isValidPostOpeningAction:(TabOpeningPostOpeningAction)action {
237237
case SHOW_DEFAULT_BROWSER_SETTINGS:
238238
case EXTERNAL_ACTION_SHOW_BROWSER_SETTINGS:
239239
case SEARCH_PASSWORDS:
240+
case CREDENTIAL_EXCHANGE_IMPORT:
240241
return YES;
241242

242243
// Lens action are valid on empty URLs, in addition to

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ source_set("ui_bundled") {
298298
"//ios/chrome/browser/web/model/font_size",
299299
"//ios/chrome/browser/web/model/print",
300300
"//ios/chrome/browser/web_state_list/model/web_usage_enabler",
301+
"//ios/chrome/browser/webauthn/coordinator",
301302
"//ios/chrome/browser/webui/model",
302303
"//ios/chrome/browser/webui/ui_bundled:coordinator",
303304
"//ios/chrome/browser/whats_new/coordinator",

ios/chrome/browser/browser_view/ui_bundled/DEPS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ include_rules = [
129129
"+ios/chrome/browser/voice/ui_bundled",
130130
"+ios/chrome/browser/web/model",
131131
"+ios/chrome/browser/web_state_list/model",
132+
"+ios/chrome/browser/webauthn/coordinator",
132133
"+ios/chrome/browser/webui",
133134
"+ios/chrome/browser/whats_new/coordinator",
134135
"+ios/chrome/browser/window_activities/model/window_activity_helpers.h",

ios/chrome/browser/browser_view/ui_bundled/browser_coordinator.mm

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
#import "ios/chrome/browser/shared/public/commands/contextual_panel_entrypoint_iph_commands.h"
233233
#import "ios/chrome/browser/shared/public/commands/contextual_sheet_commands.h"
234234
#import "ios/chrome/browser/shared/public/commands/country_code_picker_commands.h"
235+
#import "ios/chrome/browser/shared/public/commands/credential_exchange_commands.h"
235236
#import "ios/chrome/browser/shared/public/commands/download_list_commands.h"
236237
#import "ios/chrome/browser/shared/public/commands/drive_file_picker_commands.h"
237238
#import "ios/chrome/browser/shared/public/commands/enhanced_calendar_commands.h"
@@ -332,6 +333,7 @@
332333
#import "ios/chrome/browser/web/model/web_state_delegate_browser_agent.h"
333334
#import "ios/chrome/browser/web_state_list/model/web_usage_enabler/web_usage_enabler_browser_agent.h"
334335
#import "ios/chrome/browser/web_state_list/model/web_usage_enabler/web_usage_enabler_browser_agent_observer_bridge.h"
336+
#import "ios/chrome/browser/webauthn/coordinator/credential_import_coordinator.h"
335337
#import "ios/chrome/browser/webui/model/net_export_tab_helper_delegate.h"
336338
#import "ios/chrome/browser/webui/ui_bundled/net_export_coordinator.h"
337339
#import "ios/chrome/browser/whats_new/coordinator/whats_new_coordinator.h"
@@ -373,6 +375,7 @@ @interface BrowserCoordinator () <
373375
ContextualPanelEntrypointIPHCommands,
374376
ContextualSheetCommands,
375377
CountryCodePickerCommands,
378+
CredentialExchangeCommands,
376379
DefaultBrowserGenericPromoCommands,
377380
DefaultPromoNonModalPresentationDelegate,
378381
DownloadListCommands,
@@ -741,6 +744,9 @@ @implementation BrowserCoordinator {
741744

742745
// The coordinator for the Welcome Back promo.
743746
WelcomeBackCoordinator* _welcomeBackCoordinator;
747+
748+
// The coordinator for the Credential Exchange feature handling the import.
749+
CredentialImportCoordinator* _credentialImportCoordinator;
744750
}
745751

746752
#pragma mark - ReaderModeBrowserAgentDelegate
@@ -1212,7 +1218,8 @@ - (void)createViewControllerDependencies {
12121218
@protocol(CountryCodePickerCommands),
12131219
@protocol(WhatsNewCommands),
12141220
@protocol(GoogleOneCommands),
1215-
@protocol(WelcomeBackPromoCommands)
1221+
@protocol(WelcomeBackPromoCommands),
1222+
@protocol(CredentialExchangeCommands),
12161223
];
12171224

12181225
for (Protocol* protocol in protocols) {
@@ -1786,6 +1793,9 @@ - (void)stopChildCoordinators {
17861793
[_BWGCoordinator stop];
17871794
_BWGCoordinator = nil;
17881795

1796+
[_credentialImportCoordinator stop];
1797+
_credentialImportCoordinator = nil;
1798+
17891799
[self hideDriveFilePicker];
17901800
[self hideContextualSheet];
17911801
[self dismissEditAddressBottomSheet];
@@ -3103,6 +3113,16 @@ - (void)hideCountryCodePicker {
31033113
_countryCodePickerCoordinator = nil;
31043114
}
31053115

3116+
#pragma mark - CredentialExchangeCommands
3117+
3118+
- (void)showCredentialExchangeImport:(NSUUID*)UUID {
3119+
_credentialImportCoordinator = [[CredentialImportCoordinator alloc]
3120+
initWithBaseViewController:self.viewController
3121+
browser:self.browser
3122+
UUID:UUID];
3123+
[_credentialImportCoordinator start];
3124+
}
3125+
31063126
#pragma mark - BWGCommands
31073127

31083128
- (void)startBWGFlowWithEntryPoint:(bwg::EntryPoint)entryPoint {

ios/chrome/browser/intents/model/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ source_set("user_activity_browser_agent") {
5050
"//ios/chrome/app/profile",
5151
"//ios/chrome/app/spotlight",
5252
"//ios/chrome/app/startup:startup_basic",
53+
"//ios/chrome/browser/credential_provider/model:features",
5354
"//ios/chrome/browser/intents/model:intent_type",
5455
"//ios/chrome/browser/lens/ui_bundled:lens_availability",
5556
"//ios/chrome/browser/lens/ui_bundled:lens_entrypoint",
@@ -63,6 +64,7 @@ source_set("user_activity_browser_agent") {
6364
"//ios/chrome/browser/shared/public/features",
6465
"//ios/chrome/browser/url_loading/model",
6566
"//ios/chrome/browser/url_loading/model:url_loading_params_header",
67+
"//ios/chrome/browser/webauthn/model:credential_import_manager_swift",
6668
"//ios/chrome/common/intents:intents_generate_source",
6769
"//ui/base",
6870
"//url",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
include_rules = [
2+
"+ios/chrome/browser/credential_provider/model/features.h",
3+
"+ios/chrome/browser/lens",
24
"+ios/chrome/browser/metrics/model",
35
"+ios/chrome/browser/policy/model",
46
"+ios/chrome/browser/search_engines/model",
57
"+ios/chrome/browser/shared/coordinator/scene",
68
"+ios/chrome/browser/url_loading/model",
7-
"+ios/chrome/browser/lens",
9+
"+ios/chrome/browser/webauthn/model",
810
]

ios/chrome/browser/intents/model/user_activity_browser_agent.mm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#import "ios/chrome/app/spotlight/actions_spotlight_manager.h"
2727
#import "ios/chrome/app/spotlight/spotlight_util.h"
2828
#import "ios/chrome/app/startup/app_launch_metrics.h"
29+
#import "ios/chrome/browser/credential_provider/model/features.h"
2930
#import "ios/chrome/browser/intents/model/intent_type.h"
3031
#import "ios/chrome/browser/intents/model/intents_constants.h"
3132
#import "ios/chrome/browser/lens/ui_bundled/lens_availability.h"
@@ -47,6 +48,7 @@
4748
#import "ios/chrome/browser/shared/public/features/features.h"
4849
#import "ios/chrome/browser/url_loading/model/image_search_param_generator.h"
4950
#import "ios/chrome/browser/url_loading/model/url_loading_params.h"
51+
#import "ios/chrome/browser/webauthn/model/credential_import_manager_swift.h"
5052
#import "ios/chrome/common/intents/AddBookmarkToChromeIntent.h"
5153
#import "ios/chrome/common/intents/AddReadingListItemToChromeIntent.h"
5254
#import "ios/chrome/common/intents/OpenInChromeIncognitoIntent.h"
@@ -128,6 +130,17 @@ bool IsProfileStateReady(Browser* browser) {
128130
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
129131
NSURL* webpage_url = user_activity.webpageURL;
130132

133+
// Credential exchange activity should only be handled in iOS 26 with the
134+
// compile-time flag controlling the feature enabled.
135+
BOOL isCredentialExchangeActivity = NO;
136+
if (@available(iOS 26, *)) {
137+
isCredentialExchangeActivity =
138+
CredentialExchangeEnabled() &&
139+
[user_activity.activityType
140+
isEqualToString:[CredentialImportManager
141+
credentialExchangeActivity]];
142+
}
143+
131144
if ([user_activity.activityType
132145
isEqualToString:handoff::kChromeHandoffActivityType] ||
133146
[user_activity.activityType
@@ -487,6 +500,24 @@ GURL webpage_GURL(
487500
[connection_information_
488501
setStartupParameters:StartupParametersForOpeningNewTab(
489502
OPEN_CLEAR_BROWSING_DATA_DIALOG)];
503+
} else if (isCredentialExchangeActivity) {
504+
id UUID;
505+
if (@available(iOS 26, *)) {
506+
UUID = [user_activity.userInfo
507+
objectForKey:[CredentialImportManager credentialImportToken]];
508+
}
509+
if (![UUID isKindOfClass:[NSUUID class]]) {
510+
return NO;
511+
}
512+
513+
AppStartupParameters* startup_params = [[AppStartupParameters alloc]
514+
initWithExternalURL:GURL()
515+
completeURL:GURL()
516+
applicationMode:ApplicationModeForTabOpening::NORMAL
517+
forceApplicationMode:NO];
518+
startup_params.postOpeningAction = CREDENTIAL_EXCHANGE_IMPORT;
519+
startup_params.credentialExchangeImportUUID = (NSUUID*)UUID;
520+
[connection_information_ setStartupParameters:startup_params];
490521
} else {
491522
// Do nothing for unknown activity type.
492523
return NO;

ios/chrome/browser/shared/coordinator/scene/scene_controller.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
#import "ios/chrome/browser/shared/public/commands/browser_commands.h"
165165
#import "ios/chrome/browser/shared/public/commands/browser_coordinator_commands.h"
166166
#import "ios/chrome/browser/shared/public/commands/command_dispatcher.h"
167+
#import "ios/chrome/browser/shared/public/commands/credential_exchange_commands.h"
167168
#import "ios/chrome/browser/shared/public/commands/lens_commands.h"
168169
#import "ios/chrome/browser/shared/public/commands/omnibox_commands.h"
169170
#import "ios/chrome/browser/shared/public/commands/open_lens_input_selection_command.h"
@@ -3203,6 +3204,10 @@ - (ProceduralBlock)completionBlockForTriggeringAction:
32033204
return ^{
32043205
[weakSelf searchShareExtensionImageWithLens];
32053206
};
3207+
case CREDENTIAL_EXCHANGE_IMPORT:
3208+
return ^{
3209+
[weakSelf importCredentials];
3210+
};
32063211
default:
32073212
return nil;
32083213
}
@@ -3418,6 +3423,15 @@ - (void)addReadingListItems:(NSArray<NSURL*>*)URLs {
34183423
readingListBrowserAgent->BulkAddURLsToReadingListWithViewSnackbar(URLs);
34193424
}
34203425

3426+
- (void)importCredentials {
3427+
id<CredentialExchangeCommands> credentialExchangeCommands =
3428+
HandlerForProtocol(self.currentInterface.browser->GetCommandDispatcher(),
3429+
CredentialExchangeCommands);
3430+
[credentialExchangeCommands
3431+
showCredentialExchangeImport:self.startupParameters
3432+
.credentialExchangeImportUUID];
3433+
}
3434+
34213435
#pragma mark - TabOpening implementation.
34223436

34233437
- (void)dismissModalsAndMaybeOpenSelectedTabInMode:

ios/chrome/browser/shared/public/commands/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ source_set("commands") {
2424
"contextual_panel_entrypoint_iph_commands.h",
2525
"contextual_sheet_commands.h",
2626
"country_code_picker_commands.h",
27+
"credential_exchange_commands.h",
2728
"credential_provider_promo_commands.h",
2829
"docking_promo_commands.h",
2930
"download_list_commands.h",

0 commit comments

Comments
 (0)