Commit 60f3921e authored by Jeffrey Cohen's avatar Jeffrey Cohen Committed by Commit Bot

[SendTabToSelf][ios] add device name to send confirmation

Bug: 986536
Change-Id: Idcdd36bfe4db04422c12629a7252aae479819671
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715744Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680484}
parent 87b4e357
...@@ -1506,7 +1506,7 @@ Handoff must also be enabled in the General section of Settings, and your device ...@@ -1506,7 +1506,7 @@ Handoff must also be enabled in the General section of Settings, and your device
Send To Your Devices Send To Your Devices
</message> </message>
<message name="IDS_IOS_SEND_TAB_TO_SELF_SNACKBAR_MESSAGE" desc="Message briefly displayed at the bottom of the screen to the user to inform that the tab is being sent to the target device. [Length: 35em]" meaning="The is being sent to the target device. [Length: 35em]"> <message name="IDS_IOS_SEND_TAB_TO_SELF_SNACKBAR_MESSAGE" desc="Message briefly displayed at the bottom of the screen to the user to inform that the tab is being sent to the target device. [Length: 35em]" meaning="The is being sent to the target device. [Length: 35em]">
Sending... Sending to <ph name="DEVICE_NAME">$1<ex>IPhone</ex></ph>...
</message> </message>
<message name="IDS_IOS_SEND_TAB_TO_SELF_TARGET_DEVICE_ACTION" desc="Button label for the Send Tab To Self modal dialog that sends the current tab to a user's other device. [iOS only]"> <message name="IDS_IOS_SEND_TAB_TO_SELF_TARGET_DEVICE_ACTION" desc="Button label for the Send Tab To Self modal dialog that sends the current tab to a user's other device. [iOS only]">
Send To Your Device Send To Your Device
......
...@@ -747,7 +747,8 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -747,7 +747,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Send Tab To Self // Send Tab To Self
// ---------------- // ----------------
// Sends the current tab to the target device. // Sends the current tab to the target device.
- (void)sendTabToSelfTargetDeviceID:(NSString*)targetDeviceID; - (void)sendTabToSelfTargetDeviceID:(NSString*)targetDeviceID
targetDeviceName:(NSString*)targetDeviceName;
@end @end
...@@ -2896,14 +2897,16 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -2896,14 +2897,16 @@ NSString* const kBrowserViewControllerSnackbarCategory =
#pragma mark - Private Methods: Send Tab To Self #pragma mark - Private Methods: Send Tab To Self
- (void)sendTabToSelfTargetDeviceID:(NSString*)targetDeviceID { - (void)sendTabToSelfTargetDeviceID:(NSString*)targetDeviceID
targetDeviceName:(NSString*)targetDeviceName {
send_tab_to_self::CreateNewEntry(_browserState, targetDeviceID); send_tab_to_self::CreateNewEntry(_browserState, targetDeviceID);
[self.dispatcher triggerToolsMenuButtonAnimation]; [self.dispatcher triggerToolsMenuButtonAnimation];
TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess); TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess);
[self showSnackbar:l10n_util::GetNSString( [self showSnackbar:l10n_util::GetNSStringF(
IDS_IOS_SEND_TAB_TO_SELF_SNACKBAR_MESSAGE)]; IDS_IOS_SEND_TAB_TO_SELF_SNACKBAR_MESSAGE,
base::SysNSStringToUTF16(targetDeviceName))];
} }
#pragma mark - ** Protocol Implementations and Helpers ** #pragma mark - ** Protocol Implementations and Helpers **
...@@ -4388,7 +4391,8 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -4388,7 +4391,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
} }
- (void)sendTabToSelf:(SendTabToSelfCommand*)command { - (void)sendTabToSelf:(SendTabToSelfCommand*)command {
[self sendTabToSelfTargetDeviceID:[command targetDeviceID]]; [self sendTabToSelfTargetDeviceID:[command targetDeviceID]
targetDeviceName:[command targetDeviceName]];
} }
#pragma mark - FindInPageResponseDelegate #pragma mark - FindInPageResponseDelegate
......
...@@ -10,10 +10,12 @@ ...@@ -10,10 +10,12 @@
@interface SendTabToSelfCommand : NSObject @interface SendTabToSelfCommand : NSObject
@property(copy, nonatomic, readonly) NSString* targetDeviceID; @property(copy, nonatomic, readonly) NSString* targetDeviceID;
@property(copy, nonatomic, readonly) NSString* targetDeviceName;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithTargetDeviceID:(NSString*)targetDeviceID - (instancetype)initWithTargetDeviceID:(NSString*)targetDeviceID
targetDeviceName:(NSString*)targetDeviceName
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
@end @end
......
...@@ -11,10 +11,13 @@ ...@@ -11,10 +11,13 @@
@implementation SendTabToSelfCommand @implementation SendTabToSelfCommand
@synthesize targetDeviceID = _targetDeviceID; @synthesize targetDeviceID = _targetDeviceID;
@synthesize targetDeviceName = _targetDeviceName;
- (instancetype)initWithTargetDeviceID:(NSString*)targetDeviceID { - (instancetype)initWithTargetDeviceID:(NSString*)targetDeviceID
targetDeviceName:(NSString*)targetDeviceName {
if (self = [super init]) { if (self = [super init]) {
_targetDeviceID = [targetDeviceID copy]; _targetDeviceID = [targetDeviceID copy];
_targetDeviceName = [targetDeviceName copy];
} }
return self; return self;
} }
......
...@@ -105,10 +105,12 @@ ...@@ -105,10 +105,12 @@
[self stop]; [self stop];
} }
- (void)sendTabToTargetDeviceCacheGUID:(NSString*)cacheGUID { - (void)sendTabToTargetDeviceCacheGUID:(NSString*)cacheGUID
targetDeviceName:(NSString*)deviceName {
// TODO(crbug.com/970284) log histogram of send event. // TODO(crbug.com/970284) log histogram of send event.
SendTabToSelfCommand* command = SendTabToSelfCommand* command =
[[SendTabToSelfCommand alloc] initWithTargetDeviceID:cacheGUID]; [[SendTabToSelfCommand alloc] initWithTargetDeviceID:cacheGUID
targetDeviceName:deviceName];
[self.dispatcher sendTabToSelf:command]; [self.dispatcher sendTabToSelf:command];
[self stop]; [self stop];
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
completion:(void (^)())completion; completion:(void (^)())completion;
// Asks the delegate to send the current tab to the device with |cacheGuid|. // Asks the delegate to send the current tab to the device with |cacheGuid|.
- (void)sendTabToTargetDeviceCacheGUID:(NSString*)cacheGuid; - (void)sendTabToTargetDeviceCacheGUID:(NSString*)cacheGuid
targetDeviceName:(NSString*)deviceName;
@end @end
......
...@@ -236,7 +236,8 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -236,7 +236,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)sendTabWhenPressed:(UIButton*)sender { - (void)sendTabWhenPressed:(UIButton*)sender {
base::UmaHistogramEnumeration(kClickResultHistogramName, base::UmaHistogramEnumeration(kClickResultHistogramName,
SendTabToSelfClickResult::kClickItem); SendTabToSelfClickResult::kClickItem);
[self.delegate sendTabToTargetDeviceCacheGUID:self.selectedItem.cacheGuid]; [self.delegate sendTabToTargetDeviceCacheGUID:self.selectedItem.cacheGuid
targetDeviceName:self.selectedItem.text];
[self.delegate dismissViewControllerAnimated:YES completion:nil]; [self.delegate dismissViewControllerAnimated:YES completion:nil];
} }
......
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