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

Side by Side Diff: chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc

Issue 7778008: Truncate file name longer than MAX_PATH(260) on D2D (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Decode Percent-Encoding in file name Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | ui/base/dragdrop/os_exchange_data_provider_win.cc » ('j') | ui/base/dragdrop/os_exchange_data_provider_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698