summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-19 20:22:00 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-19 20:22:00 +0000
commit02bae0f37e6b09992f3b81792735010f28b9542e (patch)
treeb33485cba2d3f3049d7e801957759b268aa9257e /app
parentcfe1d619ca7f651c509ce4a4b52540fd573fbcd3 (diff)
downloadchromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.zip
chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.tar.gz
chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.tar.bz2
Move more dnd related files to ui/base
BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/6250014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/app.gyp2
-rw-r--r--app/app_base.gypi38
-rw-r--r--app/download_file_interface.h47
-rw-r--r--app/drag_drop_types.h31
-rw-r--r--app/drag_drop_types_gtk.cc31
-rw-r--r--app/drag_drop_types_win.cc30
-rw-r--r--app/gtk_dnd_util.cc263
-rw-r--r--app/gtk_dnd_util.h88
-rw-r--r--app/gtk_dnd_util_unittest.cc77
-rw-r--r--app/win/drag_source.cc57
-rw-r--r--app/win/drag_source.h58
-rw-r--r--app/win/drop_target.cc174
-rw-r--r--app/win/drop_target.h136
13 files changed, 22 insertions, 1010 deletions
diff --git a/app/app.gyp b/app/app.gyp
index de566ee..349bb0c 100644
--- a/app/app.gyp
+++ b/app/app.gyp
@@ -67,7 +67,7 @@
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
'sources': [
- 'gtk_dnd_util_unittest.cc',
+ '../ui/base/dragdrop/gtk_dnd_util_unittest.cc',
],
'dependencies': [
'app_unittest_strings',
diff --git a/app/app_base.gypi b/app/app_base.gypi
index e5faf0c..d8cb796 100644
--- a/app/app_base.gypi
+++ b/app/app_base.gypi
@@ -18,21 +18,21 @@
'../ui/base/models/tree_model.h',
'../ui/base/models/tree_node_iterator.h',
'../ui/base/models/tree_node_model.h',
- 'app_paths.h',
- 'app_paths.cc',
- 'app_switches.h',
- 'app_switches.cc',
'../ui/base/system_monitor/system_monitor.cc',
'../ui/base/system_monitor/system_monitor.h',
'../ui/base/system_monitor/system_monitor_mac.mm',
'../ui/base/system_monitor/system_monitor_posix.cc',
'../ui/base/system_monitor/system_monitor_win.cc',
+ 'app_paths.h',
+ 'app_paths.cc',
+ 'app_switches.h',
+ 'app_switches.cc',
],
'conditions': [
['OS!="linux" and OS!="freebsd" and OS!="openbsd"', {
'sources!': [
- 'gtk_dnd_util.cc',
- 'gtk_dnd_util.h',
+ '../ui/base/dragdrop/gtk_dnd_util.cc',
+ '../ui/base/dragdrop/gtk_dnd_util.h',
'gtk_signal.h',
'gtk_signal_registrar.cc',
'gtk_signal_registrar.h',
@@ -112,6 +112,15 @@
'../ui/base/clipboard/clipboard_win.cc',
'../ui/base/clipboard/scoped_clipboard_writer.cc',
'../ui/base/clipboard/scoped_clipboard_writer.h',
+ '../ui/base/dragdrop/drag_drop_types_gtk.cc',
+ '../ui/base/dragdrop/drag_drop_types_win.cc',
+ '../ui/base/dragdrop/drag_drop_types.h',
+ '../ui/base/dragdrop/drag_source.cc',
+ '../ui/base/dragdrop/drag_source.h',
+ '../ui/base/dragdrop/drop_target.cc',
+ '../ui/base/dragdrop/drop_target.h',
+ '../ui/base/dragdrop/gtk_dnd_util.cc',
+ '../ui/base/dragdrop/gtk_dnd_util.h',
'../ui/base/dragdrop/os_exchange_data_provider_gtk.cc',
'../ui/base/dragdrop/os_exchange_data_provider_gtk.h',
'../ui/base/dragdrop/os_exchange_data_provider_win.cc',
@@ -149,9 +158,6 @@
'bidi_line_iterator.cc',
'data_pack.cc',
'data_pack.h',
- 'drag_drop_types_gtk.cc',
- 'drag_drop_types_win.cc',
- 'drag_drop_types.h',
'event_synthesis_gtk.cc',
'event_synthesis_gtk.h',
'gfx/font_util.h',
@@ -174,8 +180,6 @@
'gfx/gl/gl_implementation_win.cc',
'gfx/gl/gl_interface.h',
'gfx/gl/gl_interface.cc',
- 'gtk_dnd_util.cc',
- 'gtk_dnd_util.h',
'gtk_signal.h',
'gtk_signal_registrar.cc',
'gtk_signal_registrar.h',
@@ -221,10 +225,6 @@
'theme_provider.h',
'view_prop.cc',
'view_prop.h',
- 'win/drag_source.cc',
- 'win/drag_source.h',
- 'win/drop_target.cc',
- 'win/drop_target.h',
'win/hwnd_util.cc',
'win/hwnd_util.h',
'win/iat_patch_function.cc',
@@ -299,11 +299,11 @@
# Note: because of gyp predence rules this has to be defined as
# 'sources/' rather than 'sources!'.
'sources/': [
+ ['exclude', '^../ui/base/dragdrop/drag_drop_types_gtk.cc'],
['exclude', '^../ui/base/dragdrop/os_exchange_data.cc'],
['exclude', '^../ui/base/dragdrop/os_exchange_data.h'],
['exclude', '^../ui/base/dragdrop/os_exchange_data_provider_gtk.cc'],
['exclude', '^../ui/base/dragdrop/os_exchange_data_provider_gtk.h'],
- ['exclude', '^drag_drop_types_gtk.cc'],
],
}],
['toolkit_views==1', {
@@ -317,8 +317,12 @@
}],
['OS!="win"', {
'sources!': [
+ '../ui/base/dragdrop/drag_source.cc',
+ '../ui/base/dragdrop/drag_source.h',
+ '../ui/base/dragdrop/drag_drop_types.h',
+ '../ui/base/dragdrop/drop_target.cc',
+ '../ui/base/dragdrop/drop_target.h',
'../ui/base/dragdrop/os_exchange_data.cc',
- 'drag_drop_types.h',
'gfx/gdi_util.cc',
'gfx/gdi_util.h',
'gfx/icon_util.cc',
diff --git a/app/download_file_interface.h b/app/download_file_interface.h
deleted file mode 100644
index ab90786..0000000
--- a/app/download_file_interface.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_DOWNLOAD_FILE_INTERFACE_H_
-#define APP_DOWNLOAD_FILE_INTERFACE_H_
-#pragma once
-
-#include "build/build_config.h"
-
-#include "base/basictypes.h"
-#include "base/ref_counted.h"
-
-#if defined(OS_WIN)
-#include <objidl.h>
-#endif
-
-class FilePath;
-
-// Defines the interface to observe the status of file download.
-class DownloadFileObserver
- : public base::RefCountedThreadSafe<DownloadFileObserver> {
- public:
- virtual void OnDownloadCompleted(const FilePath& file_path) = 0;
- virtual void OnDownloadAborted() = 0;
-
- protected:
- friend class base::RefCountedThreadSafe<DownloadFileObserver>;
- virtual ~DownloadFileObserver() {}
-};
-
-// Defines the interface to control how a file is downloaded.
-class DownloadFileProvider
- : public base::RefCountedThreadSafe<DownloadFileProvider> {
- public:
- virtual bool Start(DownloadFileObserver* observer) = 0;
- virtual void Stop() = 0;
-#if defined(OS_WIN)
- virtual IStream* GetStream() = 0;
-#endif
-
- protected:
- friend class base::RefCountedThreadSafe<DownloadFileProvider>;
- virtual ~DownloadFileProvider() {}
-};
-
-#endif // APP_DOWNLOAD_FILE_INTERFACE_H_
diff --git a/app/drag_drop_types.h b/app/drag_drop_types.h
deleted file mode 100644
index 74472f8..0000000
--- a/app/drag_drop_types.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_DRAG_DROP_TYPES_H_
-#define APP_DRAG_DROP_TYPES_H_
-#pragma once
-
-#include "build/build_config.h"
-
-#include "base/basictypes.h"
-
-class DragDropTypes {
- public:
- enum DragOperation {
- DRAG_NONE = 0,
- DRAG_MOVE = 1 << 0,
- DRAG_COPY = 1 << 1,
- DRAG_LINK = 1 << 2
- };
-
-#if defined(OS_WIN)
- static uint32 DragOperationToDropEffect(int drag_operation);
- static int DropEffectToDragOperation(uint32 effect);
-#elif !defined(OS_MACOSX)
- static int DragOperationToGdkDragAction(int drag_operation);
- static int GdkDragActionToDragOperation(int gdk_drag_action);
-#endif
-};
-
-#endif // APP_DRAG_DROP_TYPES_H_
diff --git a/app/drag_drop_types_gtk.cc b/app/drag_drop_types_gtk.cc
deleted file mode 100644
index 1cab322..0000000
--- a/app/drag_drop_types_gtk.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/drag_drop_types.h"
-
-#include <gtk/gtk.h>
-
-// static
-int DragDropTypes::DragOperationToGdkDragAction(int drag_operation) {
- int gdk_drag_action = 0;
- if (drag_operation & DRAG_MOVE)
- gdk_drag_action |= GDK_ACTION_MOVE;
- if (drag_operation & DRAG_COPY)
- gdk_drag_action |= GDK_ACTION_COPY;
- if (drag_operation & DRAG_LINK)
- gdk_drag_action |= GDK_ACTION_LINK;
- return gdk_drag_action;
-}
-
-// static
-int DragDropTypes::GdkDragActionToDragOperation(int gdk_drag_action) {
- int drag_operation = DRAG_NONE;
- if (gdk_drag_action & GDK_ACTION_COPY)
- drag_operation |= DRAG_COPY;
- if (gdk_drag_action & GDK_ACTION_MOVE)
- drag_operation |= DRAG_MOVE;
- if (gdk_drag_action & GDK_ACTION_LINK)
- drag_operation |= DRAG_LINK;
- return drag_operation;
-}
diff --git a/app/drag_drop_types_win.cc b/app/drag_drop_types_win.cc
deleted file mode 100644
index 5944868..0000000
--- a/app/drag_drop_types_win.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/drag_drop_types.h"
-
-#include <oleidl.h>
-
-int DragDropTypes::DropEffectToDragOperation(
- uint32 effect) {
- int drag_operation = DRAG_NONE;
- if (effect & DROPEFFECT_LINK)
- drag_operation |= DRAG_LINK;
- if (effect & DROPEFFECT_COPY)
- drag_operation |= DRAG_COPY;
- if (effect & DROPEFFECT_MOVE)
- drag_operation |= DRAG_MOVE;
- return drag_operation;
-}
-
-uint32 DragDropTypes::DragOperationToDropEffect(int drag_operation) {
- uint32 drop_effect = DROPEFFECT_NONE;
- if (drag_operation & DRAG_LINK)
- drop_effect |= DROPEFFECT_LINK;
- if (drag_operation & DRAG_COPY)
- drop_effect |= DROPEFFECT_COPY;
- if (drag_operation & DRAG_MOVE)
- drop_effect |= DROPEFFECT_MOVE;
- return drop_effect;
-}
diff --git a/app/gtk_dnd_util.cc b/app/gtk_dnd_util.cc
deleted file mode 100644
index 5df8151..0000000
--- a/app/gtk_dnd_util.cc
+++ /dev/null
@@ -1,263 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/gtk_dnd_util.h"
-
-#include <string>
-
-#include "base/logging.h"
-#include "base/pickle.h"
-#include "base/utf_string_conversions.h"
-#include "googleurl/src/gurl.h"
-
-static const int kBitsPerByte = 8;
-
-namespace {
-
-void AddTargetToList(GtkTargetList* targets, int target_code) {
- switch (target_code) {
- case gtk_dnd_util::TEXT_PLAIN:
- gtk_target_list_add_text_targets(targets, gtk_dnd_util::TEXT_PLAIN);
- break;
-
- case gtk_dnd_util::TEXT_URI_LIST:
- gtk_target_list_add_uri_targets(targets, gtk_dnd_util::TEXT_URI_LIST);
- break;
-
- case gtk_dnd_util::TEXT_HTML:
- gtk_target_list_add(
- targets, gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::TEXT_HTML),
- 0, gtk_dnd_util::TEXT_HTML);
- break;
-
- case gtk_dnd_util::NETSCAPE_URL:
- gtk_target_list_add(targets,
- gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::NETSCAPE_URL),
- 0, gtk_dnd_util::NETSCAPE_URL);
- break;
-
- case gtk_dnd_util::CHROME_TAB:
- case gtk_dnd_util::CHROME_BOOKMARK_ITEM:
- case gtk_dnd_util::CHROME_NAMED_URL:
- gtk_target_list_add(targets, gtk_dnd_util::GetAtomForTarget(target_code),
- GTK_TARGET_SAME_APP, target_code);
- break;
-
- case gtk_dnd_util::DIRECT_SAVE_FILE:
- gtk_target_list_add(targets,
- gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::DIRECT_SAVE_FILE),
- 0, gtk_dnd_util::DIRECT_SAVE_FILE);
- break;
-
- default:
- NOTREACHED() << " Unexpected target code: " << target_code;
- }
-}
-
-} // namespace
-
-namespace gtk_dnd_util {
-
-GdkAtom GetAtomForTarget(int target) {
- switch (target) {
- case CHROME_TAB:
- static GdkAtom tab_atom = gdk_atom_intern(
- const_cast<char*>("application/x-chrome-tab"), false);
- return tab_atom;
-
- case TEXT_HTML:
- static GdkAtom html_atom = gdk_atom_intern(
- const_cast<char*>("text/html"), false);
- return html_atom;
-
- case CHROME_BOOKMARK_ITEM:
- static GdkAtom bookmark_atom = gdk_atom_intern(
- const_cast<char*>("application/x-chrome-bookmark-item"), false);
- return bookmark_atom;
-
- case TEXT_PLAIN:
- static GdkAtom text_atom = gdk_atom_intern(
- const_cast<char*>("text/plain;charset=utf-8"), false);
- return text_atom;
-
- case TEXT_URI_LIST:
- static GdkAtom uris_atom = gdk_atom_intern(
- const_cast<char*>("text/uri-list"), false);
- return uris_atom;
-
- case CHROME_NAMED_URL:
- static GdkAtom named_url = gdk_atom_intern(
- const_cast<char*>("application/x-chrome-named-url"), false);
- return named_url;
-
- case NETSCAPE_URL:
- static GdkAtom netscape_url = gdk_atom_intern(
- const_cast<char*>("_NETSCAPE_URL"), false);
- return netscape_url;
-
- case TEXT_PLAIN_NO_CHARSET:
- static GdkAtom text_no_charset_atom = gdk_atom_intern(
- const_cast<char*>("text/plain"), false);
- return text_no_charset_atom;
-
- case DIRECT_SAVE_FILE:
- static GdkAtom xds_atom = gdk_atom_intern(
- const_cast<char*>("XdndDirectSave0"), false);
- return xds_atom;
-
- default:
- NOTREACHED();
- }
-
- return NULL;
-}
-
-GtkTargetList* GetTargetListFromCodeMask(int code_mask) {
- GtkTargetList* targets = gtk_target_list_new(NULL, 0);
-
- for (size_t i = 1; i < INVALID_TARGET; i = i << 1) {
- if (i == CHROME_WEBDROP_FILE_CONTENTS)
- continue;
-
- if (i & code_mask)
- AddTargetToList(targets, i);
- }
-
- return targets;
-}
-
-void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask) {
- GtkTargetList* targets = GetTargetListFromCodeMask(code_mask);
- gtk_drag_source_set_target_list(source, targets);
- gtk_target_list_unref(targets);
-}
-
-void SetDestTargetList(GtkWidget* dest, const int* target_codes) {
- GtkTargetList* targets = gtk_target_list_new(NULL, 0);
-
- for (size_t i = 0; target_codes[i] != -1; ++i) {
- AddTargetToList(targets, target_codes[i]);
- }
-
- gtk_drag_dest_set_target_list(dest, targets);
- gtk_target_list_unref(targets);
-}
-
-void WriteURLWithName(GtkSelectionData* selection_data,
- const GURL& url,
- string16 title,
- int type) {
- if (title.empty()) {
- // We prefer to not have empty titles. Set it to the filename extracted
- // from the URL.
- title = UTF8ToUTF16(url.ExtractFileName());
- }
-
- switch (type) {
- case TEXT_PLAIN: {
- gtk_selection_data_set_text(selection_data, url.spec().c_str(),
- url.spec().length());
- break;
- }
- case TEXT_URI_LIST: {
- gchar* uri_array[2];
- uri_array[0] = strdup(url.spec().c_str());
- uri_array[1] = NULL;
- gtk_selection_data_set_uris(selection_data, uri_array);
- free(uri_array[0]);
- break;
- }
- case CHROME_NAMED_URL: {
- Pickle pickle;
- pickle.WriteString(UTF16ToUTF8(title));
- pickle.WriteString(url.spec());
- gtk_selection_data_set(
- selection_data,
- GetAtomForTarget(gtk_dnd_util::CHROME_NAMED_URL),
- kBitsPerByte,
- reinterpret_cast<const guchar*>(pickle.data()),
- pickle.size());
- break;
- }
- case NETSCAPE_URL: {
- // _NETSCAPE_URL format is URL + \n + title.
- std::string utf8_text = url.spec() + "\n" + UTF16ToUTF8(title);
- gtk_selection_data_set(selection_data,
- selection_data->target,
- kBitsPerByte,
- reinterpret_cast<const guchar*>(utf8_text.c_str()),
- utf8_text.length());
- break;
- }
-
- default: {
- NOTREACHED();
- break;
- }
- }
-}
-
-bool ExtractNamedURL(GtkSelectionData* selection_data,
- GURL* url,
- string16* title) {
- if (!selection_data || selection_data->length <= 0)
- return false;
-
- Pickle data(reinterpret_cast<char*>(selection_data->data),
- selection_data->length);
- void* iter = NULL;
- std::string title_utf8, url_utf8;
- if (!data.ReadString(&iter, &title_utf8) ||
- !data.ReadString(&iter, &url_utf8)) {
- return false;
- }
-
- GURL gurl(url_utf8);
- if (!gurl.is_valid())
- return false;
-
- *url = gurl;
- *title = UTF8ToUTF16(title_utf8);
- return true;
-}
-
-bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) {
- gchar** uris = gtk_selection_data_get_uris(selection_data);
- if (!uris)
- return false;
-
- for (size_t i = 0; uris[i] != NULL; ++i) {
- GURL url(uris[i]);
- if (url.is_valid())
- urls->push_back(url);
- }
-
- g_strfreev(uris);
- return true;
-}
-
-bool ExtractNetscapeURL(GtkSelectionData* selection_data,
- GURL* url,
- string16* title) {
- if (!selection_data || selection_data->length <= 0)
- return false;
-
- // Find the first '\n' in the data. It is the separator between the url and
- // the title.
- std::string data(reinterpret_cast<char*>(selection_data->data),
- selection_data->length);
- std::string::size_type newline = data.find('\n');
- if (newline == std::string::npos)
- return false;
-
- GURL gurl(data.substr(0, newline));
- if (!gurl.is_valid())
- return false;
-
- *url = gurl;
- *title = UTF8ToUTF16(data.substr(newline + 1));
- return true;
-}
-
-} // namespace gtk_dnd_util
diff --git a/app/gtk_dnd_util.h b/app/gtk_dnd_util.h
deleted file mode 100644
index 2e6c275..0000000
--- a/app/gtk_dnd_util.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_GTK_DND_UTIL_H_
-#define APP_GTK_DND_UTIL_H_
-#pragma once
-
-#include <gtk/gtk.h>
-
-#include <vector>
-
-#include "base/string16.h"
-
-class GURL;
-
-namespace gtk_dnd_util {
-
-// Registry of all internal int codes for drag and drop.
-enum {
- // Intra-application types.
- CHROME_TAB = 1 << 0,
- CHROME_BOOKMARK_ITEM = 1 << 1,
- CHROME_WEBDROP_FILE_CONTENTS = 1 << 2,
- CHROME_NAMED_URL = 1 << 3,
-
- // Standard types.
- TEXT_PLAIN = 1 << 4,
- TEXT_URI_LIST = 1 << 5,
- TEXT_HTML = 1 << 6,
-
- // Other types. NETSCAPE_URL is provided for compatibility with other
- // apps.
- NETSCAPE_URL = 1 << 7,
-
- // Used for drag-out download.
- TEXT_PLAIN_NO_CHARSET = 1 << 8,
- DIRECT_SAVE_FILE = 1 << 9,
-
- INVALID_TARGET = 1 << 10,
-};
-
-// Get the atom for a given target (of the above enum type). Will return NULL
-// for non-custom targets, such as CHROME_TEXT_PLAIN.
-GdkAtom GetAtomForTarget(int target);
-
-// Creates a target list from the given mask. The mask should be an OR of
-// CHROME_* values. The target list is returned with ref count 1; the caller
-// is responsible for calling gtk_target_list_unref() when it is no longer
-// needed.
-// Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's
-// contents, that flag is ignored by this function. It is the responsibility
-// of the client code to do the right thing.
-GtkTargetList* GetTargetListFromCodeMask(int code_mask);
-
-// Set the drag target list for |source| with the target list that
-// corresponds to |code_mask|.
-void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask);
-
-// Set the accepted targets list for |dest|. The |target_codes| array should
-// be sorted in preference order and should be terminated with -1.
-void SetDestTargetList(GtkWidget* dest, const int* target_codes);
-
-// Write a URL to the selection in the given type.
-void WriteURLWithName(GtkSelectionData* selection_data,
- const GURL& url,
- string16 title,
- int type);
-
-// Extracts data of type CHROME_NAMED_URL from |selection_data| into
-// |url| and |title|. Returns true if the url/title were safely extracted
-// and the url is valid.
-bool ExtractNamedURL(GtkSelectionData* selection_data,
- GURL* url,
- string16* title);
-
-// Extracts data of type TEXT_URI_LIST from |selection_data| into |urls|.
-bool ExtractURIList(GtkSelectionData* selection_data,
- std::vector<GURL>* urls);
-
-// Extracts a Netscape URL (url\ntitle) from |selection_data|.
-bool ExtractNetscapeURL(GtkSelectionData* selection_data,
- GURL* url,
- string16* title);
-
-} // namespace gtk_dnd_util
-
-#endif // APP_GTK_DND_UTIL_H_
diff --git a/app/gtk_dnd_util_unittest.cc b/app/gtk_dnd_util_unittest.cc
deleted file mode 100644
index cefc6dd..0000000
--- a/app/gtk_dnd_util_unittest.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string>
-
-#include "app/gtk_dnd_util.h"
-#include "base/pickle.h"
-#include "base/scoped_ptr.h"
-#include "base/utf_string_conversions.h"
-#include "googleurl/src/gurl.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-TEST(GtkDndUtilTest, ExtractNamedURLValid) {
- const std::string kTitle = "title";
- const std::string kUrl = "http://www.foobar.com/";
- Pickle pickle;
- pickle.WriteString(kTitle);
- pickle.WriteString(kUrl);
-
- GtkSelectionData data;
- scoped_array<guchar> test_data(new guchar[pickle.size()]);
- memcpy(test_data.get(), pickle.data(), pickle.size());
- data.data = test_data.get();
- data.length = pickle.size();
-
- GURL url;
- string16 title;
- ASSERT_EQ(true, gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
- EXPECT_EQ(UTF8ToUTF16(kTitle), title);
- EXPECT_EQ(GURL(kUrl), url);
-}
-
-TEST(GtkDndUtilTest, ExtractNamedURLInvalidURL) {
- const std::string kTitle = "title";
- const std::string kBadUrl = "foobar";
- Pickle pickle;
- pickle.WriteString(kTitle);
- pickle.WriteString(kBadUrl);
-
- GtkSelectionData data;
- scoped_array<guchar> test_data(new guchar[pickle.size()]);
- memcpy(test_data.get(), pickle.data(), pickle.size());
- data.data = test_data.get();
- data.length = pickle.size();
-
- GURL url;
- string16 title;
- EXPECT_FALSE(gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
-}
-
-TEST(GtkDndUtilTest, ExtractNamedURLInvalidInput) {
- GURL url;
- string16 title;
- GtkSelectionData data;
- data.data = NULL;
- data.length = 0;
-
- EXPECT_FALSE(gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
-
- guchar empty_data[] = "";
- data.data = empty_data;
- data.length = 0;
-
- EXPECT_FALSE(gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
-
- const std::string kTitle = "title";
- Pickle pickle;
- pickle.WriteString(kTitle);
-
- scoped_array<guchar> test_data(new guchar[pickle.size()]);
- memcpy(test_data.get(), pickle.data(), pickle.size());
- data.data = test_data.get();
- data.length = pickle.size();
-
- EXPECT_FALSE(gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
-}
diff --git a/app/win/drag_source.cc b/app/win/drag_source.cc
deleted file mode 100644
index a695a33..0000000
--- a/app/win/drag_source.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/win/drag_source.h"
-
-namespace app {
-namespace win {
-
-DragSource::DragSource() : cancel_drag_(false) {
-}
-
-HRESULT DragSource::QueryContinueDrag(BOOL escape_pressed, DWORD key_state) {
- if (cancel_drag_)
- return DRAGDROP_S_CANCEL;
-
- if (escape_pressed) {
- OnDragSourceCancel();
- return DRAGDROP_S_CANCEL;
- }
-
- if (!(key_state & MK_LBUTTON)) {
- OnDragSourceDrop();
- return DRAGDROP_S_DROP;
- }
-
- OnDragSourceMove();
- return S_OK;
-}
-
-HRESULT DragSource::GiveFeedback(DWORD effect) {
- return DRAGDROP_S_USEDEFAULTCURSORS;
-}
-
-HRESULT DragSource::QueryInterface(const IID& iid, void** object) {
- *object = NULL;
- if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropSource)) {
- *object = this;
- } else {
- return E_NOINTERFACE;
- }
- AddRef();
- return S_OK;
-}
-
-ULONG DragSource::AddRef() {
- base::RefCountedThreadSafe<DragSource>::AddRef();
- return 0;
-}
-
-ULONG DragSource::Release() {
- base::RefCountedThreadSafe<DragSource>::Release();
- return 0;
-}
-
-} // namespace win
-} // namespace app
diff --git a/app/win/drag_source.h b/app/win/drag_source.h
deleted file mode 100644
index 75bee86..0000000
--- a/app/win/drag_source.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_WIN_DRAG_SOURCE_H_
-#define APP_WIN_DRAG_SOURCE_H_
-#pragma once
-
-#include <objidl.h>
-
-#include "base/basictypes.h"
-#include "base/ref_counted.h"
-
-namespace app {
-namespace win {
-
-// A base IDropSource implementation. Handles notifications sent by an active
-// drag-drop operation as the user mouses over other drop targets on their
-// system. This object tells Windows whether or not the drag should continue,
-// and supplies the appropriate cursors.
-class DragSource : public IDropSource,
- public base::RefCountedThreadSafe<DragSource> {
- public:
- DragSource();
- virtual ~DragSource() {}
-
- // Stop the drag operation at the next chance we get. This doesn't
- // synchronously stop the drag (since Windows is controlling that),
- // but lets us tell Windows to cancel the drag the next chance we get.
- void CancelDrag() {
- cancel_drag_ = true;
- }
-
- // IDropSource implementation:
- HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state);
- HRESULT __stdcall GiveFeedback(DWORD effect);
-
- // IUnknown implementation:
- HRESULT __stdcall QueryInterface(const IID& iid, void** object);
- ULONG __stdcall AddRef();
- ULONG __stdcall Release();
-
- protected:
- virtual void OnDragSourceCancel() {}
- virtual void OnDragSourceDrop() {}
- virtual void OnDragSourceMove() {}
-
- private:
- // Set to true if we want to cancel the drag operation.
- bool cancel_drag_;
-
- DISALLOW_COPY_AND_ASSIGN(DragSource);
-};
-
-} // namespace win
-} // namespace app
-
-#endif // APP_WIN_DRAG_SOURCE_H_
diff --git a/app/win/drop_target.cc b/app/win/drop_target.cc
deleted file mode 100644
index 6742e19..0000000
--- a/app/win/drop_target.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/win/drop_target.h"
-
-#include <shlobj.h>
-
-#include "base/logging.h"
-
-namespace app {
-namespace win {
-
-IDropTargetHelper* DropTarget::cached_drop_target_helper_ = NULL;
-int32 DropTarget::drag_identity_ = 0;
-
-DropTarget::DropTarget(HWND hwnd)
- : hwnd_(hwnd),
- suspended_(false),
- ref_count_(0) {
- DCHECK(hwnd);
- HRESULT result = RegisterDragDrop(hwnd, this);
- DCHECK(SUCCEEDED(result));
-}
-
-DropTarget::~DropTarget() {
-}
-
-// static
-IDropTargetHelper* DropTarget::DropHelper() {
- if (!cached_drop_target_helper_) {
- CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
- IID_IDropTargetHelper,
- reinterpret_cast<void**>(&cached_drop_target_helper_));
- }
- return cached_drop_target_helper_;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// DropTarget, IDropTarget implementation:
-
-HRESULT DropTarget::DragEnter(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect) {
- // Tell the helper that we entered so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper) {
- drop_helper->DragEnter(GetHWND(), data_object,
- reinterpret_cast<POINT*>(&cursor_position), *effect);
- }
-
- // You can't drag and drop within the same HWND.
- if (suspended_) {
- *effect = DROPEFFECT_NONE;
- return S_OK;
- }
-
- // Update the drag identity, skipping 0.
- if (++drag_identity_ == 0)
- ++drag_identity_;
-
- current_data_object_ = data_object;
- POINT screen_pt = { cursor_position.x, cursor_position.y };
- *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect);
- return S_OK;
-}
-
-HRESULT DropTarget::DragOver(DWORD key_state,
- POINTL cursor_position,
- DWORD* effect) {
- // Tell the helper that we moved over it so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper)
- drop_helper->DragOver(reinterpret_cast<POINT*>(&cursor_position), *effect);
-
- if (suspended_) {
- *effect = DROPEFFECT_NONE;
- return S_OK;
- }
-
- POINT screen_pt = { cursor_position.x, cursor_position.y };
- *effect = OnDragOver(current_data_object_, key_state, screen_pt, *effect);
- return S_OK;
-}
-
-HRESULT DropTarget::DragLeave() {
- // Tell the helper that we moved out of it so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper)
- drop_helper->DragLeave();
-
- if (suspended_)
- return S_OK;
-
- OnDragLeave(current_data_object_);
-
- current_data_object_ = NULL;
- return S_OK;
-}
-
-HRESULT DropTarget::Drop(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect) {
- // Tell the helper that we dropped onto it so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper) {
- drop_helper->Drop(current_data_object_,
- reinterpret_cast<POINT*>(&cursor_position), *effect);
- }
-
- if (suspended_) {
- *effect = DROPEFFECT_NONE;
- return S_OK;
- }
-
- POINT screen_pt = { cursor_position.x, cursor_position.y };
- *effect = OnDrop(current_data_object_, key_state, screen_pt, *effect);
- return S_OK;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// DropTarget, IUnknown implementation:
-
-HRESULT DropTarget::QueryInterface(const IID& iid, void** object) {
- *object = NULL;
- if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropTarget)) {
- *object = this;
- } else {
- return E_NOINTERFACE;
- }
- AddRef();
- return S_OK;
-}
-
-ULONG DropTarget::AddRef() {
- return ++ref_count_;
-}
-
-ULONG DropTarget::Release() {
- if (--ref_count_ == 0) {
- delete this;
- return 0U;
- }
- return ref_count_;
-}
-
-DWORD DropTarget::OnDragEnter(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect) {
- return DROPEFFECT_NONE;
-}
-
-DWORD DropTarget::OnDragOver(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect) {
- return DROPEFFECT_NONE;
-}
-
-void DropTarget::OnDragLeave(IDataObject* data_object) {
-}
-
-DWORD DropTarget::OnDrop(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect) {
- return DROPEFFECT_NONE;
-}
-
-} // namespace win
-} // namespace app
diff --git a/app/win/drop_target.h b/app/win/drop_target.h
deleted file mode 100644
index e7dc1ec..0000000
--- a/app/win/drop_target.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_WIN_DROP_TARGET_H_
-#define APP_WIN_DROP_TARGET_H_
-#pragma once
-
-#include <objidl.h>
-
-#include "base/ref_counted.h"
-
-// Windows interface.
-struct IDropTargetHelper;
-
-namespace app {
-namespace win {
-
-// A DropTarget implementation that takes care of the nitty gritty
-// of dnd. While this class is concrete, subclasses will most likely
-// want to override various OnXXX methods.
-//
-// Because DropTarget is ref counted you shouldn't delete it directly,
-// rather wrap it in a scoped_refptr. Be sure and invoke RevokeDragDrop(m_hWnd)
-// before the HWND is deleted too.
-//
-// This class is meant to be used in a STA and is not multithread-safe.
-class DropTarget : public IDropTarget {
- public:
- // Create a new DropTarget associating it with the given HWND.
- explicit DropTarget(HWND hwnd);
- virtual ~DropTarget();
-
- // When suspended is set to |true|, the drop target does not receive drops
- // from drags initiated within the owning HWND.
- bool suspended() const { return suspended_; }
- void set_suspended(bool suspended) { suspended_ = suspended; }
-
- // IDropTarget implementation:
- HRESULT __stdcall DragEnter(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect);
- HRESULT __stdcall DragOver(DWORD key_state,
- POINTL cursor_position,
- DWORD* effect);
- HRESULT __stdcall DragLeave();
- HRESULT __stdcall Drop(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect);
-
- // IUnknown implementation:
- HRESULT __stdcall QueryInterface(const IID& iid, void** object);
- ULONG __stdcall AddRef();
- ULONG __stdcall Release();
-
- protected:
- // Returns the hosting HWND.
- HWND GetHWND() { return hwnd_; }
-
- // Invoked when the cursor first moves over the hwnd during a dnd session.
- // This should return a bitmask of the supported drop operations:
- // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
- // DROPEFFECT_MOVE.
- virtual DWORD OnDragEnter(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect);
-
- // Invoked when the cursor moves over the window during a dnd session.
- // This should return a bitmask of the supported drop operations:
- // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
- // DROPEFFECT_MOVE.
- virtual DWORD OnDragOver(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect);
-
- // Invoked when the cursor moves outside the bounds of the hwnd during a
- // dnd session.
- virtual void OnDragLeave(IDataObject* data_object);
-
- // Invoked when the drop ends on the window. This should return the operation
- // that was taken.
- virtual DWORD OnDrop(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect);
-
- // Return the drag identity.
- static int32 GetDragIdentity() { return drag_identity_; }
-
- private:
- // Returns the cached drop helper, creating one if necessary. The returned
- // object is not addrefed. May return NULL if the object couldn't be created.
- static IDropTargetHelper* DropHelper();
-
- // The data object currently being dragged over this drop target.
- scoped_refptr<IDataObject> current_data_object_;
-
- // A helper object that is used to provide drag image support while the mouse
- // is dragging over the content area.
- //
- // DO NOT ACCESS DIRECTLY! Use DropHelper() instead, which will lazily create
- // this if it doesn't exist yet. This object can take tens of milliseconds to
- // create, and we don't want to block any window opening for this, especially
- // since often, DnD will never be used. Instead, we force this penalty to the
- // first time it is actually used.
- static IDropTargetHelper* cached_drop_target_helper_;
-
- // The drag identity (id). An up-counter that increases when the cursor first
- // moves over the HWND in a DnD session (OnDragEnter). 0 is reserved to mean
- // the "no/unknown" identity, and is used for initialization. The identity is
- // sent to the renderer in drag enter notifications. Note: the identity value
- // is passed over the renderer NPAPI interface to gears, so use int32 instead
- // of int here.
- static int32 drag_identity_;
-
- // The HWND of the source. This HWND is used to determine coordinates for
- // mouse events that are sent to the renderer notifying various drag states.
- HWND hwnd_;
-
- // Whether or not we are currently processing drag notifications for drags
- // initiated in this window.
- bool suspended_;
-
- LONG ref_count_;
-
- DISALLOW_COPY_AND_ASSIGN(DropTarget);
-};
-
-} // namespace win
-} // namespace app
-
-#endif // APP_WIN_DROP_TARGET_H_