[SendTabToSelf][ios] add the ability to pick the target device.

This uses the new showActivityServiceContextMenu to display an action
sheet with the target devices for sending tabs.

Bug: 949226
Change-Id: Ifa01d85f901d0a64dbae71114febe9224c75db62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610992
Reviewed-by: Peter Lee <pkl@chromium.org>
Reviewed-by: sebsg <sebsg@chromium.org>
Auto-Submit: Jeffrey Cohen <jeffreycohen@chromium.org>
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663289}
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd
index 13eb66f..81a9125 100644
--- a/ios/chrome/app/strings/ios_strings.grd
+++ b/ios/chrome/app/strings/ios_strings.grd
@@ -1502,6 +1502,9 @@
       <message name="IDS_IOS_SHARE_MENU_SEND_TAB_TO_SELF_ACTION" desc="Text label to the Send Tab To Self action in the extension menu that sends the current tab to the user's other devices. [iOS only]">
         Send To Your Devices
       </message>
+      <message name="IDS_IOS_SHARE_MENU_SEND_TAB_TO_SELF_DEVICE_ACTION" desc="Text label for the Send Tab To Self action sheet that chooses the device to which the current tab will be sent. [iOS only]">
+        Send <ph name="Title">$1<ex>Webpage Title</ex></ph> to one of your devices.
+      </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]">
         Sending...
       </message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARE_MENU_SEND_TAB_TO_SELF_DEVICE_ACTION.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARE_MENU_SEND_TAB_TO_SELF_DEVICE_ACTION.png.sha1
new file mode 100644
index 0000000..3ae3078
--- /dev/null
+++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARE_MENU_SEND_TAB_TO_SELF_DEVICE_ACTION.png.sha1
@@ -0,0 +1 @@
+4ddb290089c2d98e33e67adba7485c6993b74948
\ No newline at end of file
diff --git a/ios/chrome/browser/send_tab_to_self/BUILD.gn b/ios/chrome/browser/send_tab_to_self/BUILD.gn
index 9f352bd7..81cf622 100644
--- a/ios/chrome/browser/send_tab_to_self/BUILD.gn
+++ b/ios/chrome/browser/send_tab_to_self/BUILD.gn
@@ -30,6 +30,7 @@
     "//ios/chrome/browser/infobars:public",
     "//ios/chrome/browser/sync",
     "//ios/chrome/browser/tabs",
+    "//ios/chrome/browser/ui/commands",
     "//ios/chrome/browser/ui/infobars:infobars_ui",
     "//ios/chrome/browser/ui/util",
     "//ios/chrome/browser/web_state_list",
