summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-01 18:08:22 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-01 18:08:22 +0000
commita33dffb1c6ab617ba2edb92908a497d619e639fd (patch)
tree0c5c141a26a2990a5513295beab419650bf3c175 /app
parent9a968be67e07764043dddc9b1451a5c6c849dd25 (diff)
downloadchromium_src-a33dffb1c6ab617ba2edb92908a497d619e639fd.zip
chromium_src-a33dffb1c6ab617ba2edb92908a497d619e639fd.tar.gz
chromium_src-a33dffb1c6ab617ba2edb92908a497d619e639fd.tar.bz2
GTK: Parse NETSCAPE_URL types in drags to the bookmark bar.
This allows us to keep the original Firefox title of the bookmark. BUG=34375 TEST=Drag a bookmark from the Firefox bookmark bar to the Chrome bookmark bar. It should maintain the title instead of turning to the filename/url. Review URL: http://codereview.chromium.org/5292013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/gtk_dnd_util.cc23
-rw-r--r--app/gtk_dnd_util.h5
2 files changed, 28 insertions, 0 deletions
diff --git a/app/gtk_dnd_util.cc b/app/gtk_dnd_util.cc
index 92797a6..5df8151 100644
--- a/app/gtk_dnd_util.cc
+++ b/app/gtk_dnd_util.cc
@@ -237,4 +237,27 @@ bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) {
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
index 06acb0f..2e6c275 100644
--- a/app/gtk_dnd_util.h
+++ b/app/gtk_dnd_util.h
@@ -78,6 +78,11 @@ bool ExtractNamedURL(GtkSelectionData* selection_data,
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_