Commit aff82316 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Hook up URLLoader in remote tabs for tab grid

This CL hooks up the URLLoader for remote tabs in tab grid. When the
user taps on a remote tab, the tab will be loaded and the tab will be
displayed.

Bug: 804588
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I7a6dbe200d8e806b14012d3986bbd61789cf810b
Reviewed-on: https://chromium-review.googlesource.com/1088188Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565071}
parent a748ef4a
......@@ -23,8 +23,10 @@ source_set("tab_grid") {
"//components/favicon/ios",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/sessions:serialisation",
"//ios/chrome/browser/snapshots",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/main",
......
......@@ -4,7 +4,9 @@
#import "ios/chrome/browser/ui/tab_grid/tab_grid_coordinator.h"
#include "components/sessions/core/session_types.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/sessions/session_util.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
......@@ -17,12 +19,16 @@
#import "ios/chrome/browser/ui/tab_grid/tab_grid_paging.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_transition_handler.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#import "ios/chrome/browser/ui/url_loader.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_opener.h"
#import "ios/web/public/web_state/web_state.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface TabGridCoordinator ()<TabPresentationDelegate>
@interface TabGridCoordinator ()<TabPresentationDelegate, UrlLoader>
// Superclass property specialized for the class that this coordinator uses.
@property(nonatomic, weak) TabGridViewController* mainViewController;
// Commad dispatcher used while this coordinator's view controller is active.
......@@ -167,6 +173,7 @@
self.remoteTabsMediator;
mainViewController.remoteTabsViewController.dispatcher =
static_cast<id<ApplicationCommands>>(self.dispatcher);
mainViewController.remoteTabsViewController.loader = self;
if (self.remoteTabsMediator.browserState) {
[self.remoteTabsMediator initObservers];
[self.remoteTabsMediator refreshSessionsView];
......@@ -312,4 +319,57 @@
- (void)closeAllIncognitoTabs {
}
#pragma mark - UrlLoader
- (void)loadSessionTab:(const sessions::SessionTab*)sessionTab {
WebStateList* webStateList = self.regularTabModel.webStateList;
std::unique_ptr<web::WebState> webState =
session_util::CreateWebStateWithNavigationEntries(
self.regularTabModel.browserState,
sessionTab->current_navigation_index, sessionTab->navigations);
webStateList->InsertWebState(webStateList->count(), std::move(webState),
WebStateList::INSERT_ACTIVATE, WebStateOpener());
// Trigger the transition through the TabSwitcher delegate. This will in turn
// call back into this coordinator via the ViewControllerSwapping protocol.
[self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher
shouldFinishWithActiveModel:self.regularTabModel];
}
- (void)webPageOrderedOpen:(const GURL&)url
referrer:(const web::Referrer&)referrer
inBackground:(BOOL)inBackground
appendTo:(OpenPosition)appendTo {
// TODO(crbug.com/850240) : Hook up open all tabs in session.
UIAlertController* alertController = [UIAlertController
alertControllerWithTitle:@"Not Yet Implemented"
message:
@"We are still working on this feature. In the "
@"meantime, you can access this feature through the "
@"overflow menu and the new tab page."
preferredStyle:UIAlertControllerStyleAlert];
[alertController
addAction:[UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleCancel
handler:nil]];
[self.mainViewController presentViewController:alertController
animated:YES
completion:nil];
}
- (void)webPageOrderedOpen:(const GURL&)url
referrer:(const web::Referrer&)referrer
inIncognito:(BOOL)inIncognito
inBackground:(BOOL)inBackground
appendTo:(OpenPosition)appendTo {
// This is intentionally NO-OP.
}
- (void)loadURLWithParams:(const web::NavigationManager::WebLoadParams&)params {
// This is intentionally NO-OP.
}
- (void)loadJavaScriptFromLocationBar:(NSString*)script {
// This is intentionally NO-OP.
}
@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