Commit ebf78d7a authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Open cre "learn how" though app group

Use AppGround to open "learn how" link.

Bug: 1045455
Change-Id: Ic9c8bb4c12a51804f2d95510d401777fa576da87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2115543
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753546}
parent 13b321d9
...@@ -118,6 +118,7 @@ extern NSString* const kOpenCommandSourceTodayExtension; ...@@ -118,6 +118,7 @@ extern NSString* const kOpenCommandSourceTodayExtension;
extern NSString* const kOpenCommandSourceContentExtension; extern NSString* const kOpenCommandSourceContentExtension;
extern NSString* const kOpenCommandSourceSearchExtension; extern NSString* const kOpenCommandSourceSearchExtension;
extern NSString* const kOpenCommandSourceShareExtension; extern NSString* const kOpenCommandSourceShareExtension;
extern NSString* const kOpenCommandSourceCredentialsExtension;
// The value of the key for the sharedDefaults used by the Content Widget. // The value of the key for the sharedDefaults used by the Content Widget.
extern NSString* const kSuggestedItems; extern NSString* const kSuggestedItems;
......
...@@ -58,6 +58,8 @@ NSString* const kOpenCommandSourceTodayExtension = @"ChromeTodayExtension"; ...@@ -58,6 +58,8 @@ NSString* const kOpenCommandSourceTodayExtension = @"ChromeTodayExtension";
NSString* const kOpenCommandSourceContentExtension = @"ChromeContentExtension"; NSString* const kOpenCommandSourceContentExtension = @"ChromeContentExtension";
NSString* const kOpenCommandSourceSearchExtension = @"ChromeSearchExtension"; NSString* const kOpenCommandSourceSearchExtension = @"ChromeSearchExtension";
NSString* const kOpenCommandSourceShareExtension = @"ChromeShareExtension"; NSString* const kOpenCommandSourceShareExtension = @"ChromeShareExtension";
NSString* const kOpenCommandSourceCredentialsExtension =
@"ChromeCredentialsExtension";
NSString* const kSuggestedItems = @"SuggestedItems"; NSString* const kSuggestedItems = @"SuggestedItems";
......
...@@ -51,6 +51,7 @@ ios_appex_bundle("credential_provider_extension") { ...@@ -51,6 +51,7 @@ ios_appex_bundle("credential_provider_extension") {
deps = [ deps = [
":system_strings", ":system_strings",
"//base", "//base",
"//ios/chrome/common/app_group:command",
"//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/colors",
"//ios/chrome/common/ui/reauthentication", "//ios/chrome/common/ui/reauthentication",
"//ios/chrome/credential_provider_extension/resources", "//ios/chrome/credential_provider_extension/resources",
...@@ -68,6 +69,7 @@ ios_appex_bundle("credential_provider_extension") { ...@@ -68,6 +69,7 @@ ios_appex_bundle("credential_provider_extension") {
] ]
extra_substitutions = [ extra_substitutions = [
"CHROME_CHANNEL_SCHEME=$url_channel_scheme",
"CHROMIUM_SHORT_NAME=$chromium_short_name", "CHROMIUM_SHORT_NAME=$chromium_short_name",
"CREDENTIAL_PROVIDER_EXTENSION_BUNDLE_ID=$chromium_bundle_id.CredentialProviderExtension", "CREDENTIAL_PROVIDER_EXTENSION_BUNDLE_ID=$chromium_bundle_id.CredentialProviderExtension",
] ]
......
...@@ -32,5 +32,7 @@ ...@@ -32,5 +32,7 @@
<key>NSExtensionPointIdentifier</key> <key>NSExtensionPointIdentifier</key>
<string>com.apple.authentication-services-credential-provider-ui</string> <string>com.apple.authentication-services-credential-provider-ui</string>
</dict> </dict>
<key>KSChannelChromeScheme</key>
<string>${CHROME_CHANNEL_SCHEME}</string>
</dict> </dict>
</plist> </plist>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string> <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>
<array> <array>
<string>group.${IOS_BUNDLE_ID_PREFIX}.CredentialProvider</string> <string>group.${IOS_BUNDLE_ID_PREFIX}.chrome</string>
</array> </array>
</dict> </dict>
</plist> </plist>
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#import "base/logging.h" #import "base/logging.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "ios/chrome/common/app_group/app_group_command.h"
#import "ios/chrome/common/app_group/app_group_constants.h"
#import "ios/chrome/common/ui/reauthentication/reauthentication_module.h" #import "ios/chrome/common/ui/reauthentication/reauthentication_module.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -59,6 +61,7 @@ ...@@ -59,6 +61,7 @@
@"passcode on your device.") @"passcode on your device.")
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
__weak UIResponder* opener = [self openerFromViewController:viewController];
UIAlertAction* learnAction = [UIAlertAction UIAlertAction* learnAction = [UIAlertAction
actionWithTitle: actionWithTitle:
NSLocalizedString( NSLocalizedString(
...@@ -66,19 +69,10 @@ ...@@ -66,19 +69,10 @@
@"Learn How") @"Learn How")
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction*) { handler:^(UIAlertAction*) {
UIResponder* responder = viewController; [self openAppWithURL:[NSURL
while (responder) { URLWithString:base::SysUTF8ToNSString(
if ([responder respondsToSelector:@selector(openURL:)]) { kPasscodeArticleURL)]
[responder opener:opener];
performSelector:@selector(openURL:)
withObject:
[NSURL URLWithString:base::SysUTF8ToNSString(
kPasscodeArticleURL)]
afterDelay:0];
break;
}
responder = responder.nextResponder;
}
completionHandler(ReauthenticationResult::kFailure); completionHandler(ReauthenticationResult::kFailure);
}]; }];
[alertController addAction:learnAction]; [alertController addAction:learnAction];
...@@ -96,4 +90,34 @@ ...@@ -96,4 +90,34 @@
completion:nil]; completion:nil];
} }
#pragma mark - Private
// Returns first responder up the chain that can open a URL.
- (UIResponder*)openerFromViewController:(UIViewController*)viewController {
UIResponder* responder = viewController;
while (responder) {
if ([responder respondsToSelector:@selector(openURL:)]) {
return responder;
}
responder = responder.nextResponder;
}
return nil;
}
// Open URL through app group commands.
- (void)openAppWithURL:(NSURL*)URL opener:(UIResponder*)opener {
AppGroupCommand* command = [[AppGroupCommand alloc]
initWithSourceApp:app_group::kOpenCommandSourceCredentialsExtension
URLOpenerBlock:^(NSURL* openURL) {
if ([opener respondsToSelector:@selector(openURL:)]) {
[opener performSelector:@selector(openURL:)
withObject:openURL
afterDelay:0];
}
}];
[command prepareToOpenURL:URL];
[command executeInApp];
}
@end @end
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