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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_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_folder_view.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.mm
index b8931f24e3cc798f6c670a94ea00efa032eebcb3..5d487dc80a60010cde98496ed4baaeb743d7f462 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.mm
@@ -187,20 +187,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 =
- [[self 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);
doDrag = [[self controller] dragButton:button
to:[info draggingLocation]
copy:copy];
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.cc ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698