Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // Many of these functions are based on those found in | 5 // Many of these functions are based on those found in |
| 6 // webkit/port/platform/PasteboardWin.cpp | 6 // webkit/port/platform/PasteboardWin.cpp |
| 7 | 7 |
| 8 #include "ui/base/clipboard/clipboard_win.h" | 8 #include "ui/base/clipboard/clipboard_win.h" |
| 9 | 9 |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 | 562 |
| 563 if (start_index < html_start || end_index < start_index) | 563 if (start_index < html_start || end_index < start_index) |
| 564 return; | 564 return; |
| 565 | 565 |
| 566 std::vector<size_t> offsets; | 566 std::vector<size_t> offsets; |
| 567 offsets.push_back(start_index - html_start); | 567 offsets.push_back(start_index - html_start); |
| 568 offsets.push_back(end_index - html_start); | 568 offsets.push_back(end_index - html_start); |
| 569 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, | 569 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, |
| 570 &offsets)); | 570 &offsets)); |
| 571 *fragment_start = base::checked_cast<uint32_t>(offsets[0]); | 571 *fragment_start = base::checked_cast<uint32_t>(offsets[0]); |
| 572 *fragment_end = base::checked_cast<uint32_t>(offsets[1]); | 572 |
| 573 // Ensure EndFragment points within the string; see https://crbug.com/607181. | |
| 574 *fragment_end = | |
| 575 base::checked_cast<uint32_t>(std::min(offsets[1], markup->length())); | |
|
dcheng
2017/04/22 08:25:25
Should we do this for offsets[0] as well?
elawrence
2017/04/25 16:20:19
Embedded nulls (the known repro case) aren't probl
dcheng
2017/04/26 00:42:08
Why can't embedded nulls appear before fragment st
elawrence
2017/04/26 15:11:22
Ah, you're right in the general case. In the case
| |
| 573 } | 576 } |
| 574 | 577 |
| 575 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { | 578 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { |
| 576 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 579 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
| 577 | 580 |
| 578 ReadData(GetRtfFormatType(), result); | 581 ReadData(GetRtfFormatType(), result); |
| 579 } | 582 } |
| 580 | 583 |
| 581 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { | 584 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { |
| 582 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 585 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 if (!clipboard_owner_) | 901 if (!clipboard_owner_) |
| 899 return NULL; | 902 return NULL; |
| 900 | 903 |
| 901 if (clipboard_owner_->hwnd() == NULL) | 904 if (clipboard_owner_->hwnd() == NULL) |
| 902 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); | 905 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); |
| 903 | 906 |
| 904 return clipboard_owner_->hwnd(); | 907 return clipboard_owner_->hwnd(); |
| 905 } | 908 } |
| 906 | 909 |
| 907 } // namespace ui | 910 } // namespace ui |
| OLD | NEW |