Commit f4fb6aa2 authored by Sébastien Séguin-Gagnon's avatar Sébastien Séguin-Gagnon Committed by Commit Bot

[SendTabToSelf] Fix bug that prevented sending tabs on iOS.

Fixes a weakSelf lifetime issue in the target device sheet that
prevented the sending of the tab after the user selected a device.

Bug: 949226
Change-Id: Icda0279baea3bc524d36fbcc4d363a455d29d933
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635412
Commit-Queue: sebsg <sebsg@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Auto-Submit: sebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664825}
parent d3e80539
...@@ -87,17 +87,15 @@ NSString* const kSendTabToSelfActivityType = ...@@ -87,17 +87,15 @@ NSString* const kSendTabToSelfActivityType =
- (void)performActivity { - (void)performActivity {
NSMutableArray<ContextMenuItem*>* targetActions = NSMutableArray<ContextMenuItem*>* targetActions =
[NSMutableArray arrayWithCapacity:[_sendTabToSelfTargets count]]; [NSMutableArray arrayWithCapacity:[_sendTabToSelfTargets count]];
__weak SendTabToSelfActivity* weakSelf = self;
for (NSString* key in _sendTabToSelfTargets) { for (NSString* key in _sendTabToSelfTargets) {
NSString* deviceId = _sendTabToSelfTargets[key]; NSString* deviceId = _sendTabToSelfTargets[key];
// Retain |self| here since a |weakSelf| would be deallocated when
// displaying the target device sheet, as the ActivitySheet will be gone.
ProceduralBlock action = ^{ ProceduralBlock action = ^{
SendTabToSelfActivity* strongSelf = weakSelf;
if (!strongSelf)
return;
SendTabToSelfCommand* command = SendTabToSelfCommand* command =
[[SendTabToSelfCommand alloc] initWithTargetDeviceId:deviceId]; [[SendTabToSelfCommand alloc] initWithTargetDeviceId:deviceId];
[strongSelf->_dispatcher sendTabToSelf:command]; [self.dispatcher sendTabToSelf:command];
}; };
[targetActions addObject:[[ContextMenuItem alloc] initWithTitle:key [targetActions addObject:[[ContextMenuItem alloc] initWithTitle:key
action:action]]; action:action]];
......
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