diff --git a/ios/chrome/browser/ui/activity_services/BUILD.gn b/ios/chrome/browser/ui/activity_services/BUILD.gn
index a38cf0c..8e087b2 100644
--- a/ios/chrome/browser/ui/activity_services/BUILD.gn
+++ b/ios/chrome/browser/ui/activity_services/BUILD.gn
@@ -26,6 +26,7 @@
   deps = [
     "//base",
     "//components/bookmarks/browser",
+    "//components/send_tab_to_self",
     "//components/ui_metrics",
     "//ios/chrome/app/strings",
     "//ios/chrome/browser",
@@ -35,6 +36,7 @@
     "//ios/chrome/browser/passwords",
     "//ios/chrome/browser/send_tab_to_self",
     "//ios/chrome/browser/snapshots",
+    "//ios/chrome/browser/sync",
     "//ios/chrome/browser/tabs",
     "//ios/chrome/browser/ui/activity_services/activities",
     "//ios/chrome/browser/ui/activity_services/requirements",
@@ -91,6 +93,7 @@
     "//base/test:test_support",
     "//components/bookmarks/browser",
     "//components/bookmarks/test",
+    "//components/send_tab_to_self",
     "//components/ui_metrics",
     "//ios/chrome/app/strings",
     "//ios/chrome/browser/bookmarks",
@@ -99,6 +102,7 @@
     "//ios/chrome/browser/passwords",
     "//ios/chrome/browser/snapshots",
     "//ios/chrome/browser/snapshots:test_utils",
+    "//ios/chrome/browser/sync",
     "//ios/chrome/browser/tabs",
     "//ios/chrome/browser/ui:feature_flags",
     "//ios/chrome/browser/ui/activity_services/activities",
diff --git a/ios/chrome/browser/ui/activity_services/activities/BUILD.gn b/ios/chrome/browser/ui/activity_services/activities/BUILD.gn
index f21ac4f..c46e83b 100644
--- a/ios/chrome/browser/ui/activity_services/activities/BUILD.gn
+++ b/ios/chrome/browser/ui/activity_services/activities/BUILD.gn
@@ -32,7 +32,10 @@
     "resources:activity_services_send_tab_to_self",
     "//base",
     "//ios/chrome/app/strings",
+    "//ios/chrome/browser/send_tab_to_self",
+    "//ios/chrome/browser/ui/activity_services/requirements",
     "//ios/chrome/browser/ui/commands",
+    "//ios/chrome/browser/ui/context_menu",
     "//ios/chrome/browser/ui/util",
     "//ios/web/public",
     "//ui/base",
diff --git a/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.h b/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.h
index e90fbbf..8f573fb 100644
--- a/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.h
+++ b/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.h
@@ -8,6 +8,7 @@
 #import <UIKit/UIKit.h>
 
 @protocol BrowserCommands;
+@protocol ActivityServicePresentation;
 
 // Activity that sends the tab to another of the user's devices.
 @interface SendTabToSelfActivity : UIActivity
@@ -16,8 +17,14 @@
 + (NSString*)activityIdentifier;
 
 // Initialize the send tab to self activity with the |dispatcher| that is used
-// to add the tab to the other device.
-- (instancetype)initWithDispatcher:(id<BrowserCommands>)dispatcher;
+// to add the tab to the other device, |sendTabToSelfTargets| is the list of
+// devices that will be presented to the user via |presenter| and |title|
+// represents the title of the tab being shared.
+- (instancetype)initWithDispatcher:(id<BrowserCommands>)dispatcher
+              sendTabToSelfTargets:
+                  (NSDictionary<NSString*, NSString*>*)sendTabToSelfTargets
+                         presenter:(id<ActivityServicePresentation>)presenter
+                             title:(NSString*)title;
 
 @end
 
diff --git a/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.mm b/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.mm
index 522afc7..2586791 100644
--- a/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.mm
+++ b/ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.mm
@@ -4,11 +4,15 @@
 
 #import "ios/chrome/browser/ui/activity_services/activities/send_tab_to_self_activity.h"
 
+#include "base/ios/block_types.h"
 #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/requirements/activity_service_presentation.h"
 #import "ios/chrome/browser/ui/commands/browser_commands.h"
 #import "ios/chrome/browser/ui/commands/send_tab_to_self_command.h"
+#import "ios/chrome/browser/ui/context_menu/context_menu_item.h"
 #include "ios/chrome/grit/ios_strings.h"
 #include "ui/base/l10n/l10n_util_mac.h"
 
@@ -26,20 +30,34 @@
 @interface SendTabToSelfActivity ()
 // The dispatcher that handles when the activity is performed.
 @property(nonatomic, weak, readonly) id<BrowserCommands> dispatcher;
+
+// The dictionary of target devices and their cache guids.
+@property(nonatomic, strong, readonly)
+    NSDictionary<NSString*, NSString*>* sendTabToSelfTargets;
+
+// The presenter that will present the action sheet to show devices.
+@property(nonatomic, weak, readonly) id<ActivityServicePresentation> presenter;
+
+// The title of the shared tab.
+@property(nonatomic, copy, readonly) NSString* title;
 @end
 
 @implementation SendTabToSelfActivity
 
-@synthesize dispatcher = _dispatcher;
-
 + (NSString*)activityIdentifier {
   return kSendTabToSelfActivityType;
 }
 
-- (instancetype)initWithDispatcher:(id<BrowserCommands>)dispatcher {
+- (instancetype)initWithDispatcher:(id<BrowserCommands>)dispatcher
+              sendTabToSelfTargets:
+                  (NSDictionary<NSString*, NSString*>*)sendTabToSelfTargets
+                         presenter:(id<ActivityServicePresentation>)presenter
+                             title:(NSString*)title {
   if (self = [super init]) {
-    // TODO(crbug.com/944596): Set the target device id.
+    _sendTabToSelfTargets = sendTabToSelfTargets;
     _dispatcher = dispatcher;
+    _presenter = presenter;
+    _title = [title copy];
   }
   return self;
 }
@@ -67,9 +85,27 @@
 }
 
 - (void)performActivity {
-  SendTabToSelfCommand* command =
-      [[SendTabToSelfCommand alloc] initWithTargetDeviceId:@""];
-  [_dispatcher sendTabToSelf:command];
+  NSMutableArray<ContextMenuItem*>* targetActions =
+      [NSMutableArray arrayWithCapacity:[_sendTabToSelfTargets count]];
+  __weak SendTabToSelfActivity* weakSelf = self;
+
+  for (NSString* key in _sendTabToSelfTargets) {
+    NSString* deviceId = _sendTabToSelfTargets[key];
+    ProceduralBlock action = ^{
+      SendTabToSelfActivity* strongSelf = weakSelf;
+      if (!strongSelf)
+        return;
+      SendTabToSelfCommand* command =
+          [[SendTabToSelfCommand alloc] initWithTargetDeviceId:deviceId];
+      [strongSelf->_dispatcher sendTabToSelf:command];
+    };
+    [targetActions addObject:[[ContextMenuItem alloc] initWithTitle:key
+                                                             action:action]];
+  }
+  NSString* title =
+      l10n_util::GetNSStringF(IDS_IOS_SHARE_MENU_SEND_TAB_TO_SELF_DEVICE_ACTION,
+                              base::SysNSStringToUTF16(_title));
+  [_presenter showActivityServiceContextMenu:title items:targetActions];
   [self activityDidFinish:YES];
 }
 
diff --git a/ios/chrome/browser/ui/activity_services/activity_service_controller.mm b/ios/chrome/browser/ui/activity_services/activity_service_controller.mm
index fb1129a..467e8dd 100644
--- a/ios/chrome/browser/ui/activity_services/activity_service_controller.mm
+++ b/ios/chrome/browser/ui/activity_services/activity_service_controller.mm
@@ -10,10 +10,15 @@
 #include "base/mac/foundation_util.h"
 #include "base/metrics/user_metrics.h"
 #include "base/metrics/user_metrics_action.h"
+#include "base/strings/sys_string_conversions.h"
 #include "components/bookmarks/browser/bookmark_model.h"
+#include "components/send_tab_to_self/send_tab_to_self_model.h"
+#include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
+#include "components/send_tab_to_self/target_device_info.h"
 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
 #import "ios/chrome/browser/passwords/password_form_filler.h"
 #import "ios/chrome/browser/send_tab_to_self/send_tab_to_self_util.h"
+#include "ios/chrome/browser/sync/send_tab_to_self_sync_service_factory.h"
 #import "ios/chrome/browser/ui/activity_services/activities/bookmark_activity.h"
 #import "ios/chrome/browser/ui/activity_services/activities/copy_activity.h"
 #import "ios/chrome/browser/ui/activity_services/activities/find_in_page_activity.h"
@@ -66,11 +71,13 @@
 // share to the sharing activities.
 - (NSArray*)activityItemsForData:(ShareToData*)data;
 // Returns an array of UIActivity objects that can handle the given |data|.
-- (NSArray*)applicationActivitiesForData:(ShareToData*)data
-                              dispatcher:(id<BrowserCommands>)dispatcher
-                           bookmarkModel:
-                               (bookmarks::BookmarkModel*)bookmarkModel
-                        canSendTabToSelf:(BOOL)canSendTabToSelf;
+- (NSArray*)
+    applicationActivitiesForData:(ShareToData*)data
+                      dispatcher:(id<BrowserCommands>)dispatcher
+                   bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel
+                canSendTabToSelf:(BOOL)canSendTabToSelf
+              sendTabToSelfModel:
+                  (send_tab_to_self::SendTabToSelfModel*)sendTabToSelfModel;
 // Processes |extensionItems| returned from App Extension invocation returning
 // the |activityType|. Calls shareDelegate_ with the processed returned items
 // and |result| of activity. Returns whether caller should reset UI.
@@ -150,19 +157,25 @@
 
   BOOL canSendTabToSelf =
       send_tab_to_self::ShouldOfferFeature(browserState, data.shareURL);
+
+  send_tab_to_self::SendTabToSelfModel* sendTabToSelfModel =
+      SendTabToSelfSyncServiceFactory::GetForBrowserState(browserState)
+          ->GetSendTabToSelfModel();
+
   DCHECK(!activityViewController_);
   activityViewController_ = [[UIActivityViewController alloc]
       initWithActivityItems:[self activityItemsForData:data]
-      applicationActivities:[self
-                                applicationActivitiesForData:data
-                                                  dispatcher:dispatcher
-                                               bookmarkModel:bookmarkModel
-                                            canSendTabToSelf:canSendTabToSelf]];
+      applicationActivities:
+          [self applicationActivitiesForData:data
+                                  dispatcher:dispatcher
+                               bookmarkModel:bookmarkModel
+                            canSendTabToSelf:canSendTabToSelf
+                          sendTabToSelfModel:sendTabToSelfModel]];
 
   // Reading List and Print activities refer to iOS' version of these.
