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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 // Enable asynchronous operation. | 220 // Enable asynchronous operation. |
221 ui::OSExchangeDataProviderWin::GetIAsyncOperation(*data)->SetAsyncMode(TRUE); | 221 ui::OSExchangeDataProviderWin::GetIAsyncOperation(*data)->SetAsyncMode(TRUE); |
222 } | 222 } |
223 | 223 |
224 void TabContentsDragWin::PrepareDragForFileContents( | 224 void TabContentsDragWin::PrepareDragForFileContents( |
225 const WebDropData& drop_data, ui::OSExchangeData* data) { | 225 const WebDropData& drop_data, ui::OSExchangeData* data) { |
226 // Images without ALT text will only have a file extension so we need to | 226 // Images without ALT text will only have a file extension so we need to |
227 // synthesize one from the provided extension and URL. | 227 // synthesize one from the provided extension and URL. |
228 FilePath file_name(drop_data.file_description_filename); | 228 FilePath file_name(drop_data.file_description_filename); |
229 file_name = file_name.BaseName().RemoveExtension(); | 229 file_name = file_name.BaseName().RemoveExtension(); |
230 if (file_name.value().empty()) { | 230 |
231 // If file_name contains percent-encoded characters, we want to decoded | |
232 // them to provide friendly file name for international users. | |
233 if (file_name.value().empty() || | |
234 file_name.value().find('%') != std::string::npos) { | |
sky
2011/09/06 15:55:05
If the file name contains a '%' and you enter this
| |
231 // Retrieve the name from the URL. | 235 // Retrieve the name from the URL. |
232 file_name = FilePath( | 236 file_name = FilePath( |
233 net::GetSuggestedFilename(drop_data.url, "", "", "", "", string16())); | 237 net::GetSuggestedFilename(drop_data.url, "", "", "", "", string16())); |
234 if (file_name.value().size() + drop_data.file_extension.size() + 1 > | 238 if (file_name.value().size() + drop_data.file_extension.size() + 1 > |
235 MAX_PATH) { | 239 MAX_PATH) { |
236 file_name = FilePath(file_name.value().substr( | 240 file_name = FilePath(file_name.value().substr( |
237 0, MAX_PATH - drop_data.file_extension.size() - 2)); | 241 0, MAX_PATH - drop_data.file_extension.size() - 2)); |
238 } | 242 } |
239 } | 243 } |
240 file_name = file_name.ReplaceExtension(drop_data.file_extension); | 244 file_name = file_name.ReplaceExtension(drop_data.file_extension); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 | 361 |
358 void TabContentsDragWin::OnDataObjectDisposed() { | 362 void TabContentsDragWin::OnDataObjectDisposed() { |
359 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); | 363 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); |
360 | 364 |
361 // The drag-and-drop thread is only closed after OLE is done with | 365 // The drag-and-drop thread is only closed after OLE is done with |
362 // DataObjectImpl. | 366 // DataObjectImpl. |
363 BrowserThread::PostTask( | 367 BrowserThread::PostTask( |
364 BrowserThread::UI, FROM_HERE, | 368 BrowserThread::UI, FROM_HERE, |
365 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); | 369 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); |
366 } | 370 } |
OLD | NEW |