Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Unified Diff: ui/base/dragdrop/os_exchange_data.cc

Issue 2014733003: Removing parsing of text from pasteboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moving url parsing up the hierarchy Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/dragdrop/os_exchange_data.h ('k') | ui/base/dragdrop/os_exchange_data_provider_aura.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/dragdrop/os_exchange_data.cc
diff --git a/ui/base/dragdrop/os_exchange_data.cc b/ui/base/dragdrop/os_exchange_data.cc
index 00e58191f39c2789d42e3711f3ae3681b121461c..f7c00913be0e1962a16af1fbf9a2686781810826 100644
--- a/ui/base/dragdrop/os_exchange_data.cc
+++ b/ui/base/dragdrop/os_exchange_data.cc
@@ -6,6 +6,7 @@
#include "base/pickle.h"
#include "build/build_config.h"
+#include "net/base/filename_util.h"
#include "url/gurl.h"
namespace ui {
@@ -62,10 +63,23 @@ bool OSExchangeData::GetString(base::string16* data) const {
return provider_->GetString(data);
}
-bool OSExchangeData::GetURLAndTitle(FilenameToURLPolicy policy,
+bool OSExchangeData::GetURLAndTitle(FilenameToURLPolicy filename_policy,
+ URLTextParsePolicy text_parse_policy,
GURL* url,
base::string16* title) const {
- return provider_->GetURLAndTitle(policy, url, title);
+ if (provider_->GetURLAndTitle(filename_policy, url, title))
+ return true;
+ if (text_parse_policy == DO_NOT_PARSE_TEXT_AS_URL)
+ return false;
+ base::string16 url_str;
+ if (!provider_->GetString(&url_str))
+ return false;
+ GURL test(url_str);
+ if (!test.is_valid())
+ return false;
+ *url = std::move(test);
dcheng 2016/05/28 20:10:03 FYI: GURL doesn't have a move constructor, so this
+ *title = net::GetSuggestedFilename(*url, "", "", "", "", std::string());
+ return true;
}
bool OSExchangeData::GetFilename(base::FilePath* path) const {
@@ -85,8 +99,16 @@ bool OSExchangeData::HasString() const {
return provider_->HasString();
}
-bool OSExchangeData::HasURL(FilenameToURLPolicy policy) const {
- return provider_->HasURL(policy);
+bool OSExchangeData::HasURL(FilenameToURLPolicy filename_policy,
+ URLTextParsePolicy text_parse_policy) const {
+ if (provider_->HasURL(filename_policy))
+ return true;
+ if (text_parse_policy == DO_NOT_PARSE_TEXT_AS_URL)
+ return false;
+ base::string16 url_str;
+ if (provider_->GetString(&url_str))
+ return false;
+ return GURL(url_str).is_valid();
}
bool OSExchangeData::HasFile() const {
@@ -103,7 +125,7 @@ bool OSExchangeData::HasAnyFormat(
const std::set<Clipboard::FormatType>& format_types) const {
if ((formats & STRING) != 0 && HasString())
return true;
- if ((formats & URL) != 0 && HasURL(CONVERT_FILENAMES))
+ if ((formats & URL) != 0 && HasURL(CONVERT_FILENAMES, PARSE_TEXT_AS_URL))
return true;
#if defined(OS_WIN)
if ((formats & FILE_CONTENTS) != 0 && provider_->HasFileContents())
« no previous file with comments | « ui/base/dragdrop/os_exchange_data.h ('k') | ui/base/dragdrop/os_exchange_data_provider_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698