| 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 #include "ui/base/clipboard/clipboard_util_win.h" | 5 #include "ui/base/clipboard/clipboard_util_win.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <shlwapi.h> | 8 #include <shlwapi.h> |
| 9 #include <wininet.h> // For INTERNET_MAX_URL_LENGTH. | 9 #include <wininet.h> // For INTERNET_MAX_URL_LENGTH. |
| 10 | 10 |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 *base_url = cf_html.substr(src_start, src_end - src_start); | 466 *base_url = cf_html.substr(src_start, src_end - src_start); |
| 467 base::TrimWhitespace(*base_url, base::TRIM_ALL, base_url); | 467 base::TrimWhitespace(*base_url, base::TRIM_ALL, base_url); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 // Find the markup between "<!--StartFragment-->" and "<!--EndFragment-->". | 472 // Find the markup between "<!--StartFragment-->" and "<!--EndFragment-->". |
| 473 // If the comments cannot be found, like copying from OpenOffice Writer, | 473 // If the comments cannot be found, like copying from OpenOffice Writer, |
| 474 // we simply fall back to using StartFragment/EndFragment bytecount values | 474 // we simply fall back to using StartFragment/EndFragment bytecount values |
| 475 // to determine the fragment indexes. | 475 // to determine the fragment indexes. |
| 476 std::string cf_html_lower = base::StringToLowerASCII(cf_html); | 476 std::string cf_html_lower = base::ToLowerASCII(cf_html); |
| 477 size_t markup_start = cf_html_lower.find("<html", 0); | 477 size_t markup_start = cf_html_lower.find("<html", 0); |
| 478 if (html_start) { | 478 if (html_start) { |
| 479 *html_start = markup_start; | 479 *html_start = markup_start; |
| 480 } | 480 } |
| 481 size_t tag_start = cf_html.find("<!--StartFragment", markup_start); | 481 size_t tag_start = cf_html.find("<!--StartFragment", markup_start); |
| 482 if (tag_start == std::string::npos) { | 482 if (tag_start == std::string::npos) { |
| 483 static std::string start_fragment_str("StartFragment:"); | 483 static std::string start_fragment_str("StartFragment:"); |
| 484 size_t start_fragment_start = cf_html.find(start_fragment_str); | 484 size_t start_fragment_start = cf_html.find(start_fragment_str); |
| 485 if (start_fragment_start != std::string::npos) { | 485 if (start_fragment_start != std::string::npos) { |
| 486 *fragment_start = static_cast<size_t>(atoi(cf_html.c_str() + | 486 *fragment_start = static_cast<size_t>(atoi(cf_html.c_str() + |
| 487 start_fragment_start + start_fragment_str.length())); | 487 start_fragment_start + start_fragment_str.length())); |
| 488 } | 488 } |
| 489 | 489 |
| 490 static std::string end_fragment_str("EndFragment:"); | 490 static std::string end_fragment_str("EndFragment:"); |
| 491 size_t end_fragment_start = cf_html.find(end_fragment_str); | 491 size_t end_fragment_start = cf_html.find(end_fragment_str); |
| 492 if (end_fragment_start != std::string::npos) { | 492 if (end_fragment_start != std::string::npos) { |
| 493 *fragment_end = static_cast<size_t>(atoi(cf_html.c_str() + | 493 *fragment_end = static_cast<size_t>(atoi(cf_html.c_str() + |
| 494 end_fragment_start + end_fragment_str.length())); | 494 end_fragment_start + end_fragment_str.length())); |
| 495 } | 495 } |
| 496 } else { | 496 } else { |
| 497 *fragment_start = cf_html.find('>', tag_start) + 1; | 497 *fragment_start = cf_html.find('>', tag_start) + 1; |
| 498 size_t tag_end = cf_html.rfind("<!--EndFragment", std::string::npos); | 498 size_t tag_end = cf_html.rfind("<!--EndFragment", std::string::npos); |
| 499 *fragment_end = cf_html.rfind('<', tag_end); | 499 *fragment_end = cf_html.rfind('<', tag_end); |
| 500 } | 500 } |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace ui | 503 } // namespace ui |
| OLD | NEW |