| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 return GetDestinationTarget(dest, target); | 317 return GetDestinationTarget(dest, target); |
| 318 // TODO(gene): We don't fully support all types of the in-document | 318 // TODO(gene): We don't fully support all types of the in-document |
| 319 // links. Need to implement that. There is a bug to track that: | 319 // links. Need to implement that. There is a bug to track that: |
| 320 // http://code.google.com/p/chromium/issues/detail?id=55776 | 320 // http://code.google.com/p/chromium/issues/detail?id=55776 |
| 321 } break; | 321 } break; |
| 322 case PDFACTION_URI: { | 322 case PDFACTION_URI: { |
| 323 if (target) { | 323 if (target) { |
| 324 size_t buffer_size = | 324 size_t buffer_size = |
| 325 FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0); | 325 FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0); |
| 326 if (buffer_size > 1) { | 326 if (buffer_size > 1) { |
| 327 void* data = WriteInto(&target->url, buffer_size + 1); | 327 void* data = WriteInto(&target->url, buffer_size); |
| 328 FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size); | 328 FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 return WEBLINK_AREA; | 331 return WEBLINK_AREA; |
| 332 } break; | 332 } break; |
| 333 // TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH | 333 // TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH |
| 334 // at the moment. | 334 // at the moment. |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 void PDFiumPage::CalculateLinks() { | 399 void PDFiumPage::CalculateLinks() { |
| 400 if (calculated_links_) | 400 if (calculated_links_) |
| 401 return; | 401 return; |
| 402 | 402 |
| 403 calculated_links_ = true; | 403 calculated_links_ = true; |
| 404 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage()); | 404 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage()); |
| 405 int count = FPDFLink_CountWebLinks(links); | 405 int count = FPDFLink_CountWebLinks(links); |
| 406 for (int i = 0; i < count; ++i) { | 406 for (int i = 0; i < count; ++i) { |
| 407 base::string16 url; | 407 base::string16 url; |
| 408 int url_length = FPDFLink_GetURL(links, i, NULL, 0); | 408 int url_length = FPDFLink_GetURL(links, i, NULL, 0); |
| 409 if (url_length > 1) { // WriteInto needs at least 2 characters. | 409 if (url_length > 0) { |
| 410 unsigned short* data = | 410 unsigned short* data = |
| 411 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1)); | 411 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1)); |
| 412 FPDFLink_GetURL(links, i, data, url_length); | 412 FPDFLink_GetURL(links, i, data, url_length); |
| 413 } | 413 } |
| 414 Link link; | 414 Link link; |
| 415 link.url = base::UTF16ToUTF8(url); | 415 link.url = base::UTF16ToUTF8(url); |
| 416 | 416 |
| 417 // If the link cannot be converted to a pp::Var, then it is not possible to | 417 // If the link cannot be converted to a pp::Var, then it is not possible to |
| 418 // pass it to JS. In this case, ignore the link like other PDF viewers. | 418 // pass it to JS. In this case, ignore the link like other PDF viewers. |
| 419 // See http://crbug.com/312882 for an example. | 419 // See http://crbug.com/312882 for an example. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 page_->loading_count_--; | 496 page_->loading_count_--; |
| 497 } | 497 } |
| 498 | 498 |
| 499 PDFiumPage::Link::Link() { | 499 PDFiumPage::Link::Link() { |
| 500 } | 500 } |
| 501 | 501 |
| 502 PDFiumPage::Link::~Link() { | 502 PDFiumPage::Link::~Link() { |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace chrome_pdf | 505 } // namespace chrome_pdf |
| OLD | NEW |