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