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

Side by Side Diff: base/string_util.cc

Issue 8885: Implementation of the UI part of the autofill (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 | « base/string_util.h ('k') | base/string_util_unittest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/string_util.h" 5 #include "base/string_util.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <math.h> 9 #include <math.h>
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 652
653 bool StartsWithASCII(const std::string& str, 653 bool StartsWithASCII(const std::string& str,
654 const std::string& search, 654 const std::string& search,
655 bool case_sensitive) { 655 bool case_sensitive) {
656 if (case_sensitive) 656 if (case_sensitive)
657 return str.compare(0, search.length(), search) == 0; 657 return str.compare(0, search.length(), search) == 0;
658 else 658 else
659 return base::strncasecmp(str.c_str(), search.c_str(), search.length()) == 0; 659 return base::strncasecmp(str.c_str(), search.c_str(), search.length()) == 0;
660 } 660 }
661 661
662 bool StartsWith(const std::wstring& str,
663 const std::wstring& search,
664 bool case_sensitive) {
665 if (case_sensitive)
666 return str.compare(0, search.length(), search) == 0;
667 else {
668 if (search.size() > str.size())
669 return false;
670 return std::equal(search.begin(), search.end(), str.begin(),
671 CaseInsensitiveCompare<wchar_t>());
672 }
673 }
674
662 DataUnits GetByteDisplayUnits(int64 bytes) { 675 DataUnits GetByteDisplayUnits(int64 bytes) {
663 // The byte thresholds at which we display amounts. A byte count is displayed 676 // The byte thresholds at which we display amounts. A byte count is displayed
664 // in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1]. 677 // in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1].
665 // This must match the DataUnits enum. 678 // This must match the DataUnits enum.
666 static const int64 kUnitThresholds[] = { 679 static const int64 kUnitThresholds[] = {
667 0, // DATA_UNITS_BYTE, 680 0, // DATA_UNITS_BYTE,
668 3*1024, // DATA_UNITS_KILOBYTE, 681 3*1024, // DATA_UNITS_KILOBYTE,
669 2*1024*1024, // DATA_UNITS_MEGABYTE, 682 2*1024*1024, // DATA_UNITS_MEGABYTE,
670 1024*1024*1024 // DATA_UNITS_GIGABYTE, 683 1024*1024*1024 // DATA_UNITS_GIGABYTE,
671 }; 684 };
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 int rstr_len = (max_len - 3) / 2; 1476 int rstr_len = (max_len - 3) / 2;
1464 int lstr_len = rstr_len + ((max_len - 3) % 2); 1477 int lstr_len = rstr_len + ((max_len - 3) % 2);
1465 output->assign(input.substr(0, lstr_len) + L"..." + 1478 output->assign(input.substr(0, lstr_len) + L"..." +
1466 input.substr(input.length() - rstr_len)); 1479 input.substr(input.length() - rstr_len));
1467 break; 1480 break;
1468 } 1481 }
1469 } 1482 }
1470 1483
1471 return true; 1484 return true;
1472 } 1485 }
OLDNEW
« no previous file with comments | « base/string_util.h ('k') | base/string_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698