-  // Chrome-specific implementations of these two activities are provided below
-  // in applicationActivitiesForData:dispatcher:bookmarkModel:
-  // The "Copy" action is also provided by chrome in order to change its icon.
+  // Chrome-specific implementations of these two activities are provided
+  // below in applicationActivitiesForData:dispatcher:bookmarkModel: The
+  // "Copy" action is also provided by chrome in order to change its icon.
   NSArray* excludedActivityTypes = @[
     UIActivityTypeAddToReadingList, UIActivityTypeCopyToPasteboard,
     UIActivityTypePrint, UIActivityTypeSaveToCameraRoll
@@ -252,20 +265,37 @@
   return activityItems;
 }
 
-- (NSArray*)applicationActivitiesForData:(ShareToData*)data
-                              dispatcher:(id<BrowserCommands>)dispatcher
-                           bookmarkModel:
-                               (bookmarks::BookmarkModel*)bookmarkModel
-                        canSendTabToSelf:(BOOL)canSendTabToSelf {
+- (NSArray*)
+    applicationActivitiesForData:(ShareToData*)data
+                      dispatcher:(id<BrowserCommands>)dispatcher
+                   bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel
+                canSendTabToSelf:(BOOL)canSendTabToSelf
+              sendTabToSelfModel:
+                  (send_tab_to_self::SendTabToSelfModel*)sendTabToSelfModel {
   NSMutableArray* applicationActivities = [NSMutableArray array];
 
   [applicationActivities
       addObject:[[CopyActivity alloc] initWithURL:data.shareURL]];
 
   if (data.shareURL.SchemeIsHTTPOrHTTPS()) {
-    if (canSendTabToSelf) {
+    if (canSendTabToSelf && sendTabToSelfModel) {
+      std::map<std::string, send_tab_to_self::TargetDeviceInfo>
+          target_device_map =
+              sendTabToSelfModel->GetTargetDeviceNameToCacheInfoMap();
+      NSMutableDictionary* sendTabToSelfTargets =
+          [[NSMutableDictionary alloc] init];
+      for (auto const& iter : target_device_map) {
+        NSString* title = base::SysUTF8ToNSString(iter.first);
+        NSString* cache_guid = base::SysUTF8ToNSString(iter.second.cache_guid);
+        sendTabToSelfTargets[title] = cache_guid;
+      }
+
       SendTabToSelfActivity* sendTabToSelfActivity =
-          [[SendTabToSelfActivity alloc] initWithDispatcher:dispatcher];
+          [[SendTabToSelfActivity alloc]
+                initWithDispatcher:dispatcher
+              sendTabToSelfTargets:sendTabToSelfTargets
+                         presenter:presentationProvider_
+                             title:data.title];
       [applicationActivities addObject:sendTabToSelfActivity];
     }
 
diff --git a/ios/chrome/browser/ui/activity_services/activity_service_controller_unittest.mm b/ios/chrome/browser/ui/activity_services/activity_service_controller_unittest.mm
index 935cf5a..afe35f4 100644
--- a/ios/chrome/browser/ui/activity_services/activity_service_controller_unittest.mm
+++ b/ios/chrome/browser/ui/activity_services/activity_service_controller_unittest.mm
@@ -11,9 +11,12 @@
 #include "components/bookmarks/browser/bookmark_model.h"
 #include "components/bookmarks/browser/bookmark_node.h"
 #include "components/bookmarks/test/bookmark_test_helpers.h"
+#include "components/send_tab_to_self/send_tab_to_self_model.h"
+#include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
 #import "ios/chrome/browser/passwords/password_form_filler.h"
+#include "ios/chrome/browser/sync/send_tab_to_self_sync_service_factory.h"
 #import "ios/chrome/browser/ui/activity_services/activities/bookmark_activity.h"
 #import "ios/chrome/browser/ui/activity_services/activities/find_in_page_activity.h"
 #import "ios/chrome/browser/ui/activity_services/activities/print_activity.h"
@@ -73,11 +76,13 @@
 
 @interface ActivityServiceController (CrVisibleForTesting)
 - (NSArray*)activityItemsForData:(ShareToData*)data;
-- (NSArray*)applicationActivitiesForData:(ShareToData*)data
-                              dispatcher:(id<BrowserCommands>)dispatcher
-                           bookmarkModel:
-                               (bookmarks::BookmarkModel*)bookmarkModel
-                        canSendTabToSelf:(BOOL)canSendTabToSelf;
+- (NSArray*)
+    applicationActivitiesForData:(ShareToData*)data
+                      dispatcher:(id<BrowserCommands>)dispatcher
+                   bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel
+                canSendTabToSelf:(BOOL)canSendTabToSelf
+              sendTabToSelfModel:
+                  (send_tab_to_self::SendTabToSelfModel*)sendTabToSelfModel;
 
 - (BOOL)processItemsReturnedFromActivity:(NSString*)activityType
                                   status:(ShareTo::ShareResult)result
@@ -186,6 +191,10 @@
     bookmark_model_ = ios::BookmarkModelFactory::GetForBrowserState(
         chrome_browser_state_.get());
     bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model_);
+    send_tab_to_self_model_ =
+        SendTabToSelfSyncServiceFactory::GetForBrowserState(
+            chrome_browser_state_.get())
+            ->GetSendTabToSelfModel();
     parentController_ =
         [[UIViewController alloc] initWithNibName:nil bundle:nil];
     [[UIApplication sharedApplication] keyWindow].rootViewController =
@@ -317,6 +326,7 @@
   ShareToData* shareData_;
   std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
   bookmarks::BookmarkModel* bookmark_model_;
+  send_tab_to_self::SendTabToSelfModel* send_tab_to_self_model_;
 };
 
 TEST_F(ActivityServiceControllerTest, PresentAndDismissController) {
@@ -536,7 +546,8 @@
       [activityController applicationActivitiesForData:data
                                             dispatcher:nil
                                          bookmarkModel:bookmark_model_
-                                      canSendTabToSelf:false];
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(5U, [items count]);
   EXPECT_TRUE(ArrayContainsObjectOfClass(items, [PrintActivity class]));
 
@@ -550,10 +561,12 @@
         isPageSearchable:YES
                userAgent:web::UserAgentType::NONE
       thumbnailGenerator:DummyThumbnailGeneratorBlock()];
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:nil
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:false];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:nil
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   EXPECT_EQ(4U, [items count]);
   EXPECT_FALSE(ArrayContainsObjectOfClass(items, [PrintActivity class]));
 }
