Commit 366e10e9 authored by Dominic Battré's avatar Dominic Battré Committed by Commit Bot

Revert "[ios] Added bookmark search"

This reverts commit 1dba3ee8.

Reason for revert: Speculative revert due to Failures on ios_chrome_bookmarks_egtests (iPhone X iOS 12.0)

Original change's description:
> [ios] Added bookmark search
> 
> When opening:
> https://drive.google.com/file/d/1z4iyQgQOL9jUFNfIf9Qg1SmFz9INxN88/view?usp=sharing
> When searching:
> https://drive.google.com/file/d/1wdMrOC9GDzh7e97HY-1ObHergJH0rnoC/view?usp=sharing
> 
> In action:
> https://drive.google.com/file/d/14NMZ4mkCUZM8QNyopWHQ6MyDX939bcni/view?usp=sharing
> 
> Bug: 879570
> Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
> Change-Id: I51f88361a79703c55f03e2befb745ca3701ce577
> Reviewed-on: https://chromium-review.googlesource.com/1193932
> Commit-Queue: David Jean <djean@chromium.org>
> Reviewed-by: Sergio Collazos <sczs@chromium.org>
> Reviewed-by: Gauthier Ambard <gambard@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#589861}

TBR=sczs@chromium.org,gambard@chromium.org,djean@chromium.org

Change-Id: Ia9b723b9a69cb7aa4cf00f339f380a15a7e64109
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 879570
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Reviewed-on: https://chromium-review.googlesource.com/1215866Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589890}
parent 628c1e15
......@@ -36,12 +36,6 @@ class ChromeBrowserState;
// existing data first.
- (void)computeBookmarkTableViewData;
// Rebuilds the table view model data for the bookmarks matching the given text.
// Deletes any existing data first. If no items found, an entry with
// |noResults' message is added to the table.
- (void)computeBookmarkTableViewDataMatching:(NSString*)searchText
orShowMessageWhenNoResults:(NSString*)noResults;
@end
#endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_MEDIATOR_H_
......@@ -6,10 +6,7 @@
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/browser/titled_url_match.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/sync/synced_sessions_bridge.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view_mediator.h"
......@@ -20,7 +17,6 @@
#import "ios/chrome/browser/ui/bookmarks/cells/bookmark_home_node_item.h"
#import "ios/chrome/browser/ui/bookmarks/cells/bookmark_home_promo_item.h"
#import "ios/chrome/browser/ui/signin_interaction/public/signin_presenter.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "ios/chrome/browser/ui/table_view/table_view_model.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -29,11 +25,6 @@
using bookmarks::BookmarkNode;
namespace {
// Maximum number of entries to fetch when searching.
const int kMaxBookmarksSearchResults = 50;
} // namespace
@interface BookmarkHomeMediator ()<BookmarkHomePromoItemDelegate,
BookmarkModelBridgeObserver,
BookmarkPromoControllerDelegate,
......@@ -105,12 +96,16 @@ const int kMaxBookmarksSearchResults = 50;
// Computes the bookmarks table view based on the current root node.
- (void)computeBookmarkTableViewData {
[self deleteAllItemsOrAddSectionWithIdentifier:
BookmarkHomeSectionIdentifierBookmarks];
[self deleteAllItemsOrAddSectionWithIdentifier:
BookmarkHomeSectionIdentifierMessages];
// Regenerate the list of all bookmarks.
if ([self.sharedState.tableViewModel
hasSectionForSectionIdentifier:
BookmarkHomeSectionIdentifierBookmarks]) {
[self.sharedState.tableViewModel
removeSectionWithIdentifier:BookmarkHomeSectionIdentifierBookmarks];
}
[self.sharedState.tableViewModel
addSectionWithIdentifier:BookmarkHomeSectionIdentifierBookmarks];
if (!self.sharedState.bookmarkModel->loaded() ||
!self.sharedState.tableViewDisplayedRootNode) {
[self updateTableViewBackground];
......@@ -183,47 +178,6 @@ const int kMaxBookmarksSearchResults = 50;
}
}
- (void)computeBookmarkTableViewDataMatching:(NSString*)searchText
orShowMessageWhenNoResults:(NSString*)noResults {
[self deleteAllItemsOrAddSectionWithIdentifier:
BookmarkHomeSectionIdentifierBookmarks];
[self deleteAllItemsOrAddSectionWithIdentifier:
BookmarkHomeSectionIdentifierMessages];
std::vector<const BookmarkNode*> nodes;
bookmarks::QueryFields query;
query.word_phrase_query.reset(new base::string16);
*query.word_phrase_query = base::SysNSStringToUTF16(searchText);
GetBookmarksMatchingProperties(self.sharedState.bookmarkModel, query,
kMaxBookmarksSearchResults, &nodes);
int count = 0;
for (const BookmarkNode* node : nodes) {
if (!node->is_url())
continue;
BookmarkHomeNodeItem* nodeItem =
[[BookmarkHomeNodeItem alloc] initWithType:BookmarkHomeItemTypeBookmark
bookmarkNode:node];
[self.sharedState.tableViewModel
addItem:nodeItem
toSectionWithIdentifier:BookmarkHomeSectionIdentifierBookmarks];
count++;
}
if (count == 0) {
TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:BookmarkHomeItemTypeMessage];
item.textAlignment = NSTextAlignmentLeft;
item.textColor = [UIColor darkGrayColor];
item.text = noResults;
[self.sharedState.tableViewModel
addItem:item
toSectionWithIdentifier:BookmarkHomeSectionIdentifierMessages];
return;
}
}
- (void)updateTableViewBackground {
// If the current root node is the outermost root, check if we need to show
// the spinner backgound. Otherwise, check if we need to show the empty
......@@ -317,10 +271,6 @@ const int kMaxBookmarksSearchResults = 50;
// The node has not changed, but its children have.
- (void)bookmarkNodeChildrenChanged:(const BookmarkNode*)bookmarkNode {
// In search mode, we want to refresh any changes (like undo).
if (self.sharedState.currentlyShowingSearchResults) {
[self.consumer refreshContents];
}
// The current root folder's children changed. Reload everything.
// (When adding new folder, table is already been updated. So no need to
// reload here.)
......@@ -345,9 +295,7 @@ const int kMaxBookmarksSearchResults = 50;
// |node| was deleted from |folder|.
- (void)bookmarkNodeDeleted:(const BookmarkNode*)node
fromFolder:(const BookmarkNode*)folder {
if (self.sharedState.currentlyShowingSearchResults) {
[self.consumer refreshContents];
} else if (self.sharedState.tableViewDisplayedRootNode == node) {
if (self.sharedState.tableViewDisplayedRootNode == node) {
self.sharedState.tableViewDisplayedRootNode = NULL;
[self.consumer refreshContents];
}
......@@ -456,17 +404,4 @@ const int kMaxBookmarksSearchResults = 50;
!self.sharedState.tableViewDisplayedRootNode->empty();
}
// Delete all items for the given |sectionIdentifier| section, or create it
// if it doesn't exist, hence ensuring the section exists and is empty.
- (void)deleteAllItemsOrAddSectionWithIdentifier:(NSInteger)sectionIdentifier {
if ([self.sharedState.tableViewModel
hasSectionForSectionIdentifier:sectionIdentifier]) {
[self.sharedState.tableViewModel
deleteAllItemsFromSectionWithIdentifier:sectionIdentifier];
} else {
[self.sharedState.tableViewModel
addSectionWithIdentifier:sectionIdentifier];
}
}
@end
......@@ -24,13 +24,11 @@ class BookmarkNode;
typedef NS_ENUM(NSInteger, BookmarkHomeSectionIdentifier) {
BookmarkHomeSectionIdentifierPromo = kSectionIdentifierEnumZero,
BookmarkHomeSectionIdentifierBookmarks,
BookmarkHomeSectionIdentifierMessages,
};
typedef NS_ENUM(NSInteger, BookmarkHomeItemType) {
BookmarkHomeItemTypePromo = kItemTypeEnumZero,
BookmarkHomeItemTypeBookmark,
BookmarkHomeItemTypeMessage,
};
@protocol BookmarkHomeSharedStateObserver
......@@ -66,9 +64,6 @@ typedef NS_ENUM(NSInteger, BookmarkHomeItemType) {
// If the table view is in edit mode.
@property(nonatomic, assign) BOOL currentlyInEditMode;
// If the table view showing search results.
@property(nonatomic, assign) BOOL currentlyShowingSearchResults;
// The set of nodes currently being edited.
@property(nonatomic, readonly, assign)
std::set<const bookmarks::BookmarkNode*>& editNodes;
......
......@@ -35,7 +35,6 @@ const NSUInteger kMaxDownloadFaviconCount = 50;
@synthesize addingNewFolder = _addingNewFolder;
@synthesize bookmarkModel = _bookmarkModel;
@synthesize currentlyInEditMode = _currentlyInEditMode;
@synthesize currentlyShowingSearchResults = _currentlyShowingSearchResults;
@synthesize editingFolderCell = _editingFolderCell;
@synthesize editingFolderNode = _editingFolderNode;
@synthesize faviconDownloadCount = _faviconDownloadCount;
......
......@@ -26,8 +26,7 @@ TEST_F(BookmarkHomeViewControllerTest,
dispatcher:nil];
[controller setRootNode:_bookmarkModel->mobile_node()];
// Two sections: Messages and Bookmarks.
EXPECT_EQ(2, [controller numberOfSectionsInTableView:controller.tableView]);
EXPECT_EQ(1, [controller numberOfSectionsInTableView:controller.tableView]);
}
}
......
......@@ -332,7 +332,7 @@ enum class PresentedState {
self.bookmarkEditor.delegate = nil;
self.bookmarkEditor = nil;
[self.bookmarkNavigationController
[_parentController
dismissViewControllerAnimated:animated
completion:^{
self.bookmarkNavigationController = nil;
......@@ -346,7 +346,7 @@ enum class PresentedState {
return;
DCHECK(self.bookmarkNavigationController);
[self.bookmarkNavigationController
[_parentController
dismissViewControllerAnimated:animated
completion:^{
self.folderEditor.delegate = nil;
......
......@@ -42,10 +42,6 @@ extern NSString* const kBookmarkHomeCenterButtonIdentifier;
extern NSString* const kBookmarkHomeTrailingButtonIdentifier;
// Accessibility identifier of the BookmarkHomeVC UIToolbar.
extern NSString* const kBookmarkHomeUIToolbarIdentifier;
// Accessibility identifier of the BookmarkHomeVC search bar.
extern NSString* const kBookmarkHomeSearchBarIdentifier;
// Accessibility identifier of the search scrim.
extern NSString* const kBookmarkHomeSearchScrimIdentifier;
// Cell Layout constants:
// The space between UIViews inside the cell.
......
......@@ -38,10 +38,6 @@ NSString* const kBookmarkHomeTrailingButtonIdentifier =
@"kBookmarkHomeTrailingButtonIdentifier";
NSString* const kBookmarkHomeUIToolbarIdentifier =
@"kBookmarkHomeUIToolbarIdentifier";
NSString* const kBookmarkHomeSearchBarIdentifier =
@"kBookmarkHomeSearchBarIdentifier";
NSString* const kBookmarkHomeSearchScrimIdentifier =
@"kBookmarkHomeSearchScrimIdentifier";
const CGFloat kBookmarkCellViewSpacing = 10.0f;
const CGFloat kBookmarkCellVerticalInset = 11.0f;
......
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