| 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_home_handset_view_controller.h
" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_handset_view_controller.h
" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/objc_property_releaser.h" | 11 #include "base/mac/objc_release_properties.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
| 14 #include "base/metrics/user_metrics_action.h" | 14 #include "base/metrics/user_metrics_action.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
| 17 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
| 18 #include "google_apis/gaia/google_service_auth_error.h" | 18 #include "google_apis/gaia/google_service_auth_error.h" |
| 19 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" | 19 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" |
| 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 21 #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" | 21 #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 BookmarkEditViewControllerDelegate, | 53 BookmarkEditViewControllerDelegate, |
| 54 BookmarkFolderCollectionViewDelegate, | 54 BookmarkFolderCollectionViewDelegate, |
| 55 BookmarkFolderEditorViewControllerDelegate, | 55 BookmarkFolderEditorViewControllerDelegate, |
| 56 BookmarkFolderViewControllerDelegate, | 56 BookmarkFolderViewControllerDelegate, |
| 57 BookmarkMenuViewDelegate, | 57 BookmarkMenuViewDelegate, |
| 58 BookmarkModelBridgeObserver, | 58 BookmarkModelBridgeObserver, |
| 59 BookmarkPanelViewDelegate, | 59 BookmarkPanelViewDelegate, |
| 60 BookmarkPromoControllerDelegate> { | 60 BookmarkPromoControllerDelegate> { |
| 61 // Bridge to register for bookmark changes. | 61 // Bridge to register for bookmark changes. |
| 62 std::unique_ptr<bookmarks::BookmarkModelBridge> _bridge; | 62 std::unique_ptr<bookmarks::BookmarkModelBridge> _bridge; |
| 63 base::mac::ObjCPropertyReleaser | |
| 64 _propertyReleaser_BookmarkHomeHandsetViewController; | |
| 65 } | 63 } |
| 66 | 64 |
| 67 // This views holds the primary content of this view controller. At any point in | 65 // This views holds the primary content of this view controller. At any point in |
| 68 // time, it contains exactly one of the BookmarkCollectionView subclasses. | 66 // time, it contains exactly one of the BookmarkCollectionView subclasses. |
| 69 @property(nonatomic, retain) UIView* contentView; | 67 @property(nonatomic, retain) UIView* contentView; |
| 70 // The possible views that can be shown from the menu. | 68 // The possible views that can be shown from the menu. |
| 71 @property(nonatomic, retain) BookmarkAllCollectionView* allItemsView; | 69 @property(nonatomic, retain) BookmarkAllCollectionView* allItemsView; |
| 72 @property(nonatomic, retain) BookmarkFolderCollectionView* folderView; | 70 @property(nonatomic, retain) BookmarkFolderCollectionView* folderView; |
| 73 // This view is created and used if the model is not fully loaded yet by the | 71 // This view is created and used if the model is not fully loaded yet by the |
| 74 // time this controller starts. | 72 // time this controller starts. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 @synthesize folderEditor = _folderEditor; | 234 @synthesize folderEditor = _folderEditor; |
| 237 | 235 |
| 238 @synthesize panelView = _panelView; | 236 @synthesize panelView = _panelView; |
| 239 @synthesize scrollingMenuToTop = _scrollingMenuToTop; | 237 @synthesize scrollingMenuToTop = _scrollingMenuToTop; |
| 240 @synthesize bookmarkPromoController = _bookmarkPromoController; | 238 @synthesize bookmarkPromoController = _bookmarkPromoController; |
| 241 | 239 |
| 242 - (instancetype)initWithLoader:(id<UrlLoader>)loader | 240 - (instancetype)initWithLoader:(id<UrlLoader>)loader |
| 243 browserState:(ios::ChromeBrowserState*)browserState { | 241 browserState:(ios::ChromeBrowserState*)browserState { |
| 244 self = [super initWithLoader:loader browserState:browserState]; | 242 self = [super initWithLoader:loader browserState:browserState]; |
| 245 if (self) { | 243 if (self) { |
| 246 _propertyReleaser_BookmarkHomeHandsetViewController.Init( | |
| 247 self, [BookmarkHomeHandsetViewController class]); | |
| 248 | |
| 249 _bridge.reset(new bookmarks::BookmarkModelBridge(self, self.bookmarks)); | 244 _bridge.reset(new bookmarks::BookmarkModelBridge(self, self.bookmarks)); |
| 250 // It is important to initialize the promo controller with the browser state | 245 // It is important to initialize the promo controller with the browser state |
| 251 // passed in, as it could be incognito. | 246 // passed in, as it could be incognito. |
| 252 _bookmarkPromoController = | 247 _bookmarkPromoController = |
| 253 [[BookmarkPromoController alloc] initWithBrowserState:browserState | 248 [[BookmarkPromoController alloc] initWithBrowserState:browserState |
| 254 delegate:self]; | 249 delegate:self]; |
| 255 } | 250 } |
| 256 return self; | 251 return self; |
| 257 } | 252 } |
| 258 | 253 |
| 259 - (void)dealloc { | 254 - (void)dealloc { |
| 260 _allItemsView.delegate = nil; | 255 _allItemsView.delegate = nil; |
| 261 _folderView.delegate = nil; | 256 _folderView.delegate = nil; |
| 262 | 257 |
| 263 _menuView.delegate = nil; | 258 _menuView.delegate = nil; |
| 264 | 259 |
| 265 _editViewController.delegate = nil; | 260 _editViewController.delegate = nil; |
| 266 _folderSelector.delegate = nil; | 261 _folderSelector.delegate = nil; |
| 267 | 262 |
| 268 _panelView.delegate = nil; | 263 _panelView.delegate = nil; |
| 264 base::mac::ReleaseProperties(self); |
| 269 [super dealloc]; | 265 [super dealloc]; |
| 270 } | 266 } |
| 271 | 267 |
| 272 - (void)removeEditNode:(const BookmarkNode*)node | 268 - (void)removeEditNode:(const BookmarkNode*)node |
| 273 cell:(UICollectionViewCell*)cell { | 269 cell:(UICollectionViewCell*)cell { |
| 274 [super removeEditNode:node atIndexPath:[self indexPathForCell:cell]]; | 270 [super removeEditNode:node atIndexPath:[self indexPathForCell:cell]]; |
| 275 if (_editNodes.size() == 0) | 271 if (_editNodes.size() == 0) |
| 276 [self setEditing:NO animated:YES]; | 272 [self setEditing:NO animated:YES]; |
| 277 else | 273 else |
| 278 [self updateEditingStateAnimated:YES]; | 274 [self updateEditingStateAnimated:YES]; |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 } | 1167 } |
| 1172 | 1168 |
| 1173 - (NSIndexPath*)indexPathForCell:(UICollectionViewCell*)cell { | 1169 - (NSIndexPath*)indexPathForCell:(UICollectionViewCell*)cell { |
| 1174 DCHECK([self primaryView].collectionView); | 1170 DCHECK([self primaryView].collectionView); |
| 1175 NSIndexPath* indexPath = | 1171 NSIndexPath* indexPath = |
| 1176 [[self primaryView].collectionView indexPathForCell:cell]; | 1172 [[self primaryView].collectionView indexPathForCell:cell]; |
| 1177 return indexPath; | 1173 return indexPath; |
| 1178 } | 1174 } |
| 1179 | 1175 |
| 1180 @end | 1176 @end |
| OLD | NEW |