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

Side by Side Diff: ui/base/dragdrop/os_exchange_data_provider_aura.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
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_provider_aura.h" 5 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/base/clipboard/clipboard.h" 9 #include "ui/base/clipboard/clipboard.h"
10 #include "ui/base/clipboard/scoped_clipboard_writer.h" 10 #include "ui/base/clipboard/scoped_clipboard_writer.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return false; 83 return false;
84 *data = string_; 84 *data = string_;
85 return true; 85 return true;
86 } 86 }
87 87
88 bool OSExchangeDataProviderAura::GetURLAndTitle( 88 bool OSExchangeDataProviderAura::GetURLAndTitle(
89 OSExchangeData::FilenameToURLPolicy policy, 89 OSExchangeData::FilenameToURLPolicy policy,
90 GURL* url, 90 GURL* url,
91 base::string16* title) const { 91 base::string16* title) const {
92 // TODO(dcheng): implement filename conversion. 92 // TODO(dcheng): implement filename conversion.
93 if ((formats_ & OSExchangeData::URL) == 0) { 93 if ((formats_ & OSExchangeData::URL) == 0)
94 title->clear(); 94 return false;
95 return GetPlainTextURL(url);
96 }
97 95
98 if (!url_.is_valid()) 96 if (!url_.is_valid())
99 return false; 97 return false;
100 98
101 *url = url_; 99 *url = url_;
102 *title = title_; 100 *title = title_;
103 return true; 101 return true;
104 } 102 }
105 103
106 bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const { 104 bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const {
(...skipping 23 matching lines...) Expand all
130 return true; 128 return true;
131 } 129 }
132 130
133 bool OSExchangeDataProviderAura::HasString() const { 131 bool OSExchangeDataProviderAura::HasString() const {
134 return (formats_ & OSExchangeData::STRING) != 0; 132 return (formats_ & OSExchangeData::STRING) != 0;
135 } 133 }
136 134
137 bool OSExchangeDataProviderAura::HasURL( 135 bool OSExchangeDataProviderAura::HasURL(
138 OSExchangeData::FilenameToURLPolicy policy) const { 136 OSExchangeData::FilenameToURLPolicy policy) const {
139 // TODO(dcheng): implement filename conversion. 137 // TODO(dcheng): implement filename conversion.
140 if ((formats_ & OSExchangeData::URL) != 0) { 138 return formats_ & OSExchangeData::URL;
141 return true;
142 }
143 // No URL, see if we have plain text that can be parsed as a URL.
144 return GetPlainTextURL(NULL);
145 } 139 }
146 140
147 bool OSExchangeDataProviderAura::HasFile() const { 141 bool OSExchangeDataProviderAura::HasFile() const {
148 return (formats_ & OSExchangeData::FILE_NAME) != 0; 142 return (formats_ & OSExchangeData::FILE_NAME) != 0;
149 } 143 }
150 144
151 bool OSExchangeDataProviderAura::HasCustomFormat( 145 bool OSExchangeDataProviderAura::HasCustomFormat(
152 const Clipboard::FormatType& format) const { 146 const Clipboard::FormatType& format) const {
153 return pickle_data_.find(format) != pickle_data_.end(); 147 return pickle_data_.find(format) != pickle_data_.end();
154 } 148 }
(...skipping 27 matching lines...) Expand all
182 176
183 const gfx::ImageSkia& OSExchangeDataProviderAura::GetDragImage() const { 177 const gfx::ImageSkia& OSExchangeDataProviderAura::GetDragImage() const {
184 return drag_image_; 178 return drag_image_;
185 } 179 }
186 180
187 const gfx::Vector2d& 181 const gfx::Vector2d&
188 OSExchangeDataProviderAura::GetDragImageOffset() const { 182 OSExchangeDataProviderAura::GetDragImageOffset() const {
189 return drag_image_offset_; 183 return drag_image_offset_;
190 } 184 }
191 185
192 bool OSExchangeDataProviderAura::GetPlainTextURL(GURL* url) const {
193 if ((formats_ & OSExchangeData::STRING) == 0)
194 return false;
195
196 GURL test_url(string_);
197 if (!test_url.is_valid())
198 return false;
199
200 if (url)
201 *url = test_url;
202 return true;
203 }
204
205 /////////////////////////////////////////////////////////////////////////////// 186 ///////////////////////////////////////////////////////////////////////////////
206 // OSExchangeData, public: 187 // OSExchangeData, public:
207 188
208 // static 189 // static
209 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 190 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
210 return new OSExchangeDataProviderAura(); 191 return new OSExchangeDataProviderAura();
211 } 192 }
212 193
213 } // namespace ui 194 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698