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

Unified Diff: ui/base/clipboard/clipboard_win.cc

Issue 8305012: Remove deprecated WebClipboard::readHTML method. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/glue/webclipboard_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard_win.cc
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index a2c515b343072938dc3ab2bb685468438525840e..635b4795a48a7f695105a763ecf9607c35ed1783 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -453,17 +453,22 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup,
size_t end_index = std::string::npos;
ClipboardUtil::CFHtmlExtractMetadata(cf_html, src_url, &html_start,
&start_index, &end_index);
- if (markup) {
- // Some sanity checks...
- DCHECK(start_index != std::string::npos);
- DCHECK(end_index != std::string::npos);
- DCHECK((start_index - html_start) <= kuint32max);
- DCHECK((end_index - html_start) <= kuint32max);
-
- markup->assign(UTF8ToWide(cf_html.data() + html_start));
- *fragment_start = static_cast<uint32>(start_index - html_start);
- *fragment_end = static_cast<uint32>(end_index - html_start);
- }
+
+ // This might happen if the contents of the clipboard changed and CF_HTML is
+ // no longer available.
+ if (start_index == std::string::npos ||
+ end_index == std::string::npos ||
+ html_start == std::string::npos)
+ return;
+
+ DCHECK(start_index - html_start >= 0);
+ DCHECK(end_index - html_start >= 0);
+ DCHECK((start_index - html_start) <= kuint32max);
+ DCHECK((end_index - html_start) <= kuint32max);
+
+ markup->assign(UTF8ToWide(cf_html.data() + html_start));
+ *fragment_start = static_cast<uint32>(start_index - html_start);
+ *fragment_end = static_cast<uint32>(end_index - html_start);
}
SkBitmap Clipboard::ReadImage(Buffer buffer) const {
« no previous file with comments | « no previous file | webkit/glue/webclipboard_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698