summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-11 02:36:56 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-11 02:36:56 +0000
commitdd6b1ee947e64801990404340413cbf2a20bb305 (patch)
treef8146162ec33a2dc75f71597210dc0d9dead290f /ui/base
parenta034b70b2bb8b290d064d86e29fe0555abfcf408 (diff)
downloadchromium_src-dd6b1ee947e64801990404340413cbf2a20bb305.zip
chromium_src-dd6b1ee947e64801990404340413cbf2a20bb305.tar.gz
chromium_src-dd6b1ee947e64801990404340413cbf2a20bb305.tar.bz2
linux_aura: Fix dragging files into Dropbox.
Some Linux file managers will set both URI list representation and the plain text representation when dragging files. Chrome interprets this as a chunk of text and a file, and offers both to the renderer. This broke the javascript on the Dropbox website. This ports the hack in WebDragDestGtk::OnDragDataReceived() to linux_aura. This hack prevents us from offering the String type when we also have a URI list. BUG=318796 Review URL: https://codereview.chromium.org/133053003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aurax11.cc9
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc20
2 files changed, 28 insertions, 1 deletions
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
index 20a6842..ebea659 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
@@ -175,6 +175,13 @@ void OSExchangeDataProviderAuraX11::SetPickledData(
}
bool OSExchangeDataProviderAuraX11::GetString(base::string16* result) const {
+ if (HasFile()) {
+ // Various Linux file managers both pass a list of file:// URIs and set the
+ // string representation to the URI. We explicitly don't want to return use
+ // this representation.
+ return false;
+ }
+
std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_);
std::vector< ::Atom> requested_types;
ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types);
@@ -292,7 +299,7 @@ bool OSExchangeDataProviderAuraX11::HasString() const {
std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_);
std::vector< ::Atom> requested_types;
ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types);
- return !requested_types.empty();
+ return !requested_types.empty() && !HasFile();
}
bool OSExchangeDataProviderAuraX11::HasURL() const {
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
index e3bf0e8..cbb24d2 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
@@ -96,4 +96,24 @@ TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) {
EXPECT_EQ(kGoogleURL, out_gurl.spec());
}
+TEST_F(OSExchangeDataProviderAuraX11Test, OnlyStringURLIsUnfiltered) {
+ const base::string16 file_url = base::UTF8ToUTF16(kFileURL);
+ provider.SetString(file_url);
+
+ EXPECT_TRUE(provider.HasString());
+ EXPECT_FALSE(provider.HasURL());
+}
+
+TEST_F(OSExchangeDataProviderAuraX11Test, StringAndURIListFilterString) {
+ const base::string16 file_url = base::UTF8ToUTF16(kFileURL);
+ provider.SetString(file_url);
+ AddURLList(kFileURL);
+
+ EXPECT_FALSE(provider.HasString());
+ base::string16 out_str;
+ EXPECT_FALSE(provider.GetString(&out_str));
+
+ EXPECT_TRUE(provider.HasFile());
+}
+
} // namespace ui