| 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 30 matching lines...) Expand all Loading... |
| 52 BookmarkEditViewControllerDelegate, | 52 BookmarkEditViewControllerDelegate, |
| 53 BookmarkFolderCollectionViewDelegate, | 53 BookmarkFolderCollectionViewDelegate, |
| 54 BookmarkFolderEditorViewControllerDelegate, | 54 BookmarkFolderEditorViewControllerDelegate, |
| 55 BookmarkFolderViewControllerDelegate, | 55 BookmarkFolderViewControllerDelegate, |
| 56 BookmarkMenuViewDelegate, | 56 BookmarkMenuViewDelegate, |
| 57 BookmarkModelBridgeObserver, | 57 BookmarkModelBridgeObserver, |
| 58 BookmarkPanelViewDelegate, | 58 BookmarkPanelViewDelegate, |
| 59 BookmarkPromoControllerDelegate> { | 59 BookmarkPromoControllerDelegate> { |
| 60 // Bridge to register for bookmark changes. | 60 // Bridge to register for bookmark changes. |
| 61 std::unique_ptr<bookmarks::BookmarkModelBridge> _bridge; | 61 std::unique_ptr<bookmarks::BookmarkModelBridge> _bridge; |
| 62 base::mac::ObjCPropertyReleaser | |
| 63 _propertyReleaser_BookmarkHomeHandsetViewController; | |
| 64 } | 62 } |
| 65 | 63 |
| 66 // This views holds the primary content of this view controller. At any point in | 64 // This views holds the primary content of this view controller. At any point in |
| 67 // time, it contains exactly one of the BookmarkCollectionView subclasses. | 65 // time, it contains exactly one of the BookmarkCollectionView subclasses. |
| 68 @property(nonatomic, retain) UIView* contentView; | 66 @property(nonatomic, retain) UIView* contentView; |
| 69 // The possible views that can be shown from the menu. | 67 // The possible views that can be shown from the menu. |
| 70 @property(nonatomic, retain) BookmarkFolderCollectionView* folderView; | 68 @property(nonatomic, retain) BookmarkFolderCollectionView* folderView; |
| 71 // This view is created and used if the model is not fully loaded yet by the | 69 // This view is created and used if the model is not fully loaded yet by the |
| 72 // time this controller starts. | 70 // time this controller starts. |
| 73 @property(nonatomic, retain) BookmarkHomeWaitingView* waitForModelView; | 71 @property(nonatomic, retain) BookmarkHomeWaitingView* waitForModelView; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 @synthesize folderEditor = _folderEditor; | 230 @synthesize folderEditor = _folderEditor; |
| 233 | 231 |
| 234 @synthesize panelView = _panelView; | 232 @synthesize panelView = _panelView; |
| 235 @synthesize scrollingMenuToTop = _scrollingMenuToTop; | 233 @synthesize scrollingMenuToTop = _scrollingMenuToTop; |
| 236 @synthesize bookmarkPromoController = _bookmarkPromoController; | 234 @synthesize bookmarkPromoController = _bookmarkPromoController; |
| 237 | 235 |
| 238 - (instancetype)initWithLoader:(id<UrlLoader>)loader | 236 - (instancetype)initWithLoader:(id<UrlLoader>)loader |
| 239 browserState:(ios::ChromeBrowserState*)browserState { | 237 browserState:(ios::ChromeBrowserState*)browserState { |
| 240 self = [super initWithLoader:loader browserState:browserState]; | 238 self = [super initWithLoader:loader browserState:browserState]; |
| 241 if (self) { | 239 if (self) { |
| 242 _propertyReleaser_BookmarkHomeHandsetViewController.Init( | |
| 243 self, [BookmarkHomeHandsetViewController class]); | |
| 244 | |
| 245 _bridge.reset(new bookmarks::BookmarkModelBridge(self, self.bookmarks)); | 240 _bridge.reset(new bookmarks::BookmarkModelBridge(self, self.bookmarks)); |
| 246 // It is important to initialize the promo controller with the browser state | 241 // It is important to initialize the promo controller with the browser state |
| 247 // passed in, as it could be incognito. | 242 // passed in, as it could be incognito. |
| 248 _bookmarkPromoController = | 243 _bookmarkPromoController = |
| 249 [[BookmarkPromoController alloc] initWithBrowserState:browserState | 244 [[BookmarkPromoController alloc] initWithBrowserState:browserState |
| 250 delegate:self]; | 245 delegate:self]; |
| 251 } | 246 } |
| 252 return self; | 247 return self; |
| 253 } | 248 } |
| 254 | 249 |
| 255 - (void)dealloc { | 250 - (void)dealloc { |
| 256 _folderView.delegate = nil; | 251 _folderView.delegate = nil; |
| 257 | 252 |
| 258 _menuView.delegate = nil; | 253 _menuView.delegate = nil; |
| 259 | 254 |
| 260 _editViewController.delegate = nil; | 255 _editViewController.delegate = nil; |
| 261 _folderSelector.delegate = nil; | 256 _folderSelector.delegate = nil; |
| 262 | 257 |
| 263 _panelView.delegate = nil; | 258 _panelView.delegate = nil; |
| 259 base::mac::ReleaseProperties(self); |
| 264 [super dealloc]; | 260 [super dealloc]; |
| 265 } | 261 } |
| 266 | 262 |
| 267 - (void)removeEditNode:(const BookmarkNode*)node | 263 - (void)removeEditNode:(const BookmarkNode*)node |
| 268 cell:(UICollectionViewCell*)cell { | 264 cell:(UICollectionViewCell*)cell { |
| 269 [super removeEditNode:node atIndexPath:[self indexPathForCell:cell]]; | 265 [super removeEditNode:node atIndexPath:[self indexPathForCell:cell]]; |
| 270 if (_editNodes.size() == 0) | 266 if (_editNodes.size() == 0) |
| 271 [self setEditing:NO animated:YES]; | 267 [self setEditing:NO animated:YES]; |
| 272 else | 268 else |
| 273 [self updateEditingStateAnimated:YES]; | 269 [self updateEditingStateAnimated:YES]; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 } | 1122 } |
| 1127 | 1123 |
| 1128 - (NSIndexPath*)indexPathForCell:(UICollectionViewCell*)cell { | 1124 - (NSIndexPath*)indexPathForCell:(UICollectionViewCell*)cell { |
| 1129 DCHECK([self primaryView].collectionView); | 1125 DCHECK([self primaryView].collectionView); |
| 1130 NSIndexPath* indexPath = | 1126 NSIndexPath* indexPath = |
| 1131 [[self primaryView].collectionView indexPathForCell:cell]; | 1127 [[self primaryView].collectionView indexPathForCell:cell]; |
| 1132 return indexPath; | 1128 return indexPath; |
| 1133 } | 1129 } |
| 1134 | 1130 |
| 1135 @end | 1131 @end |
| OLD | NEW |