| 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_edit_view_controller.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_edit_view_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/ios/block_types.h" | 11 #include "base/ios/block_types.h" |
| 12 #include "base/ios/weak_nsobject.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/mac/bind_objc_block.h" | 14 #include "base/mac/bind_objc_block.h" |
| 14 #import "base/mac/foundation_util.h" | 15 #import "base/mac/foundation_util.h" |
| 15 | 16 #include "base/mac/objc_property_releaser.h" |
| 16 #include "base/mac/scoped_cftyperef.h" | 17 #include "base/mac/scoped_cftyperef.h" |
| 18 #include "base/mac/scoped_nsobject.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 18 #include "components/bookmarks/browser/bookmark_model.h" | 20 #include "components/bookmarks/browser/bookmark_model.h" |
| 19 #include "components/url_formatter/url_fixer.h" | 21 #include "components/url_formatter/url_fixer.h" |
| 20 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 22 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
| 21 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 23 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 22 #import "ios/chrome/browser/ui/bookmarks/bookmark_elevated_toolbar.h" | 24 #import "ios/chrome/browser/ui/bookmarks/bookmark_elevated_toolbar.h" |
| 23 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h" | 25 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h" |
| 24 #import "ios/chrome/browser/ui/bookmarks/bookmark_folder_view_controller.h" | 26 #import "ios/chrome/browser/ui/bookmarks/bookmark_folder_view_controller.h" |
| 25 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" | 27 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" |
| 26 #import "ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.h" | 28 #import "ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.h" |
| 27 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 29 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
| 28 #import "ios/chrome/browser/ui/bookmarks/cells/bookmark_parent_folder_item.h" | 30 #import "ios/chrome/browser/ui/bookmarks/cells/bookmark_parent_folder_item.h" |
| 29 #import "ios/chrome/browser/ui/bookmarks/cells/bookmark_text_field_item.h" | 31 #import "ios/chrome/browser/ui/bookmarks/cells/bookmark_text_field_item.h" |
| 30 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 32 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 31 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 33 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
| 32 #import "ios/chrome/browser/ui/image_util.h" | 34 #import "ios/chrome/browser/ui/image_util.h" |
| 33 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" | 35 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" |
| 34 #include "ios/chrome/browser/ui/rtl_geometry.h" | 36 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 35 #include "ios/chrome/browser/ui/ui_util.h" | 37 #include "ios/chrome/browser/ui/ui_util.h" |
| 36 #include "ios/chrome/grit/ios_strings.h" | 38 #include "ios/chrome/grit/ios_strings.h" |
| 37 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 39 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 38 #import "ios/public/provider/chrome/browser/ui/text_field_styling.h" | 40 #import "ios/public/provider/chrome/browser/ui/text_field_styling.h" |
| 39 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 41 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 40 #import "ios/third_party/material_components_ios/src/components/ShadowElevations
/src/MaterialShadowElevations.h" | 42 #import "ios/third_party/material_components_ios/src/components/ShadowElevations
/src/MaterialShadowElevations.h" |
| 41 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/
MaterialShadowLayer.h" | 43 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/
MaterialShadowLayer.h" |
| 42 #include "ui/base/l10n/l10n_util_mac.h" | 44 #include "ui/base/l10n/l10n_util_mac.h" |
| 43 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
| 44 #include "url/gurl.h" | 46 #include "url/gurl.h" |
| 45 | 47 |
| 46 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 47 #error "This file requires ARC support." | |
| 48 #endif | |
| 49 | |
| 50 using bookmarks::BookmarkModel; | 48 using bookmarks::BookmarkModel; |
| 51 using bookmarks::BookmarkNode; | 49 using bookmarks::BookmarkNode; |
| 52 | 50 |
| 53 namespace { | 51 namespace { |
| 54 // Converts NSString entered by the user to a GURL. | 52 // Converts NSString entered by the user to a GURL. |
| 55 GURL ConvertUserDataToGURL(NSString* urlString) { | 53 GURL ConvertUserDataToGURL(NSString* urlString) { |
| 56 if (urlString) { | 54 if (urlString) { |
| 57 return url_formatter::FixupURL(base::SysNSStringToUTF8(urlString), | 55 return url_formatter::FixupURL(base::SysNSStringToUTF8(urlString), |
| 58 std::string()); | 56 std::string()); |
| 59 } else { | 57 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 } // namespace | 71 } // namespace |
| 74 | 72 |
| 75 @interface BookmarkEditViewController ()<BookmarkFolderViewControllerDelegate, | 73 @interface BookmarkEditViewController ()<BookmarkFolderViewControllerDelegate, |
| 76 BookmarkModelBridgeObserver, | 74 BookmarkModelBridgeObserver, |
| 77 BookmarkTextFieldItemDelegate, | 75 BookmarkTextFieldItemDelegate, |
| 78 TextFieldValidation> { | 76 TextFieldValidation> { |
| 79 // Flag to ignore bookmark model changes notifications. | 77 // Flag to ignore bookmark model changes notifications. |
| 80 BOOL _ignoresBookmarkModelChanges; | 78 BOOL _ignoresBookmarkModelChanges; |
| 81 | 79 |
| 82 std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge; | 80 std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge; |
| 81 |
| 82 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkEditViewController; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // The bookmark this controller displays or edits. | 85 // The bookmark this controller displays or edits. |
| 86 // Redefined to be readwrite. | 86 // Redefined to be readwrite. |
| 87 @property(nonatomic, assign) const BookmarkNode* bookmark; | 87 @property(nonatomic, assign) const BookmarkNode* bookmark; |
| 88 | 88 |
| 89 // Reference to the bookmark model. | 89 // Reference to the bookmark model. |
| 90 @property(nonatomic, assign) BookmarkModel* bookmarkModel; | 90 @property(nonatomic, assign) BookmarkModel* bookmarkModel; |
| 91 | 91 |
| 92 // The parent of the bookmark. This may be different from |bookmark->parent()| | 92 // The parent of the bookmark. This may be different from |bookmark->parent()| |
| 93 // if the changes have not been saved yet. |folder| then represents the | 93 // if the changes have not been saved yet. |folder| then represents the |
| 94 // candidate for the new parent of |bookmark|. This property is always a | 94 // candidate for the new parent of |bookmark|. This property is always a |
| 95 // non-NULL, valid folder. | 95 // non-NULL, valid folder. |
| 96 @property(nonatomic, assign) const BookmarkNode* folder; | 96 @property(nonatomic, assign) const BookmarkNode* folder; |
| 97 | 97 |
| 98 // The folder picker view controller. | 98 // The folder picker view controller. |
| 99 // Redefined to be readwrite. | 99 // Redefined to be readwrite. |
| 100 @property(nonatomic, strong) BookmarkFolderViewController* folderViewController; | 100 @property(nonatomic, retain) BookmarkFolderViewController* folderViewController; |
| 101 | 101 |
| 102 @property(nonatomic, assign) ios::ChromeBrowserState* browserState; | 102 @property(nonatomic, assign) ios::ChromeBrowserState* browserState; |
| 103 | 103 |
| 104 // Cancel button item in navigation bar. | 104 // Cancel button item in navigation bar. |
| 105 @property(nonatomic, strong) UIBarButtonItem* cancelItem; | 105 @property(nonatomic, retain) UIBarButtonItem* cancelItem; |
| 106 | 106 |
| 107 // Done button item in navigation bar. | 107 // Done button item in navigation bar. |
| 108 @property(nonatomic, strong) UIBarButtonItem* doneItem; | 108 @property(nonatomic, retain) UIBarButtonItem* doneItem; |
| 109 | 109 |
| 110 // CollectionViewItem-s from the collection. | 110 // CollectionViewItem-s from the collection. |
| 111 @property(nonatomic, strong) BookmarkTextFieldItem* nameItem; | 111 @property(nonatomic, retain) BookmarkTextFieldItem* nameItem; |
| 112 @property(nonatomic, strong) BookmarkParentFolderItem* folderItem; | 112 @property(nonatomic, retain) BookmarkParentFolderItem* folderItem; |
| 113 @property(nonatomic, strong) BookmarkTextFieldItem* URLItem; | 113 @property(nonatomic, retain) BookmarkTextFieldItem* URLItem; |
| 114 | 114 |
| 115 // Reports the changes to the delegate, that has the responsibility to save the | 115 // Reports the changes to the delegate, that has the responsibility to save the |
| 116 // bookmark. | 116 // bookmark. |
| 117 - (void)commitBookmarkChanges; | 117 - (void)commitBookmarkChanges; |
| 118 | 118 |
| 119 // Changes |self.folder| and updates the UI accordingly. | 119 // Changes |self.folder| and updates the UI accordingly. |
| 120 // The change is not committed until the user taps the Save button. | 120 // The change is not committed until the user taps the Save button. |
| 121 - (void)changeFolder:(const BookmarkNode*)folder; | 121 - (void)changeFolder:(const BookmarkNode*)folder; |
| 122 | 122 |
| 123 // The Save button is disabled if the form values are deemed non-valid. This | 123 // The Save button is disabled if the form values are deemed non-valid. This |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 @synthesize URLItem = _URLItem; | 161 @synthesize URLItem = _URLItem; |
| 162 | 162 |
| 163 #pragma mark - Lifecycle | 163 #pragma mark - Lifecycle |
| 164 | 164 |
| 165 - (instancetype)initWithBookmark:(const BookmarkNode*)bookmark | 165 - (instancetype)initWithBookmark:(const BookmarkNode*)bookmark |
| 166 browserState:(ios::ChromeBrowserState*)browserState { | 166 browserState:(ios::ChromeBrowserState*)browserState { |
| 167 DCHECK(bookmark); | 167 DCHECK(bookmark); |
| 168 DCHECK(browserState); | 168 DCHECK(browserState); |
| 169 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; | 169 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; |
| 170 if (self) { | 170 if (self) { |
| 171 _propertyReleaser_BookmarkEditViewController.Init( |
| 172 self, [BookmarkEditViewController class]); |
| 171 DCHECK(!bookmark->is_folder()); | 173 DCHECK(!bookmark->is_folder()); |
| 172 DCHECK(!browserState->IsOffTheRecord()); | 174 DCHECK(!browserState->IsOffTheRecord()); |
| 173 _bookmark = bookmark; | 175 _bookmark = bookmark; |
| 174 _bookmarkModel = | 176 _bookmarkModel = |
| 175 ios::BookmarkModelFactory::GetForBrowserState(browserState); | 177 ios::BookmarkModelFactory::GetForBrowserState(browserState); |
| 176 | 178 |
| 177 _folder = bookmark->parent(); | 179 _folder = bookmark->parent(); |
| 178 | 180 |
| 179 // Set up the bookmark model oberver. | 181 // Set up the bookmark model oberver. |
| 180 _modelBridge.reset( | 182 _modelBridge.reset( |
| 181 new bookmarks::BookmarkModelBridge(self, _bookmarkModel)); | 183 new bookmarks::BookmarkModelBridge(self, _bookmarkModel)); |
| 182 | 184 |
| 183 _browserState = browserState; | 185 _browserState = browserState; |
| 184 } | 186 } |
| 185 return self; | 187 return self; |
| 186 } | 188 } |
| 187 | 189 |
| 188 - (void)dealloc { | 190 - (void)dealloc { |
| 189 _folderViewController.delegate = nil; | 191 _folderViewController.delegate = nil; |
| 192 [super dealloc]; |
| 190 } | 193 } |
| 191 | 194 |
| 192 #pragma mark View lifecycle | 195 #pragma mark View lifecycle |
| 193 | 196 |
| 194 - (void)viewDidLoad { | 197 - (void)viewDidLoad { |
| 195 [super viewDidLoad]; | 198 [super viewDidLoad]; |
| 196 self.collectionView.backgroundColor = [UIColor whiteColor]; | 199 self.collectionView.backgroundColor = [UIColor whiteColor]; |
| 197 self.view.accessibilityIdentifier = @"Single Bookmark Editor"; | 200 self.view.accessibilityIdentifier = @"Single Bookmark Editor"; |
| 198 | 201 |
| 199 self.title = l10n_util::GetNSString(IDS_IOS_BOOKMARK_EDIT_SCREEN_TITLE); | 202 self.title = l10n_util::GetNSString(IDS_IOS_BOOKMARK_EDIT_SCREEN_TITLE); |
| 200 | 203 |
| 201 self.navigationItem.hidesBackButton = YES; | 204 self.navigationItem.hidesBackButton = YES; |
| 202 | 205 |
| 203 UIBarButtonItem* cancelItem = | 206 UIBarButtonItem* cancelItem = |
| 204 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon closeIcon] | 207 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon closeIcon] |
| 205 target:self | 208 target:self |
| 206 action:@selector(cancel)]; | 209 action:@selector(cancel)]; |
| 207 cancelItem.accessibilityIdentifier = @"Cancel"; | 210 cancelItem.accessibilityIdentifier = @"Cancel"; |
| 208 self.navigationItem.leftBarButtonItem = cancelItem; | 211 self.navigationItem.leftBarButtonItem = cancelItem; |
| 209 self.cancelItem = cancelItem; | 212 self.cancelItem = cancelItem; |
| 210 | 213 |
| 211 UIBarButtonItem* doneItem = [[UIBarButtonItem alloc] | 214 base::scoped_nsobject<UIBarButtonItem> doneItem([[UIBarButtonItem alloc] |
| 212 initWithTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_DONE_BUTTON) | 215 initWithTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_DONE_BUTTON) |
| 213 style:UIBarButtonItemStylePlain | 216 style:UIBarButtonItemStylePlain |
| 214 target:self | 217 target:self |
| 215 action:@selector(save)]; | 218 action:@selector(save)]); |
| 216 doneItem.accessibilityIdentifier = @"Done"; | 219 doneItem.get().accessibilityIdentifier = @"Done"; |
| 217 self.navigationItem.rightBarButtonItem = doneItem; | 220 self.navigationItem.rightBarButtonItem = doneItem; |
| 218 self.doneItem = doneItem; | 221 self.doneItem = doneItem; |
| 219 | 222 |
| 220 BookmarksElevatedToolbar* buttonBar = [[BookmarksElevatedToolbar alloc] init]; | 223 base::scoped_nsobject<BookmarksElevatedToolbar> buttonBar( |
| 221 UIBarButtonItem* deleteItem = [[UIBarButtonItem alloc] | 224 [[BookmarksElevatedToolbar alloc] init]); |
| 225 base::scoped_nsobject<UIBarButtonItem> deleteItem([[UIBarButtonItem alloc] |
| 222 initWithTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_DELETE) | 226 initWithTitle:l10n_util::GetNSString(IDS_IOS_BOOKMARK_DELETE) |
| 223 style:UIBarButtonItemStylePlain | 227 style:UIBarButtonItemStylePlain |
| 224 target:self | 228 target:self |
| 225 action:@selector(deleteBookmark)]; | 229 action:@selector(deleteBookmark)]); |
| 226 deleteItem.accessibilityIdentifier = @"Delete_action"; | 230 deleteItem.get().accessibilityIdentifier = @"Delete_action"; |
| 227 [deleteItem setTitleTextAttributes:@{ | 231 [deleteItem setTitleTextAttributes:@{ |
| 228 NSForegroundColorAttributeName : [UIColor blackColor] | 232 NSForegroundColorAttributeName : [UIColor blackColor] |
| 229 } | 233 } |
| 230 forState:UIControlStateNormal]; | 234 forState:UIControlStateNormal]; |
| 231 [buttonBar.layer addSublayer:[[MDCShadowLayer alloc] init]]; | 235 [buttonBar.get().layer |
| 232 buttonBar.shadowElevation = MDCShadowElevationSearchBarResting; | 236 addSublayer:[[[MDCShadowLayer alloc] init] autorelease]]; |
| 233 buttonBar.backgroundColor = [UIColor whiteColor]; | 237 buttonBar.get().shadowElevation = MDCShadowElevationSearchBarResting; |
| 234 buttonBar.items = @[ deleteItem ]; | 238 buttonBar.get().backgroundColor = [UIColor whiteColor]; |
| 239 buttonBar.get().items = @[ deleteItem ]; |
| 235 [self.view addSubview:buttonBar]; | 240 [self.view addSubview:buttonBar]; |
| 236 | 241 |
| 237 // Constraint |buttonBar| to be in bottom | 242 // Constraint |buttonBar| to be in bottom |
| 238 buttonBar.translatesAutoresizingMaskIntoConstraints = NO; | 243 buttonBar.get().translatesAutoresizingMaskIntoConstraints = NO; |
| 239 [self.view addConstraints: | 244 [self.view addConstraints: |
| 240 [NSLayoutConstraint | 245 [NSLayoutConstraint |
| 241 constraintsWithVisualFormat:@"H:|[buttonBar]|" | 246 constraintsWithVisualFormat:@"H:|[buttonBar]|" |
| 242 options:0 | 247 options:0 |
| 243 metrics:nil | 248 metrics:nil |
| 244 views:NSDictionaryOfVariableBindings( | 249 views:NSDictionaryOfVariableBindings( |
| 245 buttonBar)]]; | 250 buttonBar)]]; |
| 246 [self.view addConstraint:[NSLayoutConstraint | 251 [self.view addConstraint:[NSLayoutConstraint |
| 247 constraintWithItem:buttonBar | 252 constraintWithItem:buttonBar |
| 248 attribute:NSLayoutAttributeBottom | 253 attribute:NSLayoutAttributeBottom |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 - (void)updateUIFromBookmark { | 341 - (void)updateUIFromBookmark { |
| 337 // If there is no current bookmark, don't update. | 342 // If there is no current bookmark, don't update. |
| 338 if (!self.bookmark) | 343 if (!self.bookmark) |
| 339 return; | 344 return; |
| 340 | 345 |
| 341 [self loadModel]; | 346 [self loadModel]; |
| 342 CollectionViewModel* model = self.collectionViewModel; | 347 CollectionViewModel* model = self.collectionViewModel; |
| 343 | 348 |
| 344 [model addSectionWithIdentifier:SectionIdentifierInfo]; | 349 [model addSectionWithIdentifier:SectionIdentifierInfo]; |
| 345 | 350 |
| 346 self.nameItem = [[BookmarkTextFieldItem alloc] initWithType:ItemTypeName]; | 351 self.nameItem = |
| 352 [[[BookmarkTextFieldItem alloc] initWithType:ItemTypeName] autorelease]; |
| 347 self.nameItem.accessibilityIdentifier = @"Title Field"; | 353 self.nameItem.accessibilityIdentifier = @"Title Field"; |
| 348 self.nameItem.placeholder = | 354 self.nameItem.placeholder = |
| 349 l10n_util::GetNSString(IDS_IOS_BOOKMARK_NAME_FIELD_HEADER); | 355 l10n_util::GetNSString(IDS_IOS_BOOKMARK_NAME_FIELD_HEADER); |
| 350 self.nameItem.text = bookmark_utils_ios::TitleForBookmarkNode(self.bookmark); | 356 self.nameItem.text = bookmark_utils_ios::TitleForBookmarkNode(self.bookmark); |
| 351 self.nameItem.delegate = self; | 357 self.nameItem.delegate = self; |
| 352 [model addItem:self.nameItem toSectionWithIdentifier:SectionIdentifierInfo]; | 358 [model addItem:self.nameItem toSectionWithIdentifier:SectionIdentifierInfo]; |
| 353 | 359 |
| 354 self.folderItem = | 360 self.folderItem = [[[BookmarkParentFolderItem alloc] |
| 355 [[BookmarkParentFolderItem alloc] initWithType:ItemTypeFolder]; | 361 initWithType:ItemTypeFolder] autorelease]; |
| 356 self.folderItem.title = bookmark_utils_ios::TitleForBookmarkNode(self.folder); | 362 self.folderItem.title = bookmark_utils_ios::TitleForBookmarkNode(self.folder); |
| 357 [model addItem:self.folderItem toSectionWithIdentifier:SectionIdentifierInfo]; | 363 [model addItem:self.folderItem toSectionWithIdentifier:SectionIdentifierInfo]; |
| 358 | 364 |
| 359 self.URLItem = [[BookmarkTextFieldItem alloc] initWithType:ItemTypeURL]; | 365 self.URLItem = |
| 366 [[[BookmarkTextFieldItem alloc] initWithType:ItemTypeURL] autorelease]; |
| 360 self.URLItem.accessibilityIdentifier = @"URL Field"; | 367 self.URLItem.accessibilityIdentifier = @"URL Field"; |
| 361 self.URLItem.placeholder = | 368 self.URLItem.placeholder = |
| 362 l10n_util::GetNSString(IDS_IOS_BOOKMARK_URL_FIELD_HEADER); | 369 l10n_util::GetNSString(IDS_IOS_BOOKMARK_URL_FIELD_HEADER); |
| 363 self.URLItem.text = base::SysUTF8ToNSString(self.bookmark->url().spec()); | 370 self.URLItem.text = base::SysUTF8ToNSString(self.bookmark->url().spec()); |
| 364 self.URLItem.delegate = self; | 371 self.URLItem.delegate = self; |
| 365 [model addItem:self.URLItem toSectionWithIdentifier:SectionIdentifierInfo]; | 372 [model addItem:self.URLItem toSectionWithIdentifier:SectionIdentifierInfo]; |
| 366 | 373 |
| 367 // Save button state. | 374 // Save button state. |
| 368 [self updateSaveButtonState]; | 375 [self updateSaveButtonState]; |
| 369 } | 376 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 396 } | 403 } |
| 397 [self.delegate bookmarkEditorWantsDismissal:self]; | 404 [self.delegate bookmarkEditorWantsDismissal:self]; |
| 398 } | 405 } |
| 399 | 406 |
| 400 - (void)moveBookmark { | 407 - (void)moveBookmark { |
| 401 DCHECK(self.bookmarkModel); | 408 DCHECK(self.bookmarkModel); |
| 402 DCHECK(!self.folderViewController); | 409 DCHECK(!self.folderViewController); |
| 403 | 410 |
| 404 std::set<const BookmarkNode*> editedNodes; | 411 std::set<const BookmarkNode*> editedNodes; |
| 405 editedNodes.insert(self.bookmark); | 412 editedNodes.insert(self.bookmark); |
| 406 BookmarkFolderViewController* folderViewController = | 413 base::scoped_nsobject<BookmarkFolderViewController> folderViewController( |
| 407 [[BookmarkFolderViewController alloc] | 414 [[BookmarkFolderViewController alloc] |
| 408 initWithBookmarkModel:self.bookmarkModel | 415 initWithBookmarkModel:self.bookmarkModel |
| 409 allowsNewFolders:YES | 416 allowsNewFolders:YES |
| 410 editedNodes:editedNodes | 417 editedNodes:editedNodes |
| 411 allowsCancel:NO | 418 allowsCancel:NO |
| 412 selectedFolder:self.folder]; | 419 selectedFolder:self.folder]); |
| 413 folderViewController.delegate = self; | 420 folderViewController.get().delegate = self; |
| 414 self.folderViewController = folderViewController; | 421 self.folderViewController = folderViewController; |
| 415 | 422 |
| 416 [self.navigationController pushViewController:self.folderViewController | 423 [self.navigationController pushViewController:self.folderViewController |
| 417 animated:YES]; | 424 animated:YES]; |
| 418 } | 425 } |
| 419 | 426 |
| 420 - (void)cancel { | 427 - (void)cancel { |
| 421 [self dismiss]; | 428 [self dismiss]; |
| 422 } | 429 } |
| 423 | 430 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 if (!self.bookmarkModel->is_permanent_node(self.folder)) { | 576 if (!self.bookmarkModel->is_permanent_node(self.folder)) { |
| 570 [self changeFolder:self.bookmarkModel->mobile_node()]; | 577 [self changeFolder:self.bookmarkModel->mobile_node()]; |
| 571 } | 578 } |
| 572 | 579 |
| 573 [self.delegate bookmarkEditorWantsDismissal:self]; | 580 [self.delegate bookmarkEditorWantsDismissal:self]; |
| 574 } | 581 } |
| 575 | 582 |
| 576 #pragma mark - UIResponder | 583 #pragma mark - UIResponder |
| 577 | 584 |
| 578 - (NSArray*)keyCommands { | 585 - (NSArray*)keyCommands { |
| 579 __weak BookmarkEditViewController* weakSelf = self; | 586 base::WeakNSObject<BookmarkEditViewController> weakSelf(self); |
| 580 return @[ [UIKeyCommand cr_keyCommandWithInput:UIKeyInputEscape | 587 return @[ [UIKeyCommand cr_keyCommandWithInput:UIKeyInputEscape |
| 581 modifierFlags:Cr_UIKeyModifierNone | 588 modifierFlags:Cr_UIKeyModifierNone |
| 582 title:nil | 589 title:nil |
| 583 action:^{ | 590 action:^{ |
| 584 [weakSelf dismiss]; | 591 [weakSelf dismiss]; |
| 585 }] ]; | 592 }] ]; |
| 586 } | 593 } |
| 587 | 594 |
| 588 @end | 595 @end |
| OLD | NEW |