Commit dd6b1ee9 authored by erg@chromium.org's avatar erg@chromium.org

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
parent a034b70b
...@@ -175,6 +175,13 @@ void OSExchangeDataProviderAuraX11::SetPickledData( ...@@ -175,6 +175,13 @@ void OSExchangeDataProviderAuraX11::SetPickledData(
} }
bool OSExchangeDataProviderAuraX11::GetString(base::string16* result) const { 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> text_atoms = ui::GetTextAtomsFrom(&atom_cache_);
std::vector< ::Atom> requested_types; std::vector< ::Atom> requested_types;
ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types); ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types);
...@@ -292,7 +299,7 @@ bool OSExchangeDataProviderAuraX11::HasString() const { ...@@ -292,7 +299,7 @@ bool OSExchangeDataProviderAuraX11::HasString() const {
std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_); std::vector< ::Atom> text_atoms = ui::GetTextAtomsFrom(&atom_cache_);
std::vector< ::Atom> requested_types; std::vector< ::Atom> requested_types;
ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types); ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types);
return !requested_types.empty(); return !requested_types.empty() && !HasFile();
} }
bool OSExchangeDataProviderAuraX11::HasURL() const { bool OSExchangeDataProviderAuraX11::HasURL() const {
......
...@@ -96,4 +96,24 @@ TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) { ...@@ -96,4 +96,24 @@ TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) {
EXPECT_EQ(kGoogleURL, out_gurl.spec()); 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 } // namespace ui
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