Commit dce5f169 authored by Sebastien Lalancette's avatar Sebastien Lalancette Committed by Commit Bot

[Sharing] Created Generate QR Code Share Action

Just created the action, not yet hooked up to the activity view.

Bug: 1064990
Change-Id: I3497764c910bf0fc2dc71d7859c64fa1d8e42ee8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124731Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Sebastien Lalancette <seblalancette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754583}
parent 56c3c055
...@@ -1591,6 +1591,9 @@ Handoff must also be enabled in the General section of Settings, and your device ...@@ -1591,6 +1591,9 @@ Handoff must also be enabled in the General section of Settings, and your device
<message name="IDS_IOS_SHARE_MENU_PRINT_ACTION" desc="The text label of the Print action in the extension menu that starts the printing process. [Length: 13em] [iOS only]"> <message name="IDS_IOS_SHARE_MENU_PRINT_ACTION" desc="The text label of the Print action in the extension menu that starts the printing process. [Length: 13em] [iOS only]">
Print Print
</message> </message>
<message name="IDS_IOS_SHARE_MENU_GENERATE_QR_CODE_ACTION" desc="The text label of the Share as QR Code action in the extension menu that generates and shows a QR code for the current page. [iOS only]">
Share as QR code
</message>
<message name="IDS_IOS_SHARE_MENU_READING_LIST_ACTION" desc="The text label of the Add To Reading List action in the extension menu that adds the current page to the reading list. [Length: 25em] [iOS only]"> <message name="IDS_IOS_SHARE_MENU_READING_LIST_ACTION" desc="The text label of the Add To Reading List action in the extension menu that adds the current page to the reading list. [Length: 25em] [iOS only]">
Read Later Read Later
</message> </message>
......
...@@ -11,6 +11,8 @@ source_set("activities") { ...@@ -11,6 +11,8 @@ source_set("activities") {
"copy_activity.mm", "copy_activity.mm",
"find_in_page_activity.h", "find_in_page_activity.h",
"find_in_page_activity.mm", "find_in_page_activity.mm",
"generate_qr_code_activity.h",
"generate_qr_code_activity.mm",
"print_activity.h", "print_activity.h",
"print_activity.mm", "print_activity.mm",
"reading_list_activity.h", "reading_list_activity.h",
...@@ -25,6 +27,7 @@ source_set("activities") { ...@@ -25,6 +27,7 @@ source_set("activities") {
"resources:activity_services_copy", "resources:activity_services_copy",
"resources:activity_services_edit_bookmark", "resources:activity_services_edit_bookmark",
"resources:activity_services_find_in_page", "resources:activity_services_find_in_page",
"resources:activity_services_generate_qr_code",
"resources:activity_services_print", "resources:activity_services_print",
"resources:activity_services_read_later", "resources:activity_services_read_later",
"resources:activity_services_request_desktop_site", "resources:activity_services_request_desktop_site",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_ACTIVITY_SERVICES_ACTIVITIES_GENERATE_QR_CODE_ACTIVITY_H_
#define IOS_CHROME_BROWSER_UI_ACTIVITY_SERVICES_ACTIVITIES_GENERATE_QR_CODE_ACTIVITY_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/commands/qr_generation_commands.h"
#include "url/gurl.h"
// Activity that ends up showing a QR code for the given URL.
@interface GenerateQrCodeActivity : UIActivity
// Identifier for the generate QR code activity.
+ (NSString*)activityIdentifier;
// Initializes the GenerateQrCodeActivity with the |activityURL| used to
// generate the QR code, the |title| of the page at that URL, and a |dispatcher|
// to handle the command.
- (instancetype)initWithURL:(const GURL&)activityURL
title:(NSString*)title
dispatcher:(id<QRGenerationCommands>)dispatcher
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_ACTIVITY_SERVICES_ACTIVITIES_GENERATE_QR_CODE_ACTIVITY_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/activity_services/activities/generate_qr_code_activity.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
NSString* const kGenerateQrCodeActivityType =
@"com.google.chrome.GenerateQrCodeActivityType";
} // namespace
@interface GenerateQrCodeActivity () {
GURL _activityURL;
}
@property(nonatomic, weak, readonly) NSString* title;
@property(nonatomic, weak, readonly) id<QRGenerationCommands> dispatcher;
@end
@implementation GenerateQrCodeActivity
+ (NSString*)activityIdentifier {
return kGenerateQrCodeActivityType;
}
- (instancetype)initWithURL:(const GURL&)activityURL
title:(NSString*)title
dispatcher:(id<QRGenerationCommands>)dispatcher {
if (self = [super init]) {
_activityURL = activityURL;
_title = title;
_dispatcher = dispatcher;
}
return self;
}
#pragma mark - UIActivity
- (NSString*)activityType {
return [[self class] activityIdentifier];
}
- (NSString*)activityTitle {
return l10n_util::GetNSString(IDS_IOS_SHARE_MENU_GENERATE_QR_CODE_ACTION);
}
- (UIImage*)activityImage {
return [UIImage imageNamed:@"activity_services_generate_qr_code"];
}
- (BOOL)canPerformWithActivityItems:(NSArray*)activityItems {
return YES;
}
+ (UIActivityCategory)activityCategory {
return UIActivityCategoryAction;
}
- (void)performActivity {
[self.dispatcher
generateQRCode:[[GenerateQRCodeCommand alloc] initWithURL:_activityURL
title:self.title]];
[self activityDidFinish:YES];
}
@end
...@@ -40,6 +40,15 @@ imageset("activity_services_find_in_page") { ...@@ -40,6 +40,15 @@ imageset("activity_services_find_in_page") {
] ]
} }
imageset("activity_services_generate_qr_code") {
sources = [
"activity_services_generate_qr_code.imageset/Contents.json",
"activity_services_generate_qr_code.imageset/activity_services_generate_qr_code-60@2x.png",
"activity_services_generate_qr_code.imageset/activity_services_generate_qr_code-60@3x.png",
"activity_services_generate_qr_code.imageset/activity_services_generate_qr_code-76@2x.png",
]
}
imageset("activity_services_print") { imageset("activity_services_print") {
sources = [ sources = [
"activity_services_print.imageset/Contents.json", "activity_services_print.imageset/Contents.json",
......
{
"images" : [
{
"idiom" : "iphone",
"filename" : "activity_services_generate_qr_code-60@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"filename" : "activity_services_generate_qr_code-60@3x.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"filename" : "activity_services_generate_qr_code-76@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
...@@ -43,6 +43,7 @@ enum ActivityType { ...@@ -43,6 +43,7 @@ enum ActivityType {
THIRD_PARTY_INSTAPAPER, THIRD_PARTY_INSTAPAPER,
APPEX_PASSWORD_MANAGEMENT, APPEX_PASSWORD_MANAGEMENT,
SEND_TAB_TO_SELF, SEND_TAB_TO_SELF,
GENERATE_QR_CODE,
// UNKNOWN must be the last type. // UNKNOWN must be the last type.
UNKNOWN, UNKNOWN,
}; };
......
...@@ -81,6 +81,7 @@ const PrefixTypeAssociation prefixTypeAssociations[] = { ...@@ -81,6 +81,7 @@ const PrefixTypeAssociation prefixTypeAssociations[] = {
{NATIVE_CLIPBOARD, @"com.apple.UIKit.activity.CopyToPasteboard", true}, {NATIVE_CLIPBOARD, @"com.apple.UIKit.activity.CopyToPasteboard", true},
{PRINT, @"com.google.chrome.printActivity", true}, {PRINT, @"com.google.chrome.printActivity", true},
{FIND_IN_PAGE, @"com.google.chrome.FindInPageActivityType", true}, {FIND_IN_PAGE, @"com.google.chrome.FindInPageActivityType", true},
{GENERATE_QR_CODE, @"com.google.chrome.GenerateQrCodeActivityType", true},
// The trailing '.' prevents false positives. // The trailing '.' prevents false positives.
// For instance, "com.viberific" won't be matched by the "com.viber.". // For instance, "com.viberific" won't be matched by the "com.viber.".
{GOOGLE_DRIVE, @"com.google.Drive.", false}, {GOOGLE_DRIVE, @"com.google.Drive.", false},
...@@ -229,6 +230,10 @@ void RecordMetricForActivity(ActivityType type) { ...@@ -229,6 +230,10 @@ void RecordMetricForActivity(ActivityType type) {
base::RecordAction( base::RecordAction(
base::UserMetricsAction("MobileShareMenuSendTabToSelf")); base::UserMetricsAction("MobileShareMenuSendTabToSelf"));
break; break;
case GENERATE_QR_CODE:
base::RecordAction(
base::UserMetricsAction("MobileShareMenuGenerateQRCode"));
break;
} }
} }
......
...@@ -13785,6 +13785,13 @@ should be able to be added at any place in this file. ...@@ -13785,6 +13785,13 @@ should be able to be added at any place in this file.
</description> </description>
</action> </action>
<action name="MobileShareMenuGenerateQRCode">
<owner>seblalancette@chromium.org</owner>
<description>
The user pressed the generate QR code option from the share action menu.
</description>
</action>
<action name="MobileShareMenuReadLater"> <action name="MobileShareMenuReadLater">
<owner>gambard@chromium.org</owner> <owner>gambard@chromium.org</owner>
<description>User shared to the device's Reading List.</description> <description>User shared to the device's Reading List.</description>
......
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