Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3105)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm

Issue 8404022: Fix yet another crash with bookmarks drag&drop on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm
index f9c54ca0fc1a9f2371f98aeedb9680079c13e9c4..b1e08106863ee5a9fc0d89048e2bfd9ebb19adee 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm
@@ -222,20 +222,19 @@
[data getBytes:&button length:sizeof(button)];
// If we're dragging from one profile to another, disallow moving (only
- // allow copying). Note that we need to call |GetOriginalProfile()| to make
- // sure that Incognito profiles are handled correctly.
- NSWindow* source_window = [[button delegate] browserWindow];
- BrowserWindowController* source_window_controller =
- [BrowserWindowController
- browserWindowControllerForWindow:source_window];
- const Profile* source_profile =
- [source_window_controller profile]->GetOriginalProfile();
- const Profile* target_profile =
- [controller_ bookmarkModel]->profile()->GetOriginalProfile();
+ // allow copying). Each profile has its own bookmark model, so one way to
+ // check whether we are dragging across profiles is to see if the
+ // |BookmarkNode| corresponding to |button| exists in this profile. If it
+ // does, we're dragging within a profile; otherwise, we're dragging across
+ // profiles.
+ const BookmarkModel* const model = [[self controller] bookmarkModel];
+ const BookmarkNode* const source_node = [button bookmarkNode];
+ const BookmarkNode* const target_node =
+ model->GetNodeByID(source_node->id());
BOOL copy =
!([info draggingSourceOperationMask] & NSDragOperationMove) ||
- source_profile != target_profile;
+ (source_node != target_node);
rtn = [controller_ dragButton:button
to:[info draggingLocation]
copy:copy];

Powered by Google App Engine
This is Rietveld 408576698