@@ -579,7 +592,8 @@
       [activityController applicationActivitiesForData:data
                                             dispatcher:nil
                                          bookmarkModel:bookmark_model_
-                                      canSendTabToSelf:false];
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(6U, [items count]);
 
   // Verify non-HTTP URL.
@@ -591,10 +605,12 @@
                               isPageSearchable:YES
                                      userAgent:web::UserAgentType::MOBILE
                             thumbnailGenerator:DummyThumbnailGeneratorBlock()];
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:nil
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:false];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:nil
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(2U, [items count]);
 }
 
@@ -618,7 +634,8 @@
       [activityController applicationActivitiesForData:data
                                             dispatcher:nil
                                          bookmarkModel:bookmark_model_
-                                      canSendTabToSelf:false];
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(5U, [items count]);
   UIActivity* activity = [items objectAtIndex:2];
   EXPECT_EQ([BookmarkActivity class], [activity class]);
@@ -641,10 +658,12 @@
         isPageSearchable:YES
                userAgent:web::UserAgentType::NONE
       thumbnailGenerator:DummyThumbnailGeneratorBlock()];
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:nil
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:false];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:nil
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(5U, [items count]);
   activity = [items objectAtIndex:2];
   EXPECT_EQ([BookmarkActivity class], [activity class]);
