| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "pdf/pdfium/pdfium_page.h" | 5 #include "pdf/pdfium/pdfium_page.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Remove the extra NULL character at end. | 182 // Remove the extra NULL character at end. |
| 183 // Otherwise, find() will not return any matches. | 183 // Otherwise, find() will not return any matches. |
| 184 if (targets[i].url.size() > 0 && | 184 if (targets[i].url.size() > 0 && |
| 185 targets[i].url[targets[i].url.size() - 1] == '\0') { | 185 targets[i].url[targets[i].url.size() - 1] == '\0') { |
| 186 targets[i].url.resize(targets[i].url.size() - 1); | 186 targets[i].url.resize(targets[i].url.size() - 1); |
| 187 } | 187 } |
| 188 // There should only ever be one NULL character | 188 // There should only ever be one NULL character |
| 189 DCHECK(targets[i].url[targets[i].url.size() - 1] != '\0'); | 189 DCHECK(targets[i].url[targets[i].url.size() - 1] != '\0'); |
| 190 | 190 |
| 191 // PDFium may change the case of generated links. | 191 // PDFium may change the case of generated links. |
| 192 std::string lowerCaseURL = StringToLowerASCII(targets[i].url); | 192 std::string lowerCaseURL = base::StringToLowerASCII(targets[i].url); |
| 193 std::string lowerCaseText = StringToLowerASCII(text_utf8); | 193 std::string lowerCaseText = base::StringToLowerASCII(text_utf8); |
| 194 size_t pos = lowerCaseText.find(lowerCaseURL, start); | 194 size_t pos = lowerCaseText.find(lowerCaseURL, start); |
| 195 size_t length = targets[i].url.size(); | 195 size_t length = targets[i].url.size(); |
| 196 if (pos == std::string::npos) { | 196 if (pos == std::string::npos) { |
| 197 // Check if the link is a "mailto:" URL | 197 // Check if the link is a "mailto:" URL |
| 198 if (lowerCaseURL.compare(0, 7, "mailto:") == 0) { | 198 if (lowerCaseURL.compare(0, 7, "mailto:") == 0) { |
| 199 pos = lowerCaseText.find(lowerCaseURL.substr(7), start); | 199 pos = lowerCaseText.find(lowerCaseURL.substr(7), start); |
| 200 length -= 7; | 200 length -= 7; |
| 201 } | 201 } |
| 202 | 202 |
| 203 if (pos == std::string::npos) { | 203 if (pos == std::string::npos) { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 new_left, new_top, new_right - new_left + 1, new_bottom - new_top + 1); | 469 new_left, new_top, new_right - new_left + 1, new_bottom - new_top + 1); |
| 470 } | 470 } |
| 471 | 471 |
| 472 PDFiumPage::Link::Link() { | 472 PDFiumPage::Link::Link() { |
| 473 } | 473 } |
| 474 | 474 |
| 475 PDFiumPage::Link::~Link() { | 475 PDFiumPage::Link::~Link() { |
| 476 } | 476 } |
| 477 | 477 |
| 478 } // namespace chrome_pdf | 478 } // namespace chrome_pdf |
| OLD | NEW |