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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/dragdrop/os_exchange_data.h" 5 #include "ui/base/dragdrop/os_exchange_data.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "net/base/filename_util.h"
9 #include "url/gurl.h" 10 #include "url/gurl.h"
10 11
11 namespace ui { 12 namespace ui {
12 13
13 OSExchangeData::DownloadFileInfo::DownloadFileInfo( 14 OSExchangeData::DownloadFileInfo::DownloadFileInfo(
14 const base::FilePath& filename, 15 const base::FilePath& filename,
15 DownloadFileProvider* downloader) 16 DownloadFileProvider* downloader)
16 : filename(filename), 17 : filename(filename),
17 downloader(downloader) { 18 downloader(downloader) {
18 } 19 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 56
56 void OSExchangeData::SetPickledData(const Clipboard::FormatType& format, 57 void OSExchangeData::SetPickledData(const Clipboard::FormatType& format,
57 const base::Pickle& data) { 58 const base::Pickle& data) {
58 provider_->SetPickledData(format, data); 59 provider_->SetPickledData(format, data);
59 } 60 }
60 61
61 bool OSExchangeData::GetString(base::string16* data) const { 62 bool OSExchangeData::GetString(base::string16* data) const {
62 return provider_->GetString(data); 63 return provider_->GetString(data);
63 } 64 }
64 65
65 bool OSExchangeData::GetURLAndTitle(FilenameToURLPolicy policy, 66 bool OSExchangeData::GetURLAndTitle(FilenameToURLPolicy filename_policy,
67 URLTextParsePolicy text_parse_policy,
66 GURL* url, 68 GURL* url,
67 base::string16* title) const { 69 base::string16* title) const {
68 return provider_->GetURLAndTitle(policy, url, title); 70 if (provider_->GetURLAndTitle(filename_policy, url, title))
71 return true;
72 if (text_parse_policy == DO_NOT_PARSE_TEXT_AS_URL)
73 return false;
74 base::string16 url_str;
75 if (!provider_->GetString(&url_str))
76 return false;
77 GURL test(url_str);
78 if (!test.is_valid())
79 return false;
80 *url = std::move(test);
dcheng 2016/05/28 20:10:03 FYI: GURL doesn't have a move constructor, so this
81 *title = net::GetSuggestedFilename(*url, "", "", "", "", std::string());
82 return true;
69 } 83 }
70 84
71 bool OSExchangeData::GetFilename(base::FilePath* path) const { 85 bool OSExchangeData::GetFilename(base::FilePath* path) const {
72 return provider_->GetFilename(path); 86 return provider_->GetFilename(path);
73 } 87 }
74 88
75 bool OSExchangeData::GetFilenames(std::vector<FileInfo>* filenames) const { 89 bool OSExchangeData::GetFilenames(std::vector<FileInfo>* filenames) const {
76 return provider_->GetFilenames(filenames); 90 return provider_->GetFilenames(filenames);
77 } 91 }
78 92
79 bool OSExchangeData::GetPickledData(const Clipboard::FormatType& format, 93 bool OSExchangeData::GetPickledData(const Clipboard::FormatType& format,
80 base::Pickle* data) const { 94 base::Pickle* data) const {
81 return provider_->GetPickledData(format, data); 95 return provider_->GetPickledData(format, data);
82 } 96 }
83 97
84 bool OSExchangeData::HasString() const { 98 bool OSExchangeData::HasString() const {
85 return provider_->HasString(); 99 return provider_->HasString();
86 } 100 }
87 101
88 bool OSExchangeData::HasURL(FilenameToURLPolicy policy) const { 102 bool OSExchangeData::HasURL(FilenameToURLPolicy filename_policy,
89 return provider_->HasURL(policy); 103 URLTextParsePolicy text_parse_policy) const {
104 if (provider_->HasURL(filename_policy))
105 return true;
106 if (text_parse_policy == DO_NOT_PARSE_TEXT_AS_URL)
107 return false;
108 base::string16 url_str;
109 if (provider_->GetString(&url_str))
110 return false;
111 return GURL(url_str).is_valid();
90 } 112 }
91 113
92 bool OSExchangeData::HasFile() const { 114 bool OSExchangeData::HasFile() const {
93 return provider_->HasFile(); 115 return provider_->HasFile();
94 } 116 }
95 117
96 bool OSExchangeData::HasCustomFormat( 118 bool OSExchangeData::HasCustomFormat(
97 const Clipboard::FormatType& format) const { 119 const Clipboard::FormatType& format) const {
98 return provider_->HasCustomFormat(format); 120 return provider_->HasCustomFormat(format);
99 } 121 }
100 122
101 bool OSExchangeData::HasAnyFormat( 123 bool OSExchangeData::HasAnyFormat(
102 int formats, 124 int formats,
103 const std::set<Clipboard::FormatType>& format_types) const { 125 const std::set<Clipboard::FormatType>& format_types) const {
104 if ((formats & STRING) != 0 && HasString()) 126 if ((formats & STRING) != 0 && HasString())
105 return true; 127 return true;
106 if ((formats & URL) != 0 && HasURL(CONVERT_FILENAMES)) 128 if ((formats & URL) != 0 && HasURL(CONVERT_FILENAMES, PARSE_TEXT_AS_URL))
107 return true; 129 return true;
108 #if defined(OS_WIN) 130 #if defined(OS_WIN)
109 if ((formats & FILE_CONTENTS) != 0 && provider_->HasFileContents()) 131 if ((formats & FILE_CONTENTS) != 0 && provider_->HasFileContents())
110 return true; 132 return true;
111 #endif 133 #endif
112 #if defined(USE_AURA) 134 #if defined(USE_AURA)
113 if ((formats & HTML) != 0 && provider_->HasHtml()) 135 if ((formats & HTML) != 0 && provider_->HasHtml())
114 return true; 136 return true;
115 #endif 137 #endif
116 if ((formats & FILE_NAME) != 0 && provider_->HasFile()) 138 if ((formats & FILE_NAME) != 0 && provider_->HasFile())
(...skipping 25 matching lines...) Expand all
142 void OSExchangeData::SetHtml(const base::string16& html, const GURL& base_url) { 164 void OSExchangeData::SetHtml(const base::string16& html, const GURL& base_url) {
143 provider_->SetHtml(html, base_url); 165 provider_->SetHtml(html, base_url);
144 } 166 }
145 167
146 bool OSExchangeData::GetHtml(base::string16* html, GURL* base_url) const { 168 bool OSExchangeData::GetHtml(base::string16* html, GURL* base_url) const {
147 return provider_->GetHtml(html, base_url); 169 return provider_->GetHtml(html, base_url);
148 } 170 }
149 #endif 171 #endif
150 172
151 } // namespace ui 173 } // namespace ui
OLDNEW
« 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