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

Side by Side Diff: ui/base/dragdrop/os_exchange_data_provider_win.cc

Issue 380553002: Add a unit test that filenames aren't unintentionally converted to URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows Created 6 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/dragdrop/os_exchange_data_provider_win.h" 5 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 return ClipboardUtil::GetPlainText(source_object_, data); 404 return ClipboardUtil::GetPlainText(source_object_, data);
405 } 405 }
406 406
407 bool OSExchangeDataProviderWin::GetURLAndTitle( 407 bool OSExchangeDataProviderWin::GetURLAndTitle(
408 OSExchangeData::FilenameToURLPolicy policy, 408 OSExchangeData::FilenameToURLPolicy policy,
409 GURL* url, 409 GURL* url,
410 base::string16* title) const { 410 base::string16* title) const {
411 base::string16 url_str; 411 base::string16 url_str;
412 bool success = ClipboardUtil::GetUrl( 412 bool success = ClipboardUtil::GetUrl(
413 source_object_, 413 source_object_,
414 &url_str, 414 url,
415 title, 415 title,
416 policy == OSExchangeData::CONVERT_FILENAMES ? true : false); 416 policy == OSExchangeData::CONVERT_FILENAMES ? true : false);
417 if (success) { 417 if (success) {
418 GURL test_url(url_str); 418 DCHECK(url->is_valid());
419 if (test_url.is_valid()) { 419 return true;
420 *url = test_url;
421 return true;
422 }
423 } else if (GetPlainTextURL(source_object_, url)) { 420 } else if (GetPlainTextURL(source_object_, url)) {
424 if (url->is_valid()) 421 if (url->is_valid())
425 *title = net::GetSuggestedFilename(*url, "", "", "", "", std::string()); 422 *title = net::GetSuggestedFilename(*url, "", "", "", "", std::string());
426 else 423 else
427 title->clear(); 424 title->clear();
428 return true; 425 return true;
429 } 426 }
430 return false; 427 return false;
431 } 428 }
432 429
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 1048
1052 /////////////////////////////////////////////////////////////////////////////// 1049 ///////////////////////////////////////////////////////////////////////////////
1053 // OSExchangeData, public: 1050 // OSExchangeData, public:
1054 1051
1055 // static 1052 // static
1056 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 1053 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
1057 return new OSExchangeDataProviderWin(); 1054 return new OSExchangeDataProviderWin();
1058 } 1055 }
1059 1056
1060 } // namespace ui 1057 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698