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

Side by Side Diff: ui/base/clipboard/clipboard_util_win.cc

Issue 183853011: Move TrimWhitespace to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/views/app_list_main_view.cc ('k') | ui/gfx/font_fallback_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 size_t fragment_start = std::string::npos; 449 size_t fragment_start = std::string::npos;
450 size_t fragment_end = std::string::npos; 450 size_t fragment_end = std::string::npos;
451 451
452 ClipboardUtil::CFHtmlExtractMetadata( 452 ClipboardUtil::CFHtmlExtractMetadata(
453 cf_html, base_url, NULL, &fragment_start, &fragment_end); 453 cf_html, base_url, NULL, &fragment_start, &fragment_end);
454 454
455 if (html && 455 if (html &&
456 fragment_start != std::string::npos && 456 fragment_start != std::string::npos &&
457 fragment_end != std::string::npos) { 457 fragment_end != std::string::npos) {
458 *html = cf_html.substr(fragment_start, fragment_end - fragment_start); 458 *html = cf_html.substr(fragment_start, fragment_end - fragment_start);
459 TrimWhitespace(*html, TRIM_ALL, html); 459 base::TrimWhitespace(*html, base::TRIM_ALL, html);
460 } 460 }
461 } 461 }
462 462
463 void ClipboardUtil::CFHtmlExtractMetadata(const std::string& cf_html, 463 void ClipboardUtil::CFHtmlExtractMetadata(const std::string& cf_html,
464 std::string* base_url, 464 std::string* base_url,
465 size_t* html_start, 465 size_t* html_start,
466 size_t* fragment_start, 466 size_t* fragment_start,
467 size_t* fragment_end) { 467 size_t* fragment_end) {
468 // Obtain base_url if present. 468 // Obtain base_url if present.
469 if (base_url) { 469 if (base_url) {
470 static std::string src_url_str("SourceURL:"); 470 static std::string src_url_str("SourceURL:");
471 size_t line_start = cf_html.find(src_url_str); 471 size_t line_start = cf_html.find(src_url_str);
472 if (line_start != std::string::npos) { 472 if (line_start != std::string::npos) {
473 size_t src_end = cf_html.find("\n", line_start); 473 size_t src_end = cf_html.find("\n", line_start);
474 size_t src_start = line_start + src_url_str.length(); 474 size_t src_start = line_start + src_url_str.length();
475 if (src_end != std::string::npos && src_start != std::string::npos) { 475 if (src_end != std::string::npos && src_start != std::string::npos) {
476 *base_url = cf_html.substr(src_start, src_end - src_start); 476 *base_url = cf_html.substr(src_start, src_end - src_start);
477 TrimWhitespace(*base_url, TRIM_ALL, base_url); 477 base::TrimWhitespace(*base_url, base::TRIM_ALL, base_url);
478 } 478 }
479 } 479 }
480 } 480 }
481 481
482 // Find the markup between "<!--StartFragment-->" and "<!--EndFragment-->". 482 // Find the markup between "<!--StartFragment-->" and "<!--EndFragment-->".
483 // If the comments cannot be found, like copying from OpenOffice Writer, 483 // If the comments cannot be found, like copying from OpenOffice Writer,
484 // we simply fall back to using StartFragment/EndFragment bytecount values 484 // we simply fall back to using StartFragment/EndFragment bytecount values
485 // to determine the fragment indexes. 485 // to determine the fragment indexes.
486 std::string cf_html_lower = StringToLowerASCII(cf_html); 486 std::string cf_html_lower = StringToLowerASCII(cf_html);
487 size_t markup_start = cf_html_lower.find("<html", 0); 487 size_t markup_start = cf_html_lower.find("<html", 0);
(...skipping 16 matching lines...) Expand all
504 end_fragment_start + end_fragment_str.length())); 504 end_fragment_start + end_fragment_str.length()));
505 } 505 }
506 } else { 506 } else {
507 *fragment_start = cf_html.find('>', tag_start) + 1; 507 *fragment_start = cf_html.find('>', tag_start) + 1;
508 size_t tag_end = cf_html.rfind("<!--EndFragment", std::string::npos); 508 size_t tag_end = cf_html.rfind("<!--EndFragment", std::string::npos);
509 *fragment_end = cf_html.rfind('<', tag_end); 509 *fragment_end = cf_html.rfind('<', tag_end);
510 } 510 }
511 } 511 }
512 512
513 } // namespace ui 513 } // namespace ui
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_main_view.cc ('k') | ui/gfx/font_fallback_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698