Commit 9f4b2096 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Prepares HistoryVC’s for Search implementation.

- Creates a UISearchController and adds it to the VC.
- Create a HistoryTableUpdater protocol that will be used to communicate
updates from the Container to the TableView.

Screenshots:
https://drive.google.com/open?id=1L6kaO6xZ7WGEoQXjcVGf_RJALtXrG4cM
https://drive.google.com/open?id=1uSec0DEg7ug_5vAu5uRGL6ljsWabuvZt

Bug: 805195
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Icdfa7c6133bb088352bacbf02f59c65df8b4b0d7
Reviewed-on: https://chromium-review.googlesource.com/998813
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550011}
parent 223fbc57
...@@ -99,6 +99,7 @@ source_set("history_ui") { ...@@ -99,6 +99,7 @@ source_set("history_ui") {
"history_entry_item_interface.h", "history_entry_item_interface.h",
"history_table_container_view_controller.h", "history_table_container_view_controller.h",
"history_table_container_view_controller.mm", "history_table_container_view_controller.mm",
"history_table_updater_delegate.h",
"history_table_view_controller.h", "history_table_view_controller.h",
"history_table_view_controller.mm", "history_table_view_controller.mm",
"history_util.h", "history_util.h",
......
...@@ -7,10 +7,13 @@ ...@@ -7,10 +7,13 @@
#import "ios/chrome/browser/ui/table_view/table_container_view_controller.h" #import "ios/chrome/browser/ui/table_view/table_container_view_controller.h"
@class HistoryTableViewController; @protocol HistoryTableUpdaterDelegate;
// Container for handling the interaction between its TableViewController, the // Container for handling the interaction between its TableViewController, the
// container BottomToolbar and the SearchController. // container BottomToolbar and the SearchController.
@interface HistoryTableContainerViewController : TableContainerViewController @interface HistoryTableContainerViewController : TableContainerViewController
- (instancetype)initWithTable:
(ChromeTableViewController<HistoryTableUpdaterDelegate>*)table;
@end @end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TABLE_CONTAINER_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TABLE_CONTAINER_VIEW_CONTROLLER_H_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/history/history_table_view_controller.h"
#import "ios/chrome/browser/ui/table_view/table_container_bottom_toolbar.h" #import "ios/chrome/browser/ui/table_view/table_container_bottom_toolbar.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -13,9 +14,16 @@ ...@@ -13,9 +14,16 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface HistoryTableContainerViewController ()
// This ViewController's searchController;
@property(nonatomic, strong) UISearchController* searchController;
@end
@implementation HistoryTableContainerViewController @implementation HistoryTableContainerViewController
@synthesize searchController = _searchController;
- (instancetype)initWithTable:(ChromeTableViewController*)table { - (instancetype)initWithTable:
(ChromeTableViewController<HistoryTableUpdaterDelegate>*)table {
self = [super initWithTable:table]; self = [super initWithTable:table];
if (self) { if (self) {
NSString* leadingButtonString = l10n_util::GetNSStringWithFixup( NSString* leadingButtonString = l10n_util::GetNSStringWithFixup(
...@@ -31,4 +39,29 @@ ...@@ -31,4 +39,29 @@
} }
return self; return self;
} }
- (void)viewDidLoad {
[super viewDidLoad];
[self addSearchController];
}
// Creates and adds a UISearchController.
- (void)addSearchController {
// Init the searchController with nil so the results are displayed on the same
// TableView.
self.searchController =
[[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.dimsBackgroundDuringPresentation = NO;
// For iOS 11 and later, we place the search bar in the navigation bar, if not
// we place the search bar in the table view's header.
if (@available(iOS 11, *)) {
self.navigationItem.searchController = self.searchController;
// We want the search bar visible all the time.
self.navigationItem.hidesSearchBarWhenScrolling = NO;
} else {
self.tableViewController.tableView.tableHeaderView =
self.searchController.searchBar;
}
}
@end @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_HISTORY_HISTORY_TABLE_UPDATER_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TABLE_UPDATER_DELEGATE_H_
// Delegate to communicate updates from History Container to the History
// TableView
@protocol HistoryTableUpdaterDelegate
// Search history for text |query| and display the results. |query| may be nil.
// If query is empty, show all history items.
- (void)showHistoryMatchingQuery:(NSString*)query;
// Deletes selected items from browser history and removes them from the
// tableView.
- (void)deleteSelectedItems;
@end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TABLE_UPDATER_DELEGATE_H_
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/ios/block_types.h" #include "base/ios/block_types.h"
#include "ios/chrome/browser/ui/history/history_consumer.h" #include "ios/chrome/browser/ui/history/history_consumer.h"
#include "ios/chrome/browser/ui/history/history_table_updater_delegate.h"
namespace ios { namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
...@@ -35,7 +36,7 @@ class ChromeBrowserState; ...@@ -35,7 +36,7 @@ class ChromeBrowserState;
// ChromeTableViewController for displaying history items. // ChromeTableViewController for displaying history items.
@interface HistoryTableViewController @interface HistoryTableViewController
: ChromeTableViewController<HistoryConsumer> : ChromeTableViewController<HistoryConsumer, HistoryTableUpdaterDelegate>
// The ViewController's BrowserState. // The ViewController's BrowserState.
@property(nonatomic, assign) ios::ChromeBrowserState* browserState; @property(nonatomic, assign) ios::ChromeBrowserState* browserState;
// Abstraction to communicate with HistoryService and WebHistoryService. // Abstraction to communicate with HistoryService and WebHistoryService.
......
...@@ -108,12 +108,6 @@ const int kMaxFetchCount = 100; ...@@ -108,12 +108,6 @@ const int kMaxFetchCount = 100;
return self.tableView.indexPathsForSelectedRows.count; return self.tableView.indexPathsForSelectedRows.count;
} }
- (void)showHistoryMatchingQuery:(NSString*)query {
self.finishedLoading = NO;
self.currentQuery = query;
[self fetchHistoryForQuery:query continuation:false];
}
- (void)deleteSelectedItemsFromHistory { - (void)deleteSelectedItemsFromHistory {
// TODO(crbug.com/805190): Migrate. // TODO(crbug.com/805190): Migrate.
} }
...@@ -397,4 +391,15 @@ const int kMaxFetchCount = 100; ...@@ -397,4 +391,15 @@ const int kMaxFetchCount = 100;
// TODO(crbug.com/805190): Migrate. // TODO(crbug.com/805190): Migrate.
} }
#pragma mark - HistoryTableUpdaterDelegate
- (void)showHistoryMatchingQuery:(NSString*)query {
self.finishedLoading = NO;
self.currentQuery = query;
[self fetchHistoryForQuery:query continuation:false];
}
- (void)deleteSelectedItems {
// TODO(crbug.com/805190): Migrate.
}
@end @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