OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
6 | 6 |
7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" |
11 #import "chrome/browser/bookmarks/chrome_bookmark_client.h" | 11 #import "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 12 #import "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
12 #import "chrome/browser/profiles/profile.h" | 13 #import "chrome/browser/profiles/profile.h" |
13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" | 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" |
16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h" |
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h" |
18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 20 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
20 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" | 21 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" |
21 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 22 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 destIndex = [button bookmarkNode]->child_count(); | 1254 destIndex = [button bookmarkNode]->child_count(); |
1254 } else { | 1255 } else { |
1255 // Else we're dropping somewhere in the folder, so find the right spot. | 1256 // Else we're dropping somewhere in the folder, so find the right spot. |
1256 destParent = [parentButton_ bookmarkNode]; | 1257 destParent = [parentButton_ bookmarkNode]; |
1257 destIndex = [self indexForDragToPoint:point]; | 1258 destIndex = [self indexForDragToPoint:point]; |
1258 // Be careful if the number of buttons != number of nodes. | 1259 // Be careful if the number of buttons != number of nodes. |
1259 destIndex += [[parentButton_ cell] startingChildIndex]; | 1260 destIndex += [[parentButton_ cell] startingChildIndex]; |
1260 } | 1261 } |
1261 | 1262 |
1262 ChromeBookmarkClient* client = | 1263 ChromeBookmarkClient* client = |
1263 BookmarkModelFactory::GetChromeBookmarkClientForProfile(profile_); | 1264 ChromeBookmarkClientFactory::GetForProfile(profile_); |
1264 if (!client->CanBeEditedByUser(destParent)) | 1265 if (!client->CanBeEditedByUser(destParent)) |
1265 return NO; | 1266 return NO; |
1266 if (!client->CanBeEditedByUser(sourceNode)) | 1267 if (!client->CanBeEditedByUser(sourceNode)) |
1267 copy = YES; | 1268 copy = YES; |
1268 | 1269 |
1269 // Prevent cycles. | 1270 // Prevent cycles. |
1270 BOOL wasCopiedOrMoved = NO; | 1271 BOOL wasCopiedOrMoved = NO; |
1271 if (!destParent->HasAncestor(sourceNode)) { | 1272 if (!destParent->HasAncestor(sourceNode)) { |
1272 if (copy) | 1273 if (copy) |
1273 [self bookmarkModel]->Copy(sourceNode, destParent, destIndex); | 1274 [self bookmarkModel]->Copy(sourceNode, destParent, destIndex); |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 destIndex = [button bookmarkNode]->child_count(); | 1819 destIndex = [button bookmarkNode]->child_count(); |
1819 } else { | 1820 } else { |
1820 // Else we're dropping somewhere in the folder, so find the right spot. | 1821 // Else we're dropping somewhere in the folder, so find the right spot. |
1821 destParent = [parentButton_ bookmarkNode]; | 1822 destParent = [parentButton_ bookmarkNode]; |
1822 destIndex = [self indexForDragToPoint:point]; | 1823 destIndex = [self indexForDragToPoint:point]; |
1823 // Be careful if the number of buttons != number of nodes. | 1824 // Be careful if the number of buttons != number of nodes. |
1824 destIndex += [[parentButton_ cell] startingChildIndex]; | 1825 destIndex += [[parentButton_ cell] startingChildIndex]; |
1825 } | 1826 } |
1826 | 1827 |
1827 ChromeBookmarkClient* client = | 1828 ChromeBookmarkClient* client = |
1828 BookmarkModelFactory::GetChromeBookmarkClientForProfile(profile_); | 1829 ChromeBookmarkClientFactory::GetForProfile(profile_); |
1829 if (!client->CanBeEditedByUser(destParent)) | 1830 if (!client->CanBeEditedByUser(destParent)) |
1830 return NO; | 1831 return NO; |
1831 | 1832 |
1832 // Create and add the new bookmark nodes. | 1833 // Create and add the new bookmark nodes. |
1833 size_t urlCount = [urls count]; | 1834 size_t urlCount = [urls count]; |
1834 for (size_t i = 0; i < urlCount; ++i) { | 1835 for (size_t i = 0; i < urlCount; ++i) { |
1835 GURL gurl; | 1836 GURL gurl; |
1836 const char* string = [[urls objectAtIndex:i] UTF8String]; | 1837 const char* string = [[urls objectAtIndex:i] UTF8String]; |
1837 if (string) | 1838 if (string) |
1838 gurl = GURL(string); | 1839 gurl = GURL(string); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 | 1991 |
1991 - (void)setIgnoreAnimations:(BOOL)ignore { | 1992 - (void)setIgnoreAnimations:(BOOL)ignore { |
1992 ignoreAnimations_ = ignore; | 1993 ignoreAnimations_ = ignore; |
1993 } | 1994 } |
1994 | 1995 |
1995 - (BookmarkButton*)buttonThatMouseIsIn { | 1996 - (BookmarkButton*)buttonThatMouseIsIn { |
1996 return buttonThatMouseIsIn_; | 1997 return buttonThatMouseIsIn_; |
1997 } | 1998 } |
1998 | 1999 |
1999 @end // BookmarkBarFolderController | 2000 @end // BookmarkBarFolderController |
OLD | NEW |