@@ -677,7 +696,8 @@
       [activityController applicationActivitiesForData:data
                                             dispatcher:mockDispatcher
                                          bookmarkModel:bookmark_model_
-                                      canSendTabToSelf:false];
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(6U, [items count]);
   UIActivity* activity = [items objectAtIndex:4];
   EXPECT_EQ([RequestDesktopOrMobileSiteActivity class], [activity class]);
@@ -699,10 +719,12 @@
                             thumbnailGenerator:DummyThumbnailGeneratorBlock()];
   mockDispatcher = OCMProtocolMock(@protocol(BrowserCommands));
   OCMExpect([mockDispatcher requestMobileSite]);
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:mockDispatcher
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:false];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:mockDispatcher
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(6U, [items count]);
   activity = [items objectAtIndex:4];
   EXPECT_EQ([RequestDesktopOrMobileSiteActivity class], [activity class]);
@@ -820,7 +842,8 @@
       [activityController applicationActivitiesForData:data
                                             dispatcher:nil
                                          bookmarkModel:bookmark_model_
-                                      canSendTabToSelf:false];
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(5U, [items count]);
   EXPECT_TRUE(ArrayContainsObjectOfClass(items, [FindInPageActivity class]));
 
@@ -834,10 +857,12 @@
         isPageSearchable:NO
                userAgent:web::UserAgentType::NONE
       thumbnailGenerator:DummyThumbnailGeneratorBlock()];
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:nil
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:false];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:nil
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   EXPECT_EQ(4U, [items count]);
   EXPECT_FALSE(ArrayContainsObjectOfClass(items, [FindInPageActivity class]));
 }
@@ -863,7 +888,8 @@
       [activityController applicationActivitiesForData:data
                                             dispatcher:nil
                                          bookmarkModel:bookmark_model_
-                                      canSendTabToSelf:true];
+                                      canSendTabToSelf:true
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(6U, [items count]);
   EXPECT_TRUE(ArrayContainsObjectOfClass(items, [SendTabToSelfActivity class]));
 
@@ -882,10 +908,12 @@
                userAgent:web::UserAgentType::NONE
       thumbnailGenerator:DummyThumbnailGeneratorBlock()];
 
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:nil
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:false];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:nil
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:false
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   ASSERT_EQ(5U, [items count]);
   EXPECT_FALSE(
       ArrayContainsObjectOfClass(items, [SendTabToSelfActivity class]));
@@ -899,10 +927,12 @@
                               isPageSearchable:YES
                                      userAgent:web::UserAgentType::NONE
                             thumbnailGenerator:DummyThumbnailGeneratorBlock()];
-  items = [activityController applicationActivitiesForData:data
-                                                dispatcher:nil
-                                             bookmarkModel:bookmark_model_
-                                          canSendTabToSelf:true];
+  items =
+      [activityController applicationActivitiesForData:data
+                                            dispatcher:nil
+                                         bookmarkModel:bookmark_model_
+                                      canSendTabToSelf:true
+                                    sendTabToSelfModel:send_tab_to_self_model_];
   EXPECT_EQ(2U, [items count]);
   EXPECT_FALSE(
       ArrayContainsObjectOfClass(items, [SendTabToSelfActivity class]));