| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view.h" |
| 6 | 6 |
| 7 #import <UIKit/UIGestureRecognizerSubclass.h> | 7 #import <UIKit/UIGestureRecognizerSubclass.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/mac/bind_objc_block.h" | 13 #include "base/mac/bind_objc_block.h" |
| 14 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/stl_util.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 16 #include "components/bookmarks/browser/bookmark_model.h" | 17 #include "components/bookmarks/browser/bookmark_model.h" |
| 17 #include "components/bookmarks/browser/bookmark_model_observer.h" | 18 #include "components/bookmarks/browser/bookmark_model_observer.h" |
| 18 #include "components/favicon/core/fallback_url_util.h" | 19 #include "components/favicon/core/fallback_url_util.h" |
| 19 #include "components/favicon/core/large_icon_service.h" | 20 #include "components/favicon/core/large_icon_service.h" |
| 20 #include "components/favicon_base/fallback_icon_style.h" | 21 #include "components/favicon_base/fallback_icon_style.h" |
| 21 #include "components/favicon_base/favicon_types.h" | 22 #include "components/favicon_base/favicon_types.h" |
| 22 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 23 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
| 23 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" | 24 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" |
| 24 #include "ios/chrome/browser/experimental_flags.h" | 25 #include "ios/chrome/browser/experimental_flags.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 439 |
| 439 // The node has not changed, but its children have. | 440 // The node has not changed, but its children have. |
| 440 - (void)bookmarkNodeChildrenChanged:(const BookmarkNode*)bookmarkNode { | 441 - (void)bookmarkNodeChildrenChanged:(const BookmarkNode*)bookmarkNode { |
| 441 // The base folder's children changed. Reload everything. | 442 // The base folder's children changed. Reload everything. |
| 442 if (bookmarkNode == self.folder) { | 443 if (bookmarkNode == self.folder) { |
| 443 [self updateCollectionView]; | 444 [self updateCollectionView]; |
| 444 return; | 445 return; |
| 445 } | 446 } |
| 446 | 447 |
| 447 // A subfolder's children changed. Reload that cell. | 448 // A subfolder's children changed. Reload that cell. |
| 448 std::vector<const BookmarkNode*>::iterator it = | 449 if (base::ContainsValue(_subFolders, bookmarkNode)) { |
| 449 std::find(_subFolders.begin(), _subFolders.end(), bookmarkNode); | |
| 450 if (it != _subFolders.end()) { | |
| 451 // TODO(crbug.com/603661): Ideally, we would only reload the relevant index | 450 // TODO(crbug.com/603661): Ideally, we would only reload the relevant index |
| 452 // path. However, calling reloadItemsAtIndexPaths:(0,0) immediately after | 451 // path. However, calling reloadItemsAtIndexPaths:(0,0) immediately after |
| 453 // reloadData results in a exception: NSInternalInconsistencyException | 452 // reloadData results in a exception: NSInternalInconsistencyException |
| 454 // 'request for index path for global index 2147483645 ...' | 453 // 'request for index path for global index 2147483645 ...' |
| 455 // One solution would be to keep track of whether we've just called | 454 // One solution would be to keep track of whether we've just called |
| 456 // reloadData, but that requires experimentation to determine how long we | 455 // reloadData, but that requires experimentation to determine how long we |
| 457 // have to wait before we can safely call reloadItemsAtIndexPaths. | 456 // have to wait before we can safely call reloadItemsAtIndexPaths. |
| 458 [self updateCollectionView]; | 457 [self updateCollectionView]; |
| 459 } | 458 } |
| 460 } | 459 } |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 | 1246 |
| 1248 - (BOOL)shouldShowPromoCell { | 1247 - (BOOL)shouldShowPromoCell { |
| 1249 return _promoVisible; | 1248 return _promoVisible; |
| 1250 } | 1249 } |
| 1251 | 1250 |
| 1252 - (BOOL)isPromoActive { | 1251 - (BOOL)isPromoActive { |
| 1253 return NO; | 1252 return NO; |
| 1254 } | 1253 } |
| 1255 | 1254 |
| 1256 @end | 1255 @end |
| OLD | NEW |