Commit cf8cd825 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Implement open link logic in ClearBrowsingDataTableView

Also moves it's coordinator to history and creates HistoryClearBrowsingDataLocalCommands delegate.

Bug: 854882
Change-Id: Ia408681d5d559b1ae2da38315436fc93a7591489
Reviewed-on: https://chromium-review.googlesource.com/1111077
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569939}
parent 0c062061
......@@ -31,6 +31,7 @@ source_set("history") {
"legacy_history_entry_item.mm",
]
deps = [
":clear_browsing_data",
":feature_flags",
":history_ui",
"//base",
......@@ -139,6 +140,24 @@ source_set("history_ui") {
]
}
source_set("clear_browsing_data") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"history_clear_browsing_data_coordinator.h",
"history_clear_browsing_data_coordinator.mm",
]
deps = [
":history_ui",
"//base",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/history/public",
"//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/table_view",
"//ios/web/public",
]
}
source_set("feature_flags") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
......
// Copyright 2018 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_HISTORY_HISTORY_CLEAR_BROWSING_DATA_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_CLEAR_BROWSING_DATA_COORDINATOR_H_
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
@protocol UrlLoader;
@protocol HistoryLocalCommands;
@protocol HistoryPresentationDelegate;
@protocol HistoryClearBrowsingDataLocalCommands;
// Coordinator that presents Clear Browsing Data Table View from History.
// Delegates are hooked up to History coordinator-specific methods.
@interface HistoryClearBrowsingDataCoordinator
: ChromeCoordinator<ClearBrowsingDataLocalCommands>
// Delegate for this coordinator.
@property(nonatomic, weak) id<HistoryLocalCommands> localDispatcher;
// The UrlLoader used by this coordinator.
@property(nonatomic, weak) id<UrlLoader> loader;
// Delegate used to make the Tab UI visible.
@property(nonatomic, weak) id<HistoryPresentationDelegate> presentationDelegate;
@end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_CLEAR_BROWSING_DATA_COORDINATOR_H_
// Copyright 2018 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/history/history_clear_browsing_data_coordinator.h"
#include "base/mac/foundation_util.h"
#include "ios/chrome/browser/ui/history/history_local_commands.h"
#import "ios/chrome/browser/ui/history/public/history_presentation_delegate.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_table_view_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
#import "ios/chrome/browser/ui/url_loader.h"
#import "ios/web/public/referrer.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface HistoryClearBrowsingDataCoordinator ()
// ViewController being managed by this Coordinator.
@property(strong, nonatomic)
TableViewNavigationController* historyClearBrowsingDataNavigationController;
@end
@implementation HistoryClearBrowsingDataCoordinator
@synthesize historyClearBrowsingDataNavigationController =
_historyClearBrowsingDataNavigationController;
@synthesize loader = _loader;
@synthesize localDispatcher = _localDispatcher;
@synthesize presentationDelegate = _presentationDelegate;
- (void)start {
ClearBrowsingDataTableViewController* clearBrowsingDataTableViewController =
[[ClearBrowsingDataTableViewController alloc]
initWithBrowserState:self.browserState];
clearBrowsingDataTableViewController.extendedLayoutIncludesOpaqueBars = YES;
clearBrowsingDataTableViewController.localDispatcher = self;
// Configure and present ClearBrowsingDataNavigationController.
self.historyClearBrowsingDataNavigationController =
[[TableViewNavigationController alloc]
initWithTable:clearBrowsingDataTableViewController];
self.historyClearBrowsingDataNavigationController.toolbarHidden = NO;
self.historyClearBrowsingDataNavigationController.modalPresentationStyle =
UIModalPresentationFormSheet;
self.historyClearBrowsingDataNavigationController.modalTransitionStyle =
UIModalTransitionStyleCoverVertical;
[self.baseViewController
presentViewController:self.historyClearBrowsingDataNavigationController
animated:YES
completion:nil];
}
#pragma mark - ClearBrowsingDataLocalCommands
- (void)openURL:(const GURL&)URL {
GURL copiedURL(URL);
[self dismissClearBrowsingDataWithCompletion:^() {
[self.localDispatcher dismissHistoryWithCompletion:^{
[self.loader webPageOrderedOpen:copiedURL
referrer:web::Referrer()
inIncognito:NO
inBackground:NO
appendTo:kLastTab];
[self.presentationDelegate showActiveRegularTabFromHistory];
}];
}];
}
- (void)dismissClearBrowsingDataWithCompletion:
(ProceduralBlock)completionHandler {
[self.historyClearBrowsingDataNavigationController
dismissViewControllerAnimated:YES
completion:completionHandler];
self.historyClearBrowsingDataNavigationController = nil;
}
@end
......@@ -11,12 +11,12 @@
#include "ios/chrome/browser/history/history_service_factory.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/history/history_clear_browsing_data_coordinator.h"
#include "ios/chrome/browser/ui/history/history_local_commands.h"
#import "ios/chrome/browser/ui/history/history_mediator.h"
#include "ios/chrome/browser/ui/history/history_table_view_controller.h"
#import "ios/chrome/browser/ui/history/history_transitioning_delegate.h"
#include "ios/chrome/browser/ui/history/ios_browsing_history_driver.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_coordinator.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -42,12 +42,13 @@
// The coordinator that will present Clear Browsing Data.
@property(nonatomic, strong)
ClearBrowsingDataCoordinator* clearBrowsingDataCoordinator;
HistoryClearBrowsingDataCoordinator* historyClearBrowsingDataCoordinator;
@end
@implementation HistoryCoordinator
@synthesize clearBrowsingDataCoordinator = _clearBrowsingDataCoordinator;
@synthesize dispatcher = _dispatcher;
@synthesize historyClearBrowsingDataCoordinator =
_historyClearBrowsingDataCoordinator;
@synthesize historyNavigationController = _historyNavigationController;
@synthesize historyTransitioningDelegate = _historyTransitioningDelegate;
@synthesize loader = _loader;
......@@ -118,10 +119,15 @@
- (void)displayPrivacySettings {
if (experimental_flags::IsCollectionsUIRebootEnabled()) {
self.clearBrowsingDataCoordinator = [[ClearBrowsingDataCoordinator alloc]
initWithBaseViewController:self.historyNavigationController
browserState:self.browserState];
[self.clearBrowsingDataCoordinator start];
self.historyClearBrowsingDataCoordinator =
[[HistoryClearBrowsingDataCoordinator alloc]
initWithBaseViewController:self.historyNavigationController
browserState:self.browserState];
self.historyClearBrowsingDataCoordinator.localDispatcher = self;
self.historyClearBrowsingDataCoordinator.presentationDelegate =
self.presentationDelegate;
self.historyClearBrowsingDataCoordinator.loader = self.loader;
[self.historyClearBrowsingDataCoordinator start];
} else {
[self.dispatcher showClearBrowsingDataSettingsFromViewController:
self.historyNavigationController];
......
......@@ -27,8 +27,7 @@ source_set("settings") {
"clear_browsing_data_collection_view_controller.h",
"clear_browsing_data_collection_view_controller.mm",
"clear_browsing_data_consumer.h",
"clear_browsing_data_coordinator.h",
"clear_browsing_data_coordinator.mm",
"clear_browsing_data_local_commands.h",
"clear_browsing_data_manager.h",
"clear_browsing_data_manager.mm",
"clear_browsing_data_table_view_controller.h",
......
// Copyright 2018 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_SETTINGS_CLEAR_BROWSING_DATA_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_COORDINATOR_H_
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
// Coordinator that presents Clear Browsing Data Table View.
@interface ClearBrowsingDataCoordinator : ChromeCoordinator
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_COORDINATOR_H_
// Copyright 2018 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/settings/clear_browsing_data_coordinator.h"
#include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_table_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation ClearBrowsingDataCoordinator
- (void)start {
ClearBrowsingDataTableViewController* clearBrowsingDataTableViewController =
[[ClearBrowsingDataTableViewController alloc]
initWithBrowserState:self.browserState];
clearBrowsingDataTableViewController.extendedLayoutIncludesOpaqueBars = YES;
// We currently know for sure that baseViewController is a
// Navigation Controller.
// Todo: there should be a way to stop coordinators once they've been pushed
// out of the Navigation VC.
UINavigationController* tableViewNavigationController =
base::mac::ObjCCastStrict<UINavigationController>(
self.baseViewController);
[tableViewNavigationController
pushViewController:clearBrowsingDataTableViewController
animated:YES];
}
@end
// Copyright 2018 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_SETTINGS_CLEAR_BROWSING_DATA_LOCAL_COMMANDS_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_LOCAL_COMMANDS_H_
#include "base/ios/block_types.h"
class GURL;
@protocol ClearBrowsingDataLocalCommands
// Opens URL in a new non-incognito tab and dismisses the clear browsing data
// view.
- (void)openURL:(const GURL&)URL;
// Notifies the coordinator that Clear Browsing Data should be dismissed.
- (void)dismissClearBrowsingDataWithCompletion:
(ProceduralBlock)completionHandler;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CLEAR_BROWSING_DATA_LOCAL_COMMANDS_H_
......@@ -11,6 +11,8 @@ namespace ios {
class ChromeBrowserState;
}
@protocol ClearBrowsingDataLocalCommands;
// TableView for clearing browsing data (including history,
// cookies, caches, passwords, and autofill).
@interface ClearBrowsingDataTableViewController : ChromeTableViewController
......@@ -23,6 +25,9 @@ class ChromeBrowserState;
(ChromeTableViewControllerStyle)appBarStyle
NS_UNAVAILABLE;
// Local Dispatcher for this ClearBrowsingDataTableView.
@property(nonatomic, weak) id<ClearBrowsingDataLocalCommands> localDispatcher;
@end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_CLEAR_BROWSING_DATA_TABLE_VIEW_CONTROLLER_H_
......@@ -7,6 +7,7 @@
#include "base/mac/foundation_util.h"
#include "ios/chrome/browser/browsing_data/browsing_data_remove_mask.h"
#import "ios/chrome/browser/ui/settings/cells/table_view_clear_browsing_data_item.h"
#include "ios/chrome/browser/ui/settings/clear_browsing_data_local_commands.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_manager.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_button_item.h"
......@@ -44,6 +45,7 @@ class ChromeBrowserState;
@implementation ClearBrowsingDataTableViewController
@synthesize browserState = _browserState;
@synthesize dataManager = _dataManager;
@synthesize localDispatcher = _localDispatcher;
#pragma mark - ViewController Lifecycle.
......@@ -75,6 +77,12 @@ class ChromeBrowserState;
// Navigation controller configuration.
self.title = l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
// Adds the "Done" button and hooks it up to |dismiss|.
UIBarButtonItem* dismissButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(dismiss)];
self.navigationItem.rightBarButtonItem = dismissButton;
[self loadModel];
}
......@@ -84,6 +92,10 @@ class ChromeBrowserState;
[self.dataManager loadModel:self.tableViewModel];
}
- (void)dismiss {
[self.localDispatcher dismissClearBrowsingDataWithCompletion:nil];
}
#pragma mark - UITableViewDataSource
- (UITableViewCell*)tableView:(UITableView*)tableView
......@@ -162,7 +174,8 @@ class ChromeBrowserState;
- (void)tableViewTextLinkCell:(TableViewTextLinkCell*)cell
didRequestOpenURL:(const GURL&)URL {
[self openURLInNewTab:URL];
GURL copiedURL(URL);
[self.localDispatcher openURL:copiedURL];
}
#pragma mark - TextButtonItemDelegate
......@@ -185,12 +198,4 @@ class ChromeBrowserState;
}
}
#pragma mark - Private Methods
// Opens URL in a new non-incognito tab and dismisses the clear browsing data
// view.
- (void)openURLInNewTab:(const GURL&)URL {
// TODO(crbug.com/854882): Implement open URL logic.
}
@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