OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h" | 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 void TabContentsDragWin::PrepareDragForFileContents( | 226 void TabContentsDragWin::PrepareDragForFileContents( |
227 const WebDropData& drop_data, ui::OSExchangeData* data) { | 227 const WebDropData& drop_data, ui::OSExchangeData* data) { |
228 // Images without ALT text will only have a file extension so we need to | 228 // Images without ALT text will only have a file extension so we need to |
229 // synthesize one from the provided extension and URL. | 229 // synthesize one from the provided extension and URL. |
230 FilePath file_name(drop_data.file_description_filename); | 230 FilePath file_name(drop_data.file_description_filename); |
231 file_name = file_name.BaseName().RemoveExtension(); | 231 file_name = file_name.BaseName().RemoveExtension(); |
232 if (file_name.value().empty()) { | 232 if (file_name.value().empty()) { |
233 // Retrieve the name from the URL. | 233 // Retrieve the name from the URL. |
234 file_name = net::GetSuggestedFilename(drop_data.url, "", "", FilePath()); | 234 file_name = FilePath( |
| 235 net::GetSuggestedFilename(drop_data.url, "", "", string16())); |
235 if (file_name.value().size() + drop_data.file_extension.size() + 1 > | 236 if (file_name.value().size() + drop_data.file_extension.size() + 1 > |
236 MAX_PATH) { | 237 MAX_PATH) { |
237 file_name = FilePath(file_name.value().substr( | 238 file_name = FilePath(file_name.value().substr( |
238 0, MAX_PATH - drop_data.file_extension.size() - 2)); | 239 0, MAX_PATH - drop_data.file_extension.size() - 2)); |
239 } | 240 } |
240 } | 241 } |
241 file_name = file_name.ReplaceExtension(drop_data.file_extension); | 242 file_name = file_name.ReplaceExtension(drop_data.file_extension); |
242 data->SetFileContents(file_name.value(), drop_data.file_contents); | 243 data->SetFileContents(file_name.value(), drop_data.file_contents); |
243 } | 244 } |
244 | 245 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 359 |
359 void TabContentsDragWin::OnDataObjectDisposed() { | 360 void TabContentsDragWin::OnDataObjectDisposed() { |
360 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); | 361 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); |
361 | 362 |
362 // The drag-and-drop thread is only closed after OLE is done with | 363 // The drag-and-drop thread is only closed after OLE is done with |
363 // DataObjectImpl. | 364 // DataObjectImpl. |
364 BrowserThread::PostTask( | 365 BrowserThread::PostTask( |
365 BrowserThread::UI, FROM_HERE, | 366 BrowserThread::UI, FROM_HERE, |
366 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); | 367 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); |
367 } | 368 } |
OLD | NEW |