Commit 9a4f067c authored by avi@chromium.org's avatar avi@chromium.org

Move Mac's WebDragDest to content.

BUG=95573
TEST=no change in functionality

Review URL: http://codereview.chromium.org/8440001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108165 0039d316-1c4b-4281-b951-d872f2087c98
parent b61cfcaa
...@@ -28,8 +28,8 @@ class RenderViewContextMenuMac; ...@@ -28,8 +28,8 @@ class RenderViewContextMenuMac;
class SkBitmap; class SkBitmap;
class TabContentsViewMac; class TabContentsViewMac;
class WebDragBookmarkHandlerMac; class WebDragBookmarkHandlerMac;
@class WebDragDest;
@class WebDragSource; @class WebDragSource;
@class WebDropTarget;
namespace gfx { namespace gfx {
class Point; class Point;
} }
...@@ -38,7 +38,7 @@ class Point; ...@@ -38,7 +38,7 @@ class Point;
@private @private
TabContentsViewMac* tabContentsView_; // WEAK; owns us TabContentsViewMac* tabContentsView_; // WEAK; owns us
scoped_nsobject<WebDragSource> dragSource_; scoped_nsobject<WebDragSource> dragSource_;
scoped_nsobject<WebDropTarget> dropTarget_; scoped_nsobject<WebDragDest> dragDest_;
scoped_ptr<WebDragBookmarkHandlerMac> bookmarkHandler_; scoped_ptr<WebDragBookmarkHandlerMac> bookmarkHandler_;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "chrome/browser/tab_contents/web_drag_bookmark_handler_mac.h" #include "chrome/browser/tab_contents/web_drag_bookmark_handler_mac.h"
#import "chrome/browser/ui/cocoa/focus_tracker.h" #import "chrome/browser/ui/cocoa/focus_tracker.h"
#import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h"
#import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h"
#import "chrome/browser/ui/cocoa/view_id_util.h" #import "chrome/browser/ui/cocoa/view_id_util.h"
#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_view_host_factory.h"
...@@ -23,6 +22,7 @@ ...@@ -23,6 +22,7 @@
#include "content/browser/tab_contents/popup_menu_helper_mac.h" #include "content/browser/tab_contents/popup_menu_helper_mac.h"
#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_delegate.h" #include "content/browser/tab_contents/tab_contents_delegate.h"
#import "content/browser/tab_contents/web_drag_dest_mac.h"
#import "content/browser/tab_contents/web_drag_source_mac.h" #import "content/browser/tab_contents/web_drag_source_mac.h"
#import "content/common/chrome_application_mac.h" #import "content/common/chrome_application_mac.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
...@@ -419,10 +419,10 @@ void TabContentsViewMac::Observe(int type, ...@@ -419,10 +419,10 @@ void TabContentsViewMac::Observe(int type,
self = [super initWithFrame:NSZeroRect]; self = [super initWithFrame:NSZeroRect];
if (self != nil) { if (self != nil) {
tabContentsView_ = w; tabContentsView_ = w;
dropTarget_.reset( dragDest_.reset(
[[WebDropTarget alloc] initWithTabContents:[self tabContents]]); [[WebDragDest alloc] initWithTabContents:[self tabContents]]);
bookmarkHandler_.reset(new WebDragBookmarkHandlerMac); bookmarkHandler_.reset(new WebDragBookmarkHandlerMac);
[dropTarget_ setDragDelegate: [dragDest_ setDragDelegate:
static_cast<content::WebDragDestDelegate*>(bookmarkHandler_.get())]; static_cast<content::WebDragDestDelegate*>(bookmarkHandler_.get())];
[self registerDragTypes]; [self registerDragTypes];
// TabContentsViewCocoa's ViewID may be changed to VIEW_ID_DEV_TOOLS_DOCKED // TabContentsViewCocoa's ViewID may be changed to VIEW_ID_DEV_TOOLS_DOCKED
...@@ -461,7 +461,7 @@ void TabContentsViewMac::Observe(int type, ...@@ -461,7 +461,7 @@ void TabContentsViewMac::Observe(int type,
} }
- (void)setCurrentDragOperation:(NSDragOperation)operation { - (void)setCurrentDragOperation:(NSDragOperation)operation {
[dropTarget_ setCurrentOperation:operation]; [dragDest_ setCurrentOperation:operation];
} }
- (TabContents*)tabContents { - (TabContents*)tabContents {
...@@ -557,19 +557,19 @@ void TabContentsViewMac::Observe(int type, ...@@ -557,19 +557,19 @@ void TabContentsViewMac::Observe(int type,
// NSDraggingDestination methods // NSDraggingDestination methods
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender { - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
return [dropTarget_ draggingEntered:sender view:self]; return [dragDest_ draggingEntered:sender view:self];
} }
- (void)draggingExited:(id<NSDraggingInfo>)sender { - (void)draggingExited:(id<NSDraggingInfo>)sender {
[dropTarget_ draggingExited:sender]; [dragDest_ draggingExited:sender];
} }
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender { - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
return [dropTarget_ draggingUpdated:sender view:self]; return [dragDest_ draggingUpdated:sender view:self];
} }
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
return [dropTarget_ performDragOperation:sender view:self]; return [dragDest_ performDragOperation:sender view:self];
} }
- (void)cancelDeferredClose { - (void)cancelDeferredClose {
......
...@@ -2810,8 +2810,6 @@ ...@@ -2810,8 +2810,6 @@
'browser/ui/cocoa/tab_contents/sad_tab_view.mm', 'browser/ui/cocoa/tab_contents/sad_tab_view.mm',
'browser/ui/cocoa/tab_contents/tab_contents_controller.h', 'browser/ui/cocoa/tab_contents/tab_contents_controller.h',
'browser/ui/cocoa/tab_contents/tab_contents_controller.mm', 'browser/ui/cocoa/tab_contents/tab_contents_controller.mm',
'browser/ui/cocoa/tab_contents/web_drop_target.h',
'browser/ui/cocoa/tab_contents/web_drop_target.mm',
'browser/ui/cocoa/tab_view_picker_table.h', 'browser/ui/cocoa/tab_view_picker_table.h',
'browser/ui/cocoa/tab_view_picker_table.mm', 'browser/ui/cocoa/tab_view_picker_table.mm',
'browser/ui/cocoa/table_row_nsimage_cache.h', 'browser/ui/cocoa/table_row_nsimage_cache.h',
...@@ -4402,8 +4400,6 @@ ...@@ -4402,8 +4400,6 @@
'../third_party/molokocacao/NSBezierPath+MCAdditions.h', '../third_party/molokocacao/NSBezierPath+MCAdditions.h',
'../third_party/molokocacao/NSBezierPath+MCAdditions.m', '../third_party/molokocacao/NSBezierPath+MCAdditions.m',
# Build necessary Mozilla sources # Build necessary Mozilla sources
'../third_party/mozilla/NSPasteboard+Utils.h',
'../third_party/mozilla/NSPasteboard+Utils.mm',
'../third_party/mozilla/NSScreen+Utils.h', '../third_party/mozilla/NSScreen+Utils.h',
'../third_party/mozilla/NSScreen+Utils.m', '../third_party/mozilla/NSScreen+Utils.m',
'../third_party/mozilla/NSString+Utils.h', '../third_party/mozilla/NSString+Utils.h',
......
...@@ -1762,7 +1762,6 @@ ...@@ -1762,7 +1762,6 @@
'browser/ui/cocoa/tab_contents/previewable_contents_controller_unittest.mm', 'browser/ui/cocoa/tab_contents/previewable_contents_controller_unittest.mm',
'browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm', 'browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm',
'browser/ui/cocoa/tab_contents/sad_tab_view_unittest.mm', 'browser/ui/cocoa/tab_contents/sad_tab_view_unittest.mm',
'browser/ui/cocoa/tab_contents/web_drop_target_unittest.mm',
'browser/ui/cocoa/tab_view_picker_table_unittest.mm', 'browser/ui/cocoa/tab_view_picker_table_unittest.mm',
'browser/ui/cocoa/table_row_nsimage_cache_unittest.mm', 'browser/ui/cocoa/table_row_nsimage_cache_unittest.mm',
'browser/ui/cocoa/tabpose_window_unittest.mm', 'browser/ui/cocoa/tabpose_window_unittest.mm',
......
...@@ -22,7 +22,7 @@ typedef RenderViewHost* RenderViewHostIdentifier; ...@@ -22,7 +22,7 @@ typedef RenderViewHost* RenderViewHostIdentifier;
// over the content area. Assumes something else initiates the drag, this is // over the content area. Assumes something else initiates the drag, this is
// only for processing during a drag. // only for processing during a drag.
@interface WebDropTarget : NSObject { @interface WebDragDest : NSObject {
@private @private
// Our associated TabContents. Weak reference. // Our associated TabContents. Weak reference.
TabContents* tabContents_; TabContents* tabContents_;
...@@ -64,7 +64,7 @@ typedef RenderViewHost* RenderViewHostIdentifier; ...@@ -64,7 +64,7 @@ typedef RenderViewHost* RenderViewHostIdentifier;
@end @end
// Public use only for unit tests. // Public use only for unit tests.
@interface WebDropTarget(Testing) @interface WebDragDest(Testing)
// Given |data|, which should not be nil, fill it in using the contents of the // Given |data|, which should not be nil, fill it in using the contents of the
// given pasteboard. // given pasteboard.
- (void)populateWebDropData:(WebDropData*)data - (void)populateWebDropData:(WebDropData*)data
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" #import "content/browser/tab_contents/web_drag_dest_mac.h"
#include "base/sys_string_conversions.h" #include "base/sys_string_conversions.h"
#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host.h"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
using WebKit::WebDragOperationsMask; using WebKit::WebDragOperationsMask;
@implementation WebDropTarget @implementation WebDragDest
// |contents| is the TabContents representing this tab, used to communicate // |contents| is the TabContents representing this tab, used to communicate
// drag&drop messages to WebCore and handle navigation on a successful drop // drag&drop messages to WebCore and handle navigation on a successful drop
...@@ -33,7 +33,7 @@ using WebKit::WebDragOperationsMask; ...@@ -33,7 +33,7 @@ using WebKit::WebDragOperationsMask;
// Call to set whether or not we should allow the drop. Takes effect the // Call to set whether or not we should allow the drop. Takes effect the
// next time |-draggingUpdated:| is called. // next time |-draggingUpdated:| is called.
- (void)setCurrentOperation: (NSDragOperation)operation { - (void)setCurrentOperation:(NSDragOperation)operation {
current_operation_ = operation; current_operation_ = operation;
} }
......
...@@ -6,21 +6,20 @@ ...@@ -6,21 +6,20 @@
#import "base/memory/scoped_nsobject.h" #import "base/memory/scoped_nsobject.h"
#include "base/sys_string_conversions.h" #include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h" #include "content/browser/renderer_host/test_render_view_host.h"
#import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "content/browser/tab_contents/test_tab_contents.h" #include "content/browser/tab_contents/test_tab_contents.h"
#import "content/browser/tab_contents/web_drag_dest_mac.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#import "third_party/mozilla/NSPasteboard+Utils.h" #import "third_party/mozilla/NSPasteboard+Utils.h"
#import "ui/base/dragdrop/cocoa_dnd_util.h" #import "ui/base/dragdrop/cocoa_dnd_util.h"
#import "ui/base/test/ui_cocoa_test_helper.h"
#include "webkit/glue/webdropdata.h" #include "webkit/glue/webdropdata.h"
class WebDropTargetTest : public ChromeRenderViewHostTestHarness { class WebDragDestTest : public RenderViewHostTestHarness {
public: public:
virtual void SetUp() { virtual void SetUp() {
ChromeRenderViewHostTestHarness::SetUp(); RenderViewHostTestHarness::SetUp();
CocoaTest::BootstrapCocoa(); drag_dest_.reset([[WebDragDest alloc] initWithTabContents:contents()]);
drop_target_.reset([[WebDropTarget alloc] initWithTabContents:contents()]);
} }
void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) { void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) {
...@@ -45,24 +44,24 @@ class WebDropTargetTest : public ChromeRenderViewHostTestHarness { ...@@ -45,24 +44,24 @@ class WebDropTargetTest : public ChromeRenderViewHostTestHarness {
} }
base::mac::ScopedNSAutoreleasePool pool_; base::mac::ScopedNSAutoreleasePool pool_;
scoped_nsobject<WebDropTarget> drop_target_; scoped_nsobject<WebDragDest> drag_dest_;
}; };
// Make sure nothing leaks. // Make sure nothing leaks.
TEST_F(WebDropTargetTest, Init) { TEST_F(WebDragDestTest, Init) {
EXPECT_TRUE(drop_target_); EXPECT_TRUE(drag_dest_);
} }
// Test flipping of coordinates given a point in window coordinates. // Test flipping of coordinates given a point in window coordinates.
TEST_F(WebDropTargetTest, Flip) { TEST_F(WebDragDestTest, Flip) {
NSPoint windowPoint = NSZeroPoint; NSPoint windowPoint = NSZeroPoint;
scoped_nsobject<NSWindow> window([[CocoaTestHelperWindow alloc] init]); scoped_nsobject<NSWindow> window([[CocoaTestHelperWindow alloc] init]);
NSPoint viewPoint = NSPoint viewPoint =
[drop_target_ flipWindowPointToView:windowPoint [drag_dest_ flipWindowPointToView:windowPoint
view:[window contentView]]; view:[window contentView]];
NSPoint screenPoint = NSPoint screenPoint =
[drop_target_ flipWindowPointToScreen:windowPoint [drag_dest_ flipWindowPointToScreen:windowPoint
view:[window contentView]]; view:[window contentView]];
EXPECT_EQ(0, viewPoint.x); EXPECT_EQ(0, viewPoint.x);
EXPECT_EQ(600, viewPoint.y); EXPECT_EQ(600, viewPoint.y);
EXPECT_EQ(0, screenPoint.x); EXPECT_EQ(0, screenPoint.x);
...@@ -71,7 +70,7 @@ TEST_F(WebDropTargetTest, Flip) { ...@@ -71,7 +70,7 @@ TEST_F(WebDropTargetTest, Flip) {
EXPECT_NE(0, screenPoint.y); EXPECT_NE(0, screenPoint.y);
} }
TEST_F(WebDropTargetTest, URL) { TEST_F(WebDragDestTest, URL) {
NSPasteboard* pboard = nil; NSPasteboard* pboard = nil;
NSString* url = nil; NSString* url = nil;
NSString* title = nil; NSString* title = nil;
...@@ -135,7 +134,7 @@ TEST_F(WebDropTargetTest, URL) { ...@@ -135,7 +134,7 @@ TEST_F(WebDropTargetTest, URL) {
[pboard releaseGlobally]; [pboard releaseGlobally];
} }
TEST_F(WebDropTargetTest, Data) { TEST_F(WebDragDestTest, Data) {
WebDropData data; WebDropData data;
NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName]; NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName];
...@@ -147,7 +146,7 @@ TEST_F(WebDropTargetTest, Data) { ...@@ -147,7 +146,7 @@ TEST_F(WebDropTargetTest, Data) {
NSString* textString = @"hi there"; NSString* textString = @"hi there";
[pboard setString:htmlString forType:NSHTMLPboardType]; [pboard setString:htmlString forType:NSHTMLPboardType];
[pboard setString:textString forType:NSStringPboardType]; [pboard setString:textString forType:NSStringPboardType];
[drop_target_ populateWebDropData:&data fromPasteboard:pboard]; [drag_dest_ populateWebDropData:&data fromPasteboard:pboard];
EXPECT_EQ(data.url.spec(), "http://www.google.com/"); EXPECT_EQ(data.url.spec(), "http://www.google.com/");
EXPECT_EQ(base::SysNSStringToUTF16(textString), data.plain_text); EXPECT_EQ(base::SysNSStringToUTF16(textString), data.plain_text);
EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.text_html); EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.text_html);
......
...@@ -541,6 +541,8 @@ ...@@ -541,6 +541,8 @@
'browser/tab_contents/web_drag_dest_delegate.h', 'browser/tab_contents/web_drag_dest_delegate.h',
'browser/tab_contents/web_drag_dest_gtk.cc', 'browser/tab_contents/web_drag_dest_gtk.cc',
'browser/tab_contents/web_drag_dest_gtk.h', 'browser/tab_contents/web_drag_dest_gtk.h',
'browser/tab_contents/web_drag_dest_mac.h',
'browser/tab_contents/web_drag_dest_mac.mm',
'browser/tab_contents/web_drag_source_gtk.cc', 'browser/tab_contents/web_drag_source_gtk.cc',
'browser/tab_contents/web_drag_source_gtk.h', 'browser/tab_contents/web_drag_source_gtk.h',
'browser/tab_contents/web_drag_source_mac.h', 'browser/tab_contents/web_drag_source_mac.h',
...@@ -670,6 +672,8 @@ ...@@ -670,6 +672,8 @@
# Build necessary Mozilla sources # Build necessary Mozilla sources
'../third_party/mozilla/ComplexTextInputPanel.h', '../third_party/mozilla/ComplexTextInputPanel.h',
'../third_party/mozilla/ComplexTextInputPanel.mm', '../third_party/mozilla/ComplexTextInputPanel.mm',
'../third_party/mozilla/NSPasteboard+Utils.h',
'../third_party/mozilla/NSPasteboard+Utils.mm',
], ],
'link_settings': { 'link_settings': {
'mac_bundle_resources': [ 'mac_bundle_resources': [
......
...@@ -188,6 +188,7 @@ ...@@ -188,6 +188,7 @@
'browser/ssl/ssl_host_state_unittest.cc', 'browser/ssl/ssl_host_state_unittest.cc',
'browser/tab_contents/navigation_entry_unittest.cc', 'browser/tab_contents/navigation_entry_unittest.cc',
'browser/tab_contents/tab_contents_delegate_unittest.cc', 'browser/tab_contents/tab_contents_delegate_unittest.cc',
'browser/tab_contents/web_drag_dest_mac_unittest.mm',
'browser/trace_subscriber_stdio_unittest.cc', 'browser/trace_subscriber_stdio_unittest.cc',
'common/mac/attributed_string_coder_unittest.mm', 'common/mac/attributed_string_coder_unittest.mm',
'common/mac/font_descriptor_unittest.mm', 'common/mac/font_descriptor_unittest.mm',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment