| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/os_exchange_data_provider_win.h" | 5 #include "app/os_exchange_data_provider_win.h" |
| 6 | 6 |
| 7 #include "app/clipboard/clipboard_util_win.h" | 7 #include "app/clipboard/clipboard_util_win.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 static const std::string kInternetShortcutFileEnd = | 696 static const std::string kInternetShortcutFileEnd = |
| 697 "\r\n"; | 697 "\r\n"; |
| 698 *data = kInternetShortcutFileStart + url.spec() + kInternetShortcutFileEnd; | 698 *data = kInternetShortcutFileStart + url.spec() + kInternetShortcutFileEnd; |
| 699 } | 699 } |
| 700 | 700 |
| 701 static void CreateValidFileNameFromTitle(const GURL& url, | 701 static void CreateValidFileNameFromTitle(const GURL& url, |
| 702 const std::wstring& title, | 702 const std::wstring& title, |
| 703 std::wstring* validated) { | 703 std::wstring* validated) { |
| 704 if (title.empty()) { | 704 if (title.empty()) { |
| 705 if (url.is_valid()) { | 705 if (url.is_valid()) { |
| 706 *validated = net::GetSuggestedFilename( | 706 *validated = net::GetSuggestedFilename(url, std::string(), |
| 707 url, std::string(), std::string(), std::wstring()); | 707 std::string(), "").ToWStringHack(); |
| 708 } else { | 708 } else { |
| 709 // Nothing else can be done, just use a default. | 709 // Nothing else can be done, just use a default. |
| 710 *validated = l10n_util::GetString(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); | 710 *validated = l10n_util::GetString(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); |
| 711 } | 711 } |
| 712 } else { | 712 } else { |
| 713 *validated = title; | 713 *validated = title; |
| 714 file_util::ReplaceIllegalCharacters(validated, '-'); | 714 file_util::ReplaceIllegalCharactersInPath(validated, '-'); |
| 715 } | 715 } |
| 716 static const wchar_t extension[] = L".url"; | 716 static const wchar_t extension[] = L".url"; |
| 717 static const size_t max_length = MAX_PATH - arraysize(extension); | 717 static const size_t max_length = MAX_PATH - arraysize(extension); |
| 718 if (validated->size() > max_length) | 718 if (validated->size() > max_length) |
| 719 validated->erase(max_length); | 719 validated->erase(max_length); |
| 720 *validated += extension; | 720 *validated += extension; |
| 721 } | 721 } |
| 722 | 722 |
| 723 static STGMEDIUM* GetStorageForFileDescriptor( | 723 static STGMEDIUM* GetStorageForFileDescriptor( |
| 724 const std::wstring& valid_file_name) { | 724 const std::wstring& valid_file_name) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 748 // static | 748 // static |
| 749 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 749 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
| 750 return new OSExchangeDataProviderWin(); | 750 return new OSExchangeDataProviderWin(); |
| 751 } | 751 } |
| 752 | 752 |
| 753 // static | 753 // static |
| 754 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( | 754 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( |
| 755 const std::string& type) { | 755 const std::string& type) { |
| 756 return RegisterClipboardFormat(ASCIIToWide(type).c_str()); | 756 return RegisterClipboardFormat(ASCIIToWide(type).c_str()); |
| 757 } | 757 } |
| OLD | NEW |