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

Unified Diff: content/renderer/android/email_detector.cc

Issue 2790893004: Delete Android content detectors. (Closed)
Patch Set: Rebase Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/android/email_detector.cc
diff --git a/content/renderer/android/email_detector.cc b/content/renderer/android/email_detector.cc
deleted file mode 100644
index 1a0db8b07a850ec383b75e0be6dc209e16e43fbf..0000000000000000000000000000000000000000
--- a/content/renderer/android/email_detector.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/android/email_detector.h"
-
-#include <memory>
-
-#include "base/logging.h"
-#include "base/strings/utf_string_conversions.h"
-#include "content/public/renderer/android_content_detection_prefixes.h"
-#include "net/base/escape.h"
-#include "third_party/icu/source/i18n/unicode/regex.h"
-
-namespace {
-
-// Maximum length of an email address.
-const size_t kMaximumEmailLength = 254;
-
-// Regex to match email addresses.
-// This is more specific than RFC 2822 (uncommon special characters are
-// disallowed) in order to avoid false positives.
-// Delimiters are word boundaries to allow punctuation, quote marks etc. around
-// the address.
-const char kEmailRegex[] =
- "\\b[A-Z0-9._%+-]+@[A-Z0-9-]+(\\.[A-Z0-9-]+)*(\\.[A-Z]{2,6})\\b";
-
-} // anonymous namespace
-
-namespace content {
-
-EmailDetector::EmailDetector() {
-}
-
-size_t EmailDetector::GetMaximumContentLength() {
- return kMaximumEmailLength;
-}
-
-GURL EmailDetector::GetIntentURL(const std::string& content_text) {
- if (content_text.empty())
- return GURL();
-
- return GURL(kEmailPrefix +
- net::EscapeQueryParamValue(content_text, true));
-}
-
-bool EmailDetector::FindContent(const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end,
- size_t* start_pos,
- size_t* end_pos,
- std::string* content_text) {
- base::string16 utf16_input = base::string16(begin, end);
- icu::UnicodeString pattern(kEmailRegex);
- icu::UnicodeString input(utf16_input.data(), utf16_input.length());
- UErrorCode status = U_ZERO_ERROR;
- std::unique_ptr<icu::RegexMatcher> matcher(
- new icu::RegexMatcher(pattern, input, UREGEX_CASE_INSENSITIVE, status));
- if (matcher->find()) {
- *start_pos = matcher->start(status);
- DCHECK(U_SUCCESS(status));
- *end_pos = matcher->end(status);
- DCHECK(U_SUCCESS(status));
- icu::UnicodeString content_ustr(matcher->group(status));
- DCHECK(U_SUCCESS(status));
- content_text->clear();
- content_ustr.toUTF8String(*content_text);
- return true;
- }
-
- return false;
-}
-
-} // namespace content
« 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