Commit 713aa3d8 authored by Ewann's avatar Ewann Committed by Commit Bot

[iOS] Adds Recent Tabs context menu in Tab Grid

This Cl moves the implementation of the RecentTabsMenuProvider protocol
in a separate helper.
This helper is used to create context menu from the recent tabs and the
tab grid coordinator.

Bug: 1093302
Change-Id: I7c78adc6eded30f749b9a2dec8d159306452588a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351974Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarSebastien Lalancette <seblalancette@chromium.org>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798609}
parent 3f4619b6
......@@ -11,6 +11,8 @@ source_set("recent_tabs") {
"recent_tabs_coordinator.mm",
"recent_tabs_mediator.h",
"recent_tabs_mediator.mm",
"recent_tabs_menu_helper.h",
"recent_tabs_menu_helper.mm",
"synced_sessions_bridge.h",
"synced_sessions_bridge.mm",
]
......
......@@ -6,7 +6,6 @@
#include "base/ios/block_types.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
......@@ -17,6 +16,7 @@
#import "ios/chrome/browser/ui/menu/action_factory.h"
#import "ios/chrome/browser/ui/menu/menu_histograms.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_mediator.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_menu_helper.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_menu_provider.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_presentation_delegate.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.h"
......@@ -27,18 +27,14 @@
#import "ios/chrome/browser/ui/table_view/feature_flags.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h"
#import "ios/chrome/browser/ui/util/multi_window_support.h"
#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface RecentTabsCoordinator () <RecentTabsMenuProvider,
@interface RecentTabsCoordinator () <RecentTabsContextMenuDelegate,
RecentTabsPresentationDelegate>
// Completion block called once the recentTabsViewController is dismissed.
@property(nonatomic, copy) ProceduralBlock completion;
......@@ -51,9 +47,9 @@
RecentTabsTransitioningDelegate* recentTabsTransitioningDelegate;
@property(nonatomic, strong)
RecentTabsTableViewController* recentTabsTableViewController;
@property(nonatomic, strong) SharingCoordinator* sharingCoordinator;
@property(nonatomic, strong)
RecentTabsContextMenuHelper* recentTabsContextMenuHelper;
@end
@implementation RecentTabsCoordinator
......@@ -75,7 +71,12 @@
self.recentTabsTableViewController.presentationDelegate = self;
if (@available(iOS 13.0, *)) {
self.recentTabsTableViewController.menuProvider = self;
self.recentTabsContextMenuHelper =
[[RecentTabsContextMenuHelper alloc] initWithBrowser:self.browser
recentTabsPresentationDelegate:self
recentTabsContextMenuDelegate:self];
self.recentTabsTableViewController.menuProvider =
self.recentTabsContextMenuHelper;
}
// Adds the "Done" button and hooks it up to |stop|.
......@@ -145,6 +146,9 @@
dismissViewControllerAnimated:YES
completion:self.completion];
self.recentTabsNavigationController = nil;
self.recentTabsContextMenuHelper = nil;
[self.sharingCoordinator stop];
self.sharingCoordinator = nil;
self.recentTabsTransitioningDelegate = nil;
[self.mediator disconnect];
}
......@@ -154,33 +158,6 @@
[self stop];
}
#pragma mark - Private
// Opens all tabs from the given |sectionIdentifier|.
- (void)openAllTabsFromSessionSectionIdentitifer:(NSInteger)sectionIdentifier {
synced_sessions::DistantSession const* session =
[self.recentTabsTableViewController
sessionForSectionIdentifier:sectionIdentifier];
[self openAllTabsFromSession:session];
}
// Triggers the URL sharing flow for the given |URL| and |title|, with the
// origin |view| representing the UI component for that URL.
- (void)shareURL:(const GURL&)URL
title:(NSString*)title
fromView:(UIView*)view {
ActivityParams* params =
[[ActivityParams alloc] initWithURL:URL
title:title
scenario:ActivityScenario::RecentTabsEntry];
self.sharingCoordinator = [[SharingCoordinator alloc]
initWithBaseViewController:self.recentTabsTableViewController
browser:self.browser
params:params
originView:view];
[self.sharingCoordinator start];
}
#pragma mark - RecentTabsPresentationDelegate
- (void)openAllTabsFromSession:(const synced_sessions::DistantSession*)session {
......@@ -226,120 +203,32 @@
[self stop];
}
#pragma mark - RecentTabsMenuProvider
- (UIContextMenuConfiguration*)contextMenuConfigurationForItem:
(TableViewURLItem*)item
fromView:(UIView*)view
API_AVAILABLE(ios(13.0)) {
__weak __typeof(self) weakSelf = self;
UIContextMenuActionProvider actionProvider = ^(
NSArray<UIMenuElement*>* suggestedActions) {
if (!weakSelf) {
// Return an empty menu.
return [UIMenu menuWithTitle:@"" children:@[]];
}
RecentTabsCoordinator* strongSelf = weakSelf;
// Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::kRecentTabsEntry);
ActionFactory* actionFactory =
[[ActionFactory alloc] initWithBrowser:strongSelf.browser
scenario:MenuScenario::kRecentTabsEntry];
NSMutableArray<UIMenuElement*>* menuElements =
[[NSMutableArray alloc] init];
[menuElements addObject:[actionFactory actionToOpenInNewTabWithURL:item.URL
completion:^{
[strongSelf stop];
}]];
[menuElements
addObject:[actionFactory actionToOpenInNewIncognitoTabWithURL:item.URL
completion:^{
[strongSelf stop];
}]];
if (IsMultipleScenesSupported()) {
[menuElements
addObject:
[actionFactory
actionToOpenInNewWindowWithURL:item.URL
activityOrigin:WindowActivityRecentTabsOrigin
completion:^{
[strongSelf stop];
}]];
}
[menuElements addObject:[actionFactory actionToCopyURL:item.URL]];
[menuElements addObject:[actionFactory actionToShareWithBlock:^{
[strongSelf shareURL:item.URL
title:item.title
fromView:view];
}]];
return [UIMenu menuWithTitle:@"" children:menuElements];
};
#pragma mark - RecentTabsContextMenuDelegate
return
[UIContextMenuConfiguration configurationWithIdentifier:nil
previewProvider:nil
actionProvider:actionProvider];
- (void)shareURL:(const GURL&)URL
title:(NSString*)title
fromView:(UIView*)view {
ActivityParams* params =
[[ActivityParams alloc] initWithURL:URL
title:title
scenario:ActivityScenario::RecentTabsEntry];
self.sharingCoordinator = [[SharingCoordinator alloc]
initWithBaseViewController:self.recentTabsTableViewController
browser:self.browser
params:params
originView:view];
[self.sharingCoordinator start];
}
- (UIContextMenuConfiguration*)
contextMenuConfigurationForHeaderWithSectionIdentifier:
(NSInteger)sectionIdentifier API_AVAILABLE(ios(13.0)) {
__weak __typeof(self) weakSelf = self;
UIContextMenuActionProvider actionProvider =
^(NSArray<UIMenuElement*>* suggestedActions) {
if (!weakSelf || ![weakSelf.recentTabsTableViewController
isSessionSectionIdentifier:sectionIdentifier]) {
// Return an empty menu.
return [UIMenu menuWithTitle:@"" children:@[]];
}
// Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::kRecentTabsHeader);
ActionFactory* actionFactory = [[ActionFactory alloc]
initWithBrowser:weakSelf.browser
scenario:MenuScenario::kRecentTabsHeader];
NSMutableArray<UIMenuElement*>* menuElements =
[[NSMutableArray alloc] init];
synced_sessions::DistantSession const* session =
[weakSelf.recentTabsTableViewController
sessionForSectionIdentifier:sectionIdentifier];
if (!session->tabs.empty()) {
[menuElements
addObject:[actionFactory actionToOpenAllTabsWithBlock:^{
[weakSelf
openAllTabsFromSessionSectionIdentitifer:sectionIdentifier];
}]];
}
[menuElements
addObject:[actionFactory actionToHideWithBlock:^{
[weakSelf.recentTabsTableViewController
- (void)removeSessionAtSessionSectionIdentifier:(NSInteger)sectionIdentifier {
[self.recentTabsTableViewController
removeSessionAtSessionSectionIdentifier:sectionIdentifier];
}]];
return [UIMenu menuWithTitle:@"" children:menuElements];
};
}
return
[UIContextMenuConfiguration configurationWithIdentifier:nil
previewProvider:nil
actionProvider:actionProvider];
- (synced_sessions::DistantSession const*)sessionForSectionIdentifier:
(NSInteger)sectionIdentifier {
return [self.recentTabsTableViewController
sessionForSectionIdentifier:sectionIdentifier];
}
@end
// 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_RECENT_TABS_RECENT_TABS_MENU_HELPER_H_
#define IOS_CHROME_BROWSER_UI_RECENT_TABS_RECENT_TABS_MENU_HELPER_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_menu_provider.h"
class Browser;
class GURL;
@class RecentTabsTableViewController;
@protocol RecentTabsPresentationDelegate;
namespace synced_sessions {
class DistantSession;
}
// Commands used to create context menu actions.
@protocol RecentTabsContextMenuDelegate
// Triggers the URL sharing flow for the given |URL| and |title|, with the
// origin |view| representing the UI component for that URL.
- (void)shareURL:(const GURL&)URL title:(NSString*)title fromView:(UIView*)view;
// Hides Sessions corresponding to the given |sectionIdentifier|.
- (void)removeSessionAtSessionSectionIdentifier:(NSInteger)sectionIdentifier;
// Returns Sessions corresponding to the given |sectionIdentifier|.
- (synced_sessions::DistantSession const*)sessionForSectionIdentifier:
(NSInteger)sectionIdentifier;
@end
// RecentTabsContextMenuHelper controls the creation of context menus,
// based on the given |browser|, |RecentTabsPresentationDelegate| and
// |RecentTabsTableViewController|.
@interface RecentTabsContextMenuHelper : NSObject <RecentTabsMenuProvider>
- (instancetype)initWithBrowser:(Browser*)browser
recentTabsPresentationDelegate:
(id<RecentTabsPresentationDelegate>)recentTabsPresentationDelegate
recentTabsContextMenuDelegate:
(id<RecentTabsContextMenuDelegate>)recentTabsContextMenuDelegate
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_RECENT_TABS_RECENT_TABS_MENU_HELPER_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/recent_tabs/recent_tabs_menu_helper.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
#import "ios/chrome/browser/ui/menu/action_factory.h"
#import "ios/chrome/browser/ui/menu/menu_histograms.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_menu_provider.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_presentation_delegate.h"
#include "ios/chrome/browser/ui/recent_tabs/synced_sessions.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_item.h"
#import "ios/chrome/browser/ui/util/multi_window_support.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface RecentTabsContextMenuHelper () <RecentTabsMenuProvider>
@property(nonatomic, assign) Browser* browser;
@property(nonatomic, weak) id<RecentTabsPresentationDelegate>
recentTabsPresentationDelegate;
@property(nonatomic, weak) id<RecentTabsContextMenuDelegate>
recentTabsContextMenuDelegate;
@end
@implementation RecentTabsContextMenuHelper
- (instancetype)initWithBrowser:(Browser*)browser
recentTabsPresentationDelegate:
(id<RecentTabsPresentationDelegate>)recentTabsPresentationDelegate
recentTabsContextMenuDelegate:
(id<RecentTabsContextMenuDelegate>)recentTabsContextMenuDelegate {
self = [super init];
if (self) {
_browser = browser;
_recentTabsPresentationDelegate = recentTabsPresentationDelegate;
_recentTabsContextMenuDelegate = recentTabsContextMenuDelegate;
}
return self;
}
#pragma mark - RecentTabsMenuProvider
- (UIContextMenuConfiguration*)contextMenuConfigurationForItem:
(TableViewURLItem*)item
fromView:(UIView*)view
API_AVAILABLE(ios(13.0)) {
__weak __typeof(self) weakSelf = self;
UIContextMenuActionProvider actionProvider = ^(
NSArray<UIMenuElement*>* suggestedActions) {
if (!weakSelf) {
// Return an empty menu.
return [UIMenu menuWithTitle:@"" children:@[]];
}
RecentTabsContextMenuHelper* strongSelf = weakSelf;
// Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::kRecentTabsEntry);
ActionFactory* actionFactory =
[[ActionFactory alloc] initWithBrowser:strongSelf.browser
scenario:MenuScenario::kRecentTabsEntry];
NSMutableArray<UIMenuElement*>* menuElements =
[[NSMutableArray alloc] init];
[menuElements
addObject:[actionFactory
actionToOpenInNewTabWithURL:item.URL
completion:^{
[self.recentTabsPresentationDelegate
dismissRecentTabs];
}]];
[menuElements
addObject:
[actionFactory
actionToOpenInNewIncognitoTabWithURL:item.URL
completion:^{
[self.recentTabsPresentationDelegate
dismissRecentTabs];
}]];
if (IsMultipleScenesSupported()) {
[menuElements
addObject:
[actionFactory
actionToOpenInNewWindowWithURL:item.URL
activityOrigin:WindowActivityRecentTabsOrigin
completion:^{
[self.recentTabsPresentationDelegate
dismissRecentTabs];
}]];
}
[menuElements addObject:[actionFactory actionToCopyURL:item.URL]];
[menuElements addObject:[actionFactory actionToShareWithBlock:^{
[strongSelf.recentTabsContextMenuDelegate
shareURL:item.URL
title:item.title
fromView:view];
}]];
return [UIMenu menuWithTitle:@"" children:menuElements];
};
return
[UIContextMenuConfiguration configurationWithIdentifier:nil
previewProvider:nil
actionProvider:actionProvider];
}
- (UIContextMenuConfiguration*)
contextMenuConfigurationForHeaderWithSectionIdentifier:
(NSInteger)sectionIdentifier API_AVAILABLE(ios(13.0)) {
__weak __typeof(self) weakSelf = self;
UIContextMenuActionProvider actionProvider =
^(NSArray<UIMenuElement*>* suggestedActions) {
if (!weakSelf) {
// Return an empty menu.
return [UIMenu menuWithTitle:@"" children:@[]];
}
// Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::kRecentTabsHeader);
ActionFactory* actionFactory = [[ActionFactory alloc]
initWithBrowser:self.browser
scenario:MenuScenario::kRecentTabsHeader];
NSMutableArray<UIMenuElement*>* menuElements =
[[NSMutableArray alloc] init];
synced_sessions::DistantSession const* session =
[weakSelf.recentTabsContextMenuDelegate
sessionForSectionIdentifier:sectionIdentifier];
if (!session->tabs.empty()) {
[menuElements addObject:[actionFactory actionToOpenAllTabsWithBlock:^{
[self.recentTabsPresentationDelegate
openAllTabsFromSession:session];
}]];
}
[menuElements
addObject:[actionFactory actionToHideWithBlock:^{
[weakSelf.recentTabsContextMenuDelegate
removeSessionAtSessionSectionIdentifier:sectionIdentifier];
}]];
return [UIMenu menuWithTitle:@"" children:menuElements];
};
return
[UIContextMenuConfiguration configurationWithIdentifier:nil
previewProvider:nil
actionProvider:actionProvider];
}
@end
......@@ -55,9 +55,6 @@ class DistantSession;
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE;
// Returns YES if |sectionIdentifier| is a Sessions sectionIdentifier.
- (BOOL)isSessionSectionIdentifier:(NSInteger)sectionIdentifier;
// Returns Sessions corresponding to the given |sectionIdentifier|.
- (synced_sessions::DistantSession const*)sessionForSectionIdentifier:
(NSInteger)sectionIdentifer;
......
......@@ -647,12 +647,6 @@ const int kRecentlyClosedTabsSectionIndex = 0;
#pragma mark - Public
- (BOOL)isSessionSectionIdentifier:(NSInteger)sectionIdentifier {
NSArray* sessionSectionIdentifiers = [self allSessionSectionIdentifiers];
NSNumber* sectionIdentifierObject = @(sectionIdentifier);
return [sessionSectionIdentifiers containsObject:sectionIdentifierObject];
}
- (synced_sessions::DistantSession const*)sessionForSectionIdentifier:
(NSInteger)sectionIdentifer {
NSInteger section =
......@@ -690,6 +684,15 @@ const int kRecentlyClosedTabsSectionIndex = 0;
}];
}
#pragma mark - Private
// Returns YES if |sectionIdentifier| is a Sessions sectionIdentifier.
- (BOOL)isSessionSectionIdentifier:(NSInteger)sectionIdentifier {
NSArray* sessionSectionIdentifiers = [self allSessionSectionIdentifiers];
NSNumber* sectionIdentifierObject = @(sectionIdentifier);
return [sessionSectionIdentifiers containsObject:sectionIdentifierObject];
}
#pragma mark - Consumer Protocol
- (void)refreshUserState:(SessionsSyncUserState)newSessionState {
......@@ -944,6 +947,9 @@ const int kRecentlyClosedTabsSectionIndex = 0;
UIView* header = [interaction view];
NSInteger tappedHeaderSectionIdentifier = header.tag;
if (![self isSessionSectionIdentifier:tappedHeaderSectionIdentifier])
return [[UIContextMenuConfiguration alloc] init];
return
[self.menuProvider contextMenuConfigurationForHeaderWithSectionIdentifier:
tappedHeaderSectionIdentifier];
......
......@@ -31,6 +31,7 @@ source_set("tab_grid") {
"//ios/chrome/browser/snapshots",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/activity_services",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/history",
......@@ -38,6 +39,7 @@ source_set("tab_grid") {
"//ios/chrome/browser/ui/main",
"//ios/chrome/browser/ui/recent_tabs",
"//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui",
"//ios/chrome/browser/ui/sharing",
"//ios/chrome/browser/ui/tab_grid/transitions",
"//ios/chrome/browser/ui/util",
"//ios/chrome/browser/url_loading",
......
......@@ -6,11 +6,14 @@
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
#import "ios/chrome/browser/ui/activity_services/activity_params.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/browsing_data_commands.h"
......@@ -20,8 +23,11 @@
#import "ios/chrome/browser/ui/history/public/history_presentation_delegate.h"
#import "ios/chrome/browser/ui/main/bvc_container_view_controller.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_mediator.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_menu_helper.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_presentation_delegate.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.h"
#include "ios/chrome/browser/ui/recent_tabs/synced_sessions.h"
#import "ios/chrome/browser/ui/sharing/sharing_coordinator.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_coordinator_delegate.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_mediator.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_paging.h"
......@@ -29,6 +35,7 @@
#import "ios/chrome/browser/ui/tab_grid/transitions/tab_grid_transition_handler.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
......@@ -38,6 +45,7 @@
@interface TabGridCoordinator () <TabPresentationDelegate,
HistoryPresentationDelegate,
RecentTabsContextMenuDelegate,
RecentTabsPresentationDelegate> {
// Use an explicit ivar instead of synthesizing as the setter isn't using the
// ivar.
......@@ -64,6 +72,10 @@
@property(nonatomic, strong) HistoryCoordinator* historyCoordinator;
// YES if the TabViewController has never been shown yet.
@property(nonatomic, assign) BOOL firstPresentation;
@property(nonatomic, strong) SharingCoordinator* sharingCoordinator;
@property(nonatomic, strong)
RecentTabsContextMenuHelper* recentTabsContextMenuHelper;
@end
@implementation TabGridCoordinator
......@@ -268,6 +280,15 @@
baseViewController.regularTabsImageDataSource = self.regularTabsMediator;
baseViewController.incognitoTabsImageDataSource = self.incognitoTabsMediator;
if (@available(iOS 13.0, *)) {
self.recentTabsContextMenuHelper =
[[RecentTabsContextMenuHelper alloc] initWithBrowser:self.regularBrowser
recentTabsPresentationDelegate:self
recentTabsContextMenuDelegate:self];
self.baseViewController.remoteTabsViewController.menuProvider =
self.recentTabsContextMenuHelper;
}
// TODO(crbug.com/845192) : Remove RecentTabsTableViewController dependency on
// ChromeBrowserState so that we don't need to expose the view controller.
baseViewController.remoteTabsViewController.browser = self.regularBrowser;
......@@ -314,6 +335,9 @@
// handler after this coordinator has stopped; make this action a no-op by
// setting the handler to nil.
self.baseViewController.handler = nil;
self.recentTabsContextMenuHelper = nil;
[self.sharingCoordinator stop];
self.sharingCoordinator = nil;
[self.dispatcher stopDispatchingForProtocol:@protocol(ApplicationCommands)];
[self.dispatcher
stopDispatchingForProtocol:@protocol(ApplicationSettingsCommands)];
......@@ -399,7 +423,53 @@
- (void)openAllTabsFromSession:(const synced_sessions::DistantSession*)session {
// TODO(crbug.com/1093302) : Implement this.
base::RecordAction(base::UserMetricsAction(
"MobileRecentTabManagerOpenAllTabsFromOtherDevice"));
base::UmaHistogramCounts100(
"Mobile.RecentTabsManager.TotalTabsFromOtherDevicesOpenAll",
session->tabs.size());
for (auto const& tab : session->tabs) {
UrlLoadParams params = UrlLoadParams::InNewTab(tab->virtual_url);
params.SetInBackground(YES);
params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK;
params.load_strategy =
self.baseViewController.remoteTabsViewController.loadStrategy;
params.in_incognito =
self.regularBrowser->GetBrowserState()->IsOffTheRecord();
UrlLoadingBrowserAgent::FromBrowser(self.regularBrowser)->Load(params);
}
[self showActiveRegularTabFromRecentTabs];
}
#pragma mark - RecentTabsContextMenuDelegate
- (void)shareURL:(const GURL&)URL
title:(NSString*)title
fromView:(UIView*)view {
ActivityParams* params =
[[ActivityParams alloc] initWithURL:URL
title:title
scenario:ActivityScenario::RecentTabsEntry];
self.sharingCoordinator = [[SharingCoordinator alloc]
initWithBaseViewController:self.baseViewController
.remoteTabsViewController
browser:self.regularBrowser
params:params
originView:view];
[self.sharingCoordinator start];
}
- (void)removeSessionAtSessionSectionIdentifier:(NSInteger)sectionIdentifier {
[self.baseViewController.remoteTabsViewController
removeSessionAtSessionSectionIdentifier:sectionIdentifier];
}
- (synced_sessions::DistantSession const*)sessionForSectionIdentifier:
(NSInteger)sectionIdentifier {
return [self.baseViewController.remoteTabsViewController
sessionForSectionIdentifier:sectionIdentifier];
}
@end
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