Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_interaction_controller.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 - (void)dealloc { | 143 - (void)dealloc { |
| 144 _bookmarkBrowser.delegate = nil; | 144 _bookmarkBrowser.delegate = nil; |
| 145 _bookmarkEditor.delegate = nil; | 145 _bookmarkEditor.delegate = nil; |
| 146 } | 146 } |
| 147 | 147 |
| 148 - (void)addBookmarkForTab:(Tab*)tab { | 148 - (void)addBookmarkForTab:(Tab*)tab { |
| 149 base::RecordAction(base::UserMetricsAction("BookmarkAdded")); | 149 base::RecordAction(base::UserMetricsAction("BookmarkAdded")); |
| 150 const BookmarkNode* defaultFolder = | 150 const BookmarkNode* defaultFolder = |
| 151 [[self class] folderForNewBookmarksInBrowserState:_browserState]; | 151 [[self class] folderForNewBookmarksInBrowserState:_browserState]; |
| 152 self.bookmarkModel->AddURL(defaultFolder, defaultFolder->child_count(), | 152 self.bookmarkModel->AddURL(defaultFolder, defaultFolder->child_count(), |
| 153 base::SysNSStringToUTF16(tab.title), tab.url); | 153 base::SysNSStringToUTF16(tab.title), |
| 154 tab.lastCommittedURL); | |
|
Eugene But (OOO till 7-30)
2017/04/14 21:06:24
I checked that Desktop adds bookmark for lastCommi
| |
| 154 | 155 |
| 155 MDCSnackbarMessageAction* action = [[MDCSnackbarMessageAction alloc] init]; | 156 MDCSnackbarMessageAction* action = [[MDCSnackbarMessageAction alloc] init]; |
| 156 __weak BookmarkInteractionController* weakSelf = self; | 157 __weak BookmarkInteractionController* weakSelf = self; |
| 157 __weak Tab* weakTab = tab; | 158 __weak Tab* weakTab = tab; |
| 158 action.handler = ^{ | 159 action.handler = ^{ |
| 159 BookmarkInteractionController* strongSelf = weakSelf; | 160 BookmarkInteractionController* strongSelf = weakSelf; |
| 160 if (!strongSelf || !weakTab) | 161 if (!strongSelf || !weakTab) |
| 161 return; | 162 return; |
| 162 [strongSelf presentBookmarkForTab:weakTab]; | 163 [strongSelf presentBookmarkForTab:weakTab]; |
| 163 }; | 164 }; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 177 message.action = action; | 178 message.action = action; |
| 178 message.category = bookmark_utils_ios::kBookmarksSnackbarCategory; | 179 message.category = bookmark_utils_ios::kBookmarksSnackbarCategory; |
| 179 [MDCSnackbarManager showMessage:message]; | 180 [MDCSnackbarManager showMessage:message]; |
| 180 } | 181 } |
| 181 | 182 |
| 182 - (void)presentBookmarkForTab:(Tab*)tab { | 183 - (void)presentBookmarkForTab:(Tab*)tab { |
| 183 DCHECK(!self.bookmarkBrowser && !self.bookmarkEditor); | 184 DCHECK(!self.bookmarkBrowser && !self.bookmarkEditor); |
| 184 DCHECK(tab); | 185 DCHECK(tab); |
| 185 | 186 |
| 186 const BookmarkNode* bookmark = | 187 const BookmarkNode* bookmark = |
| 187 self.bookmarkModel->GetMostRecentlyAddedUserNodeForURL(tab.url); | 188 self.bookmarkModel->GetMostRecentlyAddedUserNodeForURL( |
| 189 tab.lastCommittedURL); | |
| 188 if (!bookmark) | 190 if (!bookmark) |
| 189 return; | 191 return; |
| 190 | 192 |
| 191 [self dismissSnackbar]; | 193 [self dismissSnackbar]; |
| 192 | 194 |
| 193 BookmarkEditViewController* bookmarkEditor = | 195 BookmarkEditViewController* bookmarkEditor = |
| 194 [[BookmarkEditViewController alloc] initWithBookmark:bookmark | 196 [[BookmarkEditViewController alloc] initWithBookmark:bookmark |
| 195 browserState:_browserState]; | 197 browserState:_browserState]; |
| 196 self.bookmarkEditor = bookmarkEditor; | 198 self.bookmarkEditor = bookmarkEditor; |
| 197 self.bookmarkEditor.delegate = self; | 199 self.bookmarkEditor.delegate = self; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 } else { | 299 } else { |
| 298 [_loader loadURL:url | 300 [_loader loadURL:url |
| 299 referrer:web::Referrer() | 301 referrer:web::Referrer() |
| 300 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK | 302 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK |
| 301 rendererInitiated:NO]; | 303 rendererInitiated:NO]; |
| 302 } | 304 } |
| 303 } | 305 } |
| 304 } | 306 } |
| 305 | 307 |
| 306 @end | 308 @end |
| OLD | NEW |