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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 for (size_t i = 0; target_codes[i] != -1; ++i) { | 139 for (size_t i = 0; target_codes[i] != -1; ++i) { |
140 AddTargetToList(targets, target_codes[i]); | 140 AddTargetToList(targets, target_codes[i]); |
141 } | 141 } |
142 | 142 |
143 gtk_drag_dest_set_target_list(dest, targets); | 143 gtk_drag_dest_set_target_list(dest, targets); |
144 gtk_target_list_unref(targets); | 144 gtk_target_list_unref(targets); |
145 } | 145 } |
146 | 146 |
147 void WriteURLWithName(GtkSelectionData* selection_data, | 147 void WriteURLWithName(GtkSelectionData* selection_data, |
148 const GURL& url, | 148 const GURL& url, |
149 const string16& title, | 149 string16 title, |
150 int type) { | 150 int type) { |
151 if (title.empty()) { | |
152 // Can't have an empty title. Set it to the filename extracted from the | |
Evan Stade
2010/11/30 21:28:21
nit: "Can't"? Isn't it more like "Prefer to avoid"
| |
153 // URL. | |
154 title = UTF8ToUTF16(url.ExtractFileName()); | |
sky
2010/11/30 22:14:08
Might the filename be empty too?
Elliot Glaysher
2010/11/30 22:18:20
I'm not really concerned about that. In that case,
| |
155 } | |
156 | |
151 switch (type) { | 157 switch (type) { |
152 case TEXT_PLAIN: { | 158 case TEXT_PLAIN: { |
153 gtk_selection_data_set_text(selection_data, url.spec().c_str(), | 159 gtk_selection_data_set_text(selection_data, url.spec().c_str(), |
154 url.spec().length()); | 160 url.spec().length()); |
155 break; | 161 break; |
156 } | 162 } |
157 case TEXT_URI_LIST: { | 163 case TEXT_URI_LIST: { |
158 gchar* uri_array[2]; | 164 gchar* uri_array[2]; |
159 uri_array[0] = strdup(url.spec().c_str()); | 165 uri_array[0] = strdup(url.spec().c_str()); |
160 uri_array[1] = NULL; | 166 uri_array[1] = NULL; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 GURL url(uris[i]); | 231 GURL url(uris[i]); |
226 if (url.is_valid()) | 232 if (url.is_valid()) |
227 urls->push_back(url); | 233 urls->push_back(url); |
228 } | 234 } |
229 | 235 |
230 g_strfreev(uris); | 236 g_strfreev(uris); |
231 return true; | 237 return true; |
232 } | 238 } |
233 | 239 |
234 } // namespace gtk_dnd_util | 240 } // namespace gtk_dnd_util |
OLD | NEW |