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

Side by Side Diff: content/renderer/android/phone_number_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/phone_number_detector.h" 5 #include "content/renderer/android/phone_number_detector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 GURL PhoneNumberDetector::GetIntentURL(const std::string& content_text) { 49 GURL PhoneNumberDetector::GetIntentURL(const std::string& content_text) {
50 if (content_text.empty()) 50 if (content_text.empty())
51 return GURL(); 51 return GURL();
52 52
53 return GURL(kPhoneNumberPrefix + 53 return GURL(kPhoneNumberPrefix +
54 net::EscapeQueryParamValue(content_text, true)); 54 net::EscapeQueryParamValue(content_text, true));
55 } 55 }
56 56
57 bool PhoneNumberDetector::FindContent(const string16::const_iterator& begin, 57 bool PhoneNumberDetector::FindContent(
58 const string16::const_iterator& end, 58 const base::string16::const_iterator& begin,
59 size_t* start_pos, 59 const base::string16::const_iterator& end,
60 size_t* end_pos, 60 size_t* start_pos,
61 std::string* content_text) { 61 size_t* end_pos,
62 string16 utf16_input = string16(begin, end); 62 std::string* content_text) {
63 base::string16 utf16_input = base::string16(begin, end);
63 std::string utf8_input = UTF16ToUTF8(utf16_input); 64 std::string utf8_input = UTF16ToUTF8(utf16_input);
64 65
65 PhoneNumberMatcher matcher(utf8_input, region_code_); 66 PhoneNumberMatcher matcher(utf8_input, region_code_);
66 if (matcher.HasNext()) { 67 if (matcher.HasNext()) {
67 PhoneNumberMatch match; 68 PhoneNumberMatch match;
68 matcher.Next(&match); 69 matcher.Next(&match);
69 70
70 PhoneNumberUtil* phone_util = PhoneNumberUtil::GetInstance(); 71 PhoneNumberUtil* phone_util = PhoneNumberUtil::GetInstance();
71 phone_util->FormatNumberForMobileDialing(match.number(), region_code_, 72 phone_util->FormatNumberForMobileDialing(match.number(), region_code_,
72 false, /* with_formatting */ 73 false, /* with_formatting */
73 content_text); 74 content_text);
74 // If the number can't be dialed from the current region, the formatted 75 // If the number can't be dialed from the current region, the formatted
75 // string will be empty. 76 // string will be empty.
76 if (content_text->empty()) 77 if (content_text->empty())
77 return false; 78 return false;
78 79
79 // Need to return start_pos and end_pos relative to a UTF16 encoding. 80 // Need to return start_pos and end_pos relative to a UTF16 encoding.
80 *start_pos = UTF8ToUTF16(utf8_input.substr(0, match.start())).length(); 81 *start_pos = UTF8ToUTF16(utf8_input.substr(0, match.start())).length();
81 *end_pos = *start_pos + UTF8ToUTF16(match.raw_string()).length(); 82 *end_pos = *start_pos + UTF8ToUTF16(match.raw_string()).length();
82 83
83 return true; 84 return true;
84 } 85 }
85 86
86 return false; 87 return false;
87 } 88 }
88 89
89 } // namespace content 90 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/phone_number_detector.h ('k') | content/renderer/android/phone_number_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698