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

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

Issue 869233006: [net] Cleanup filename_util and make it portable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clang-format-filename-tests
Patch Set: Created 5 years, 10 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
« no previous file with comments | « net/base/filename_util_unsafe.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_.get(), url, title, 413 source_object_.get(), url, title,
414 policy == OSExchangeData::CONVERT_FILENAMES ? true : false); 414 policy == OSExchangeData::CONVERT_FILENAMES ? true : false);
415 if (success) { 415 if (success) {
416 DCHECK(url->is_valid()); 416 DCHECK(url->is_valid());
417 return true; 417 return true;
418 } else if (GetPlainTextURL(source_object_.get(), url)) { 418 } else if (GetPlainTextURL(source_object_.get(), url)) {
419 if (url->is_valid()) 419 if (url->is_valid()) {
420 *title = net::GetSuggestedFilename(*url, "", "", "", "", std::string()); 420 *title = net::GenerateFileName(*url, std::string(), std::string(),
421 else 421 std::string(), std::string(),
422 std::string()).AsUTF16Unsafe();
423 } else {
422 title->clear(); 424 title->clear();
425 }
423 return true; 426 return true;
424 } 427 }
425 return false; 428 return false;
426 } 429 }
427 430
428 bool OSExchangeDataProviderWin::GetFilename(base::FilePath* path) const { 431 bool OSExchangeDataProviderWin::GetFilename(base::FilePath* path) const {
429 std::vector<base::string16> filenames; 432 std::vector<base::string16> filenames;
430 bool success = ClipboardUtil::GetFilenames(source_object_.get(), &filenames); 433 bool success = ClipboardUtil::GetFilenames(source_object_.get(), &filenames);
431 if (success) 434 if (success)
432 *path = base::FilePath(filenames[0]); 435 *path = base::FilePath(filenames[0]);
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 static const std::string kInternetShortcutFileEnd = 903 static const std::string kInternetShortcutFileEnd =
901 "\r\n"; 904 "\r\n";
902 *data = kInternetShortcutFileStart + url.spec() + kInternetShortcutFileEnd; 905 *data = kInternetShortcutFileStart + url.spec() + kInternetShortcutFileEnd;
903 } 906 }
904 907
905 static void CreateValidFileNameFromTitle(const GURL& url, 908 static void CreateValidFileNameFromTitle(const GURL& url,
906 const base::string16& title, 909 const base::string16& title,
907 base::string16* validated) { 910 base::string16* validated) {
908 if (title.empty()) { 911 if (title.empty()) {
909 if (url.is_valid()) { 912 if (url.is_valid()) {
910 *validated = net::GetSuggestedFilename(url, "", "", "", "", 913 *validated = net::GenerateFileName(url, std::string(), std::string(),
911 std::string()); 914 std::string(), std::string(),
915 std::string()).AsUTF16Unsafe();
912 } else { 916 } else {
913 // Nothing else can be done, just use a default. 917 // Nothing else can be done, just use a default.
914 *validated = 918 *validated =
915 l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); 919 l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME);
916 } 920 }
917 } else { 921 } else {
918 *validated = title; 922 *validated = title;
919 base::i18n::ReplaceIllegalCharactersInPath(validated, '-'); 923 base::i18n::ReplaceIllegalCharactersInPath(validated, '-');
920 } 924 }
921 static const wchar_t extension[] = L".url"; 925 static const wchar_t extension[] = L".url";
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 1051
1048 /////////////////////////////////////////////////////////////////////////////// 1052 ///////////////////////////////////////////////////////////////////////////////
1049 // OSExchangeData, public: 1053 // OSExchangeData, public:
1050 1054
1051 // static 1055 // static
1052 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 1056 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
1053 return new OSExchangeDataProviderWin(); 1057 return new OSExchangeDataProviderWin();
1054 } 1058 }
1055 1059
1056 } // namespace ui 1060 } // namespace ui
OLDNEW
« no previous file with comments | « net/base/filename_util_unsafe.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698