| Index: ios/chrome/browser/ui/activity_services/activity_type_util.mm
|
| diff --git a/ios/chrome/browser/ui/activity_services/activity_type_util.mm b/ios/chrome/browser/ui/activity_services/activity_type_util.mm
|
| index 8a8378ef3f7e8d98f24e62d4a1183afd1d46f52f..41d0770666f2f771db15c1d80ef6ff8de3c5b099 100644
|
| --- a/ios/chrome/browser/ui/activity_services/activity_type_util.mm
|
| +++ b/ios/chrome/browser/ui/activity_services/activity_type_util.mm
|
| @@ -7,6 +7,7 @@
|
| #include "base/logging.h"
|
| #include "base/metrics/user_metrics.h"
|
| #include "base/metrics/user_metrics_action.h"
|
| +#include "base/strings/sys_string_conversions.h"
|
| #import "ios/chrome/browser/ui/activity_services/appex_constants.h"
|
| #import "ios/chrome/browser/ui/activity_services/print_activity.h"
|
| #include "ios/chrome/grit/ios_strings.h"
|
| @@ -17,13 +18,46 @@
|
| #endif
|
|
|
| namespace {
|
| +
|
| // A substring to identify activity strings that are from Password Management
|
| // App Extensions. This string is intentionally without the leading and
|
| // trailing "." so it can be used as a prefix, suffix, or substring of the
|
| // App Extension's bundle ID.
|
| NSString* const kFindLoginActionBundleSubstring = @"find-login-action";
|
| +
|
| +// Returns whether |activity_string| refers to a supported Password Management
|
| +// App Extension. Supported extensions are listed in kAllPasswordManagerApps.
|
| +// The |exact_match| field defines whether an exact match of bundle_id is
|
| +// required to consider activity_string a match. To add more Password Manager
|
| +// extensions, add more entries to the static array.
|
| +bool IsPasswordManagerActivity(NSString* activity_string) {
|
| + static struct {
|
| + const char* bundle_id;
|
| + bool exact_match;
|
| + } kAllPasswordManagerApps[] = {
|
| + // 1Password
|
| + {"com.agilebits.onepassword-ios.extension", true},
|
| + // LastPass
|
| + {"com.lastpass.ilastpass.LastPassExt", true},
|
| + // Dashlane
|
| + {"com.dashlane.dashlanephonefinal.", false}};
|
| +
|
| + std::string activity = base::SysNSStringToUTF8(activity_string);
|
| + for (const auto& app : kAllPasswordManagerApps) {
|
| + std::string bundle_id(app.bundle_id);
|
| + if (app.exact_match) {
|
| + if (activity == bundle_id)
|
| + return true;
|
| + } else {
|
| + if (activity.find(bundle_id) == 0)
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| }
|
|
|
| +} // namespace
|
| +
|
| namespace activity_type_util {
|
|
|
| struct PrefixTypeAssociation {
|
| @@ -60,13 +94,7 @@ const PrefixTypeAssociation prefixTypeAssociations[] = {
|
| {THIRD_PARTY_PINTEREST, @"pinterest.", false},
|
| {THIRD_PARTY_POCKET, @"com.ideashower.ReadItLaterPro.", false},
|
| {THIRD_PARTY_READABILITY, @"com.readability.ReadabilityMobile.", false},
|
| - {THIRD_PARTY_INSTAPAPER, @"com.marcoarment.instapaperpro.", false},
|
| - {APPEX_PASSWORD_MANAGEMENT_1PASSWORD,
|
| - activity_services::kAppExtensionOnePassword, true},
|
| - {APPEX_PASSWORD_MANAGEMENT_LASTPASS,
|
| - activity_services::kAppExtensionLastPass, true},
|
| - {APPEX_PASSWORD_MANAGEMENT_DASHLANE,
|
| - activity_services::kAppExtensionDashlanePrefix, false}};
|
| + {THIRD_PARTY_INSTAPAPER, @"com.marcoarment.instapaperpro.", false}};
|
|
|
| ActivityType TypeFromString(NSString* activityString) {
|
| DCHECK(activityString);
|
| @@ -75,7 +103,7 @@ ActivityType TypeFromString(NSString* activityString) {
|
| NSRange found =
|
| [activityString rangeOfString:kFindLoginActionBundleSubstring];
|
| if (found.length)
|
| - return APPEX_PASSWORD_MANAGEMENT_OTHERS;
|
| + return APPEX_PASSWORD_MANAGEMENT;
|
| for (auto const& assocation : prefixTypeAssociations) {
|
| if (assocation.requiresExactMatch_) {
|
| if ([activityString isEqualToString:assocation.prefix_])
|
| @@ -85,15 +113,15 @@ ActivityType TypeFromString(NSString* activityString) {
|
| return assocation.type_;
|
| }
|
| }
|
| + if (IsPasswordManagerActivity(activityString)) {
|
| + return APPEX_PASSWORD_MANAGEMENT;
|
| + }
|
| return UNKNOWN;
|
| }
|
|
|
| NSNumber* PasswordAppExActivityVersion(NSString* activityString) {
|
| switch (TypeFromString(activityString)) {
|
| - case APPEX_PASSWORD_MANAGEMENT_1PASSWORD:
|
| - case APPEX_PASSWORD_MANAGEMENT_LASTPASS:
|
| - case APPEX_PASSWORD_MANAGEMENT_DASHLANE:
|
| - case APPEX_PASSWORD_MANAGEMENT_OTHERS:
|
| + case APPEX_PASSWORD_MANAGEMENT:
|
| return activity_services::kPasswordAppExVersionNumber;
|
| default:
|
| return nil;
|
| @@ -111,10 +139,7 @@ NSString* CompletionMessageForActivity(ActivityType type) {
|
| switch (type) {
|
| case NATIVE_CLIPBOARD:
|
| return l10n_util::GetNSString(IDS_IOS_SHARE_TO_CLIPBOARD_SUCCESS);
|
| - case APPEX_PASSWORD_MANAGEMENT_1PASSWORD:
|
| - case APPEX_PASSWORD_MANAGEMENT_LASTPASS:
|
| - case APPEX_PASSWORD_MANAGEMENT_DASHLANE:
|
| - case APPEX_PASSWORD_MANAGEMENT_OTHERS:
|
| + case APPEX_PASSWORD_MANAGEMENT:
|
| return l10n_util::GetNSString(IDS_IOS_APPEX_PASSWORD_FORM_FILLED_SUCCESS);
|
| default:
|
| return nil;
|
| @@ -182,10 +207,7 @@ void RecordMetricForActivity(ActivityType type) {
|
| base::RecordAction(
|
| base::UserMetricsAction("MobileShareMenuToContentApp"));
|
| break;
|
| - case APPEX_PASSWORD_MANAGEMENT_1PASSWORD:
|
| - case APPEX_PASSWORD_MANAGEMENT_LASTPASS:
|
| - case APPEX_PASSWORD_MANAGEMENT_DASHLANE:
|
| - case APPEX_PASSWORD_MANAGEMENT_OTHERS:
|
| + case APPEX_PASSWORD_MANAGEMENT:
|
| base::RecordAction(
|
| base::UserMetricsAction("MobileAppExFormFilledByPasswordManager"));
|
| break;
|
|
|