| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 return; | 561 return; |
| 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 // Ensure the Fragment points within the string; see https://crbug.com/607181. |
| 572 *fragment_end = base::checked_cast<uint32_t>(offsets[1]); | 572 size_t end = std::min(offsets[1], markup->length()); |
| 573 *fragment_start = base::checked_cast<uint32_t>(std::min(offsets[0], end)); |
| 574 *fragment_end = base::checked_cast<uint32_t>(end); |
| 573 } | 575 } |
| 574 | 576 |
| 575 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { | 577 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { |
| 576 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 578 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
| 577 | 579 |
| 578 ReadData(GetRtfFormatType(), result); | 580 ReadData(GetRtfFormatType(), result); |
| 579 } | 581 } |
| 580 | 582 |
| 581 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { | 583 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { |
| 582 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 584 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 if (!clipboard_owner_) | 900 if (!clipboard_owner_) |
| 899 return NULL; | 901 return NULL; |
| 900 | 902 |
| 901 if (clipboard_owner_->hwnd() == NULL) | 903 if (clipboard_owner_->hwnd() == NULL) |
| 902 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); | 904 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); |
| 903 | 905 |
| 904 return clipboard_owner_->hwnd(); | 906 return clipboard_owner_->hwnd(); |
| 905 } | 907 } |
| 906 | 908 |
| 907 } // namespace ui | 909 } // namespace ui |
| OLD | NEW |