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

Side by Side Diff: content/renderer/android/email_detector.cc

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 "content/renderer/android/email_detector.h" 5 #include "content/renderer/android/email_detector.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/renderer/android_content_detection_prefixes.h" 10 #include "content/public/renderer/android_content_detection_prefixes.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 GURL EmailDetector::GetIntentURL(const std::string& content_text) { 37 GURL EmailDetector::GetIntentURL(const std::string& content_text) {
38 if (content_text.empty()) 38 if (content_text.empty())
39 return GURL(); 39 return GURL();
40 40
41 return GURL(kEmailPrefix + 41 return GURL(kEmailPrefix +
42 net::EscapeQueryParamValue(content_text, true)); 42 net::EscapeQueryParamValue(content_text, true));
43 } 43 }
44 44
45 bool EmailDetector::FindContent(const string16::const_iterator& begin, 45 bool EmailDetector::FindContent(const base::string16::const_iterator& begin,
46 const string16::const_iterator& end, 46 const base::string16::const_iterator& end,
47 size_t* start_pos, 47 size_t* start_pos,
48 size_t* end_pos, 48 size_t* end_pos,
49 std::string* content_text) { 49 std::string* content_text) {
50 string16 utf16_input = string16(begin, end); 50 base::string16 utf16_input = base::string16(begin, end);
51 icu::UnicodeString pattern(kEmailRegex); 51 icu::UnicodeString pattern(kEmailRegex);
52 icu::UnicodeString input(utf16_input.data(), utf16_input.length()); 52 icu::UnicodeString input(utf16_input.data(), utf16_input.length());
53 UErrorCode status = U_ZERO_ERROR; 53 UErrorCode status = U_ZERO_ERROR;
54 scoped_ptr<icu::RegexMatcher> matcher( 54 scoped_ptr<icu::RegexMatcher> matcher(
55 new icu::RegexMatcher(pattern, 55 new icu::RegexMatcher(pattern,
56 input, 56 input,
57 UREGEX_CASE_INSENSITIVE, 57 UREGEX_CASE_INSENSITIVE,
58 status)); 58 status));
59 if (matcher->find()) { 59 if (matcher->find()) {
60 *start_pos = matcher->start(status); 60 *start_pos = matcher->start(status);
61 DCHECK(U_SUCCESS(status)); 61 DCHECK(U_SUCCESS(status));
62 *end_pos = matcher->end(status); 62 *end_pos = matcher->end(status);
63 DCHECK(U_SUCCESS(status)); 63 DCHECK(U_SUCCESS(status));
64 icu::UnicodeString content_ustr(matcher->group(status)); 64 icu::UnicodeString content_ustr(matcher->group(status));
65 DCHECK(U_SUCCESS(status)); 65 DCHECK(U_SUCCESS(status));
66 UTF16ToUTF8(content_ustr.getBuffer(), content_ustr.length(), content_text); 66 UTF16ToUTF8(content_ustr.getBuffer(), content_ustr.length(), content_text);
67 return true; 67 return true;
68 } 68 }
69 69
70 return false; 70 return false;
71 } 71 }
72 72
73 } // namespace content 73 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/email_detector.h ('k') | content/renderer/android/email_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698