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

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

Issue 10539028: Only paste the fragment of text which was copied to the clipboard. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 5 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
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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 #define NUMBER_FORMAT MAKE_NUMBER_FORMAT_1(MAX_DIGITS) 480 #define NUMBER_FORMAT MAKE_NUMBER_FORMAT_1(MAX_DIGITS)
481 481
482 static const char* header = "Version:0.9\r\n" 482 static const char* header = "Version:0.9\r\n"
483 "StartHTML:" NUMBER_FORMAT "\r\n" 483 "StartHTML:" NUMBER_FORMAT "\r\n"
484 "EndHTML:" NUMBER_FORMAT "\r\n" 484 "EndHTML:" NUMBER_FORMAT "\r\n"
485 "StartFragment:" NUMBER_FORMAT "\r\n" 485 "StartFragment:" NUMBER_FORMAT "\r\n"
486 "EndFragment:" NUMBER_FORMAT "\r\n"; 486 "EndFragment:" NUMBER_FORMAT "\r\n";
487 static const char* source_url_prefix = "SourceURL:"; 487 static const char* source_url_prefix = "SourceURL:";
488 488
489 static const char* start_markup = 489 static const char* start_markup =
490 "<html>\r\n<body>\r\n<!--StartFragment-->\r\n"; 490 "<html>\r\n<body>\r\n<!--StartFragment-->";
491 static const char* end_markup = 491 static const char* end_markup =
492 "\r\n<!--EndFragment-->\r\n</body>\r\n</html>"; 492 "<!--EndFragment-->\r\n</body>\r\n</html>";
493 493
494 // Calculate offsets 494 // Calculate offsets
495 size_t start_html_offset = strlen(header) - strlen(NUMBER_FORMAT) * 4 + 495 size_t start_html_offset = strlen(header) - strlen(NUMBER_FORMAT) * 4 +
496 MAX_DIGITS * 4; 496 MAX_DIGITS * 4;
497 if (!base_url.empty()) { 497 if (!base_url.empty()) {
498 start_html_offset += strlen(source_url_prefix) + 498 start_html_offset += strlen(source_url_prefix) +
499 base_url.length() + 2; // Add 2 for \r\n. 499 base_url.length() + 2; // Add 2 for \r\n.
500 } 500 }
501 size_t start_fragment_offset = start_html_offset + strlen(start_markup); 501 size_t start_fragment_offset = start_html_offset + strlen(start_markup);
502 size_t end_fragment_offset = start_fragment_offset + html.length(); 502 size_t end_fragment_offset = start_fragment_offset + html.length();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 end_fragment_start + end_fragment_str.length())); 586 end_fragment_start + end_fragment_str.length()));
587 } 587 }
588 } else { 588 } else {
589 *fragment_start = cf_html.find('>', tag_start) + 1; 589 *fragment_start = cf_html.find('>', tag_start) + 1;
590 size_t tag_end = cf_html.rfind("<!--EndFragment", std::string::npos); 590 size_t tag_end = cf_html.rfind("<!--EndFragment", std::string::npos);
591 *fragment_end = cf_html.rfind('<', tag_end); 591 *fragment_end = cf_html.rfind('<', tag_end);
592 } 592 }
593 } 593 }
594 594
595 } // namespace ui 595 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/dragdrop/os_exchange_data_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698