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

Side by Side Diff: content/browser/web_contents/web_drag_dest_mac.mm

Issue 10783037: Don't send a DragLeave to the renderer if we didn't send a DragEnter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/web_contents/web_drag_dest_mac.h" 5 #import "content/browser/web_contents/web_drag_dest_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 8
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "content/browser/renderer_host/render_view_host_impl.h" 10 #include "content/browser/renderer_host/render_view_host_impl.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // hear back from the renderer. For now, be optimistic: 135 // hear back from the renderer. For now, be optimistic:
136 currentOperation_ = NSDragOperationCopy; 136 currentOperation_ = NSDragOperationCopy;
137 return currentOperation_; 137 return currentOperation_;
138 } 138 }
139 139
140 - (void)draggingExited:(id<NSDraggingInfo>)info { 140 - (void)draggingExited:(id<NSDraggingInfo>)info {
141 DCHECK(currentRVH_); 141 DCHECK(currentRVH_);
142 if (currentRVH_ != webContents_->GetRenderViewHost()) 142 if (currentRVH_ != webContents_->GetRenderViewHost())
143 return; 143 return;
144 144
145 // Nothing to do in the interstitial case. 145 if ([self onlyAllowsNavigation]) {
sky 2012/07/18 20:58:43 no {}
146 return;
147 }
146 148
147 if (delegate_) 149 if (delegate_)
148 delegate_->OnDragLeave(); 150 delegate_->OnDragLeave();
149 151
150 webContents_->GetRenderViewHost()->DragTargetDragLeave(); 152 webContents_->GetRenderViewHost()->DragTargetDragLeave();
151 dropData_.reset(); 153 dropData_.reset();
152 } 154 }
153 155
154 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info 156 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info
155 view:(NSView*)view { 157 view:(NSView*)view {
(...skipping 24 matching lines...) Expand all
180 182
181 return currentOperation_; 183 return currentOperation_;
182 } 184 }
183 185
184 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info 186 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info
185 view:(NSView*)view { 187 view:(NSView*)view {
186 if (currentRVH_ != webContents_->GetRenderViewHost()) 188 if (currentRVH_ != webContents_->GetRenderViewHost())
187 [self draggingEntered:info view:view]; 189 [self draggingEntered:info view:view];
188 190
189 // Check if we only allow navigation and navigate to a url on the pasteboard. 191 // Check if we only allow navigation and navigate to a url on the pasteboard.
190 BOOL result = YES;
191 if ([self onlyAllowsNavigation]) { 192 if ([self onlyAllowsNavigation]) {
192 NSPasteboard* pboard = [info draggingPasteboard]; 193 NSPasteboard* pboard = [info draggingPasteboard];
193 if ([pboard containsURLData]) { 194 if ([pboard containsURLData]) {
194 GURL url; 195 GURL url;
195 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES); 196 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES);
196 webContents_->OpenURL(OpenURLParams( 197 webContents_->OpenURL(OpenURLParams(
197 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK, 198 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK,
198 false)); 199 false));
200 return YES;
199 } else { 201 } else {
200 result = NO; 202 return NO;
201 } 203 }
202 } else {
203 if (delegate_)
204 delegate_->OnDrop();
205 } 204 }
206 205
206 if (delegate_)
207 delegate_->OnDrop();
208
207 currentRVH_ = NULL; 209 currentRVH_ = NULL;
208 210
209 // Create the appropriate mouse locations for WebCore. The draggingLocation 211 // Create the appropriate mouse locations for WebCore. The draggingLocation
210 // is in window coordinates. Both need to be flipped. 212 // is in window coordinates. Both need to be flipped.
211 NSPoint windowPoint = [info draggingLocation]; 213 NSPoint windowPoint = [info draggingLocation];
212 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; 214 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
213 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; 215 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
214 webContents_->GetRenderViewHost()->DragTargetDrop( 216 webContents_->GetRenderViewHost()->DragTargetDrop(
215 gfx::Point(viewPoint.x, viewPoint.y), 217 gfx::Point(viewPoint.x, viewPoint.y),
216 gfx::Point(screenPoint.x, screenPoint.y), 218 gfx::Point(screenPoint.x, screenPoint.y),
217 GetModifierFlags()); 219 GetModifierFlags());
218 220
219 dropData_.reset(); 221 dropData_.reset();
220 222
221 return result; 223 return YES;
222 } 224 }
223 225
224 // Given |data|, which should not be nil, fill it in using the contents of the 226 // Given |data|, which should not be nil, fill it in using the contents of the
225 // given pasteboard. The types handled by this method should be kept in sync 227 // given pasteboard. The types handled by this method should be kept in sync
226 // with [WebContentsViewCocoa registerDragTypes]. 228 // with [WebContentsViewCocoa registerDragTypes].
227 - (void)populateWebDropData:(WebDropData*)data 229 - (void)populateWebDropData:(WebDropData*)data
228 fromPasteboard:(NSPasteboard*)pboard { 230 fromPasteboard:(NSPasteboard*)pboard {
229 DCHECK(data); 231 DCHECK(data);
230 DCHECK(pboard); 232 DCHECK(pboard);
231 NSArray* types = [pboard types]; 233 NSArray* types = [pboard types];
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // Get custom MIME data. 278 // Get custom MIME data.
277 if ([types containsObject:ui::kWebCustomDataPboardType]) { 279 if ([types containsObject:ui::kWebCustomDataPboardType]) {
278 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; 280 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType];
279 ui::ReadCustomDataIntoMap([customData bytes], 281 ui::ReadCustomDataIntoMap([customData bytes],
280 [customData length], 282 [customData length],
281 &data->custom_data); 283 &data->custom_data);
282 } 284 }
283 } 285 }
284 286
285 @end 287 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698