Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/gtk_dnd_util.h" | 5 #include "app/gtk_dnd_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 for (size_t i = 0; uris[i] != NULL; ++i) { | 230 for (size_t i = 0; uris[i] != NULL; ++i) { |
| 231 GURL url(uris[i]); | 231 GURL url(uris[i]); |
| 232 if (url.is_valid()) | 232 if (url.is_valid()) |
| 233 urls->push_back(url); | 233 urls->push_back(url); |
| 234 } | 234 } |
| 235 | 235 |
| 236 g_strfreev(uris); | 236 g_strfreev(uris); |
| 237 return true; | 237 return true; |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool ExtractNetscapeURL(GtkSelectionData* selection_data, | |
| 241 GURL* url, | |
| 242 string16* title) { | |
| 243 if (!selection_data || selection_data->length <= 0) | |
| 244 return false; | |
| 245 | |
| 246 // Find the first '\n' in the data. It is the separator between the url and | |
| 247 // the title. | |
| 248 std::string data(reinterpret_cast<char*>(selection_data->data), | |
| 249 selection_data->length); | |
| 250 std::string::size_type newline = data.find('\n'); | |
| 251 if (newline == std::string::npos) | |
| 252 return false; | |
| 253 | |
| 254 GURL gurl(data.substr(0, newline)); | |
| 255 if (!gurl.is_valid()) | |
| 256 return false; | |
| 257 | |
| 258 *url = gurl; | |
|
Evan Stade
2010/11/30 23:56:17
if (url)
...
if (title)
...
Elliot Glaysher
2010/12/01 00:05:21
ExtractNamedURL() and ExtractURIList() don't check
| |
| 259 *title = UTF8ToUTF16(data.substr(newline + 1)); | |
| 260 return true; | |
| 261 } | |
| 262 | |
| 240 } // namespace gtk_dnd_util | 263 } // namespace gtk_dnd_util |
| OLD | NEW |