summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/location_bar_view_mac.mm
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 18:10:35 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 18:10:35 +0000
commite1e6a969571c97f94017a17e6b9734f97f92a0d4 (patch)
tree91415097f2bd079fd0ed453121c64299b3ee8328 /chrome/browser/cocoa/location_bar_view_mac.mm
parent13a7e81b0e0ea980e91a03d5beda2c274283c910 (diff)
downloadchromium_src-e1e6a969571c97f94017a17e6b9734f97f92a0d4.zip
chromium_src-e1e6a969571c97f94017a17e6b9734f97f92a0d4.tar.gz
chromium_src-e1e6a969571c97f94017a17e6b9734f97f92a0d4.tar.bz2
[Mac] Location icon in omnibox as drag source.
Wire up location icon to allow dragging if the user click-drags or click-holds. Otherwise falls through to the page-info display. BUG=37865 TEST=When omnibox shows an URL, click-drag the globe initiates an URL drag. TEST=Drop it in web content. TEST=Drop it in safari. TEST=Drop it on bookmark bar. Review URL: http://codereview.chromium.org/1567023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/location_bar_view_mac.mm')
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm23
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index 7079471..c2c10dd 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -41,6 +41,7 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "skia/ext/skia_utils_mac.h"
+#import "third_party/mozilla/include/NSPasteboard+Utils.h"
// TODO(shess): This code is mostly copied from the gtk
@@ -600,6 +601,8 @@ LocationBarViewMac::LocationIconView::LocationIconView(
LocationBarViewMac::LocationIconView::~LocationIconView() {}
void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) {
+ // TODO(shess): Only allow click if page-info makes sense.
+ // http://codereview.chromium.org/1594012
TabContents* tab = owner_->GetTabContents();
NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
if (!nav_entry) {
@@ -609,6 +612,26 @@ void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) {
tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
}
+bool LocationBarViewMac::LocationIconView::IsDraggable() {
+ // TODO(shess): Only allow drag if there's an URL to drag.
+ // http://codereview.chromium.org/1594012
+ return true;
+}
+
+NSPasteboard* LocationBarViewMac::LocationIconView::GetDragPasteboard() {
+ TabContents* tab = owner_->GetTabContents();
+ DCHECK(tab);
+
+ NSString* url = base::SysUTF8ToNSString(tab->GetURL().spec());
+ NSString* title = base::SysUTF16ToNSString(tab->GetTitle());
+
+ NSPasteboard* pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ [pboard declareURLPasteboardWithAdditionalTypes:[NSArray array]
+ owner:nil];
+ [pboard setDataForURL:url title:title];
+ return pboard;
+}
+
// StarIconView-----------------------------------------------------------------
LocationBarViewMac::StarIconView::StarIconView(CommandUpdater* command_updater)