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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return GetDestinationTarget(dest, target); | 298 return GetDestinationTarget(dest, target); |
299 // TODO(gene): We don't fully support all types of the in-document | 299 // TODO(gene): We don't fully support all types of the in-document |
300 // links. Need to implement that. There is a bug to track that: | 300 // links. Need to implement that. There is a bug to track that: |
301 // http://code.google.com/p/chromium/issues/detail?id=55776 | 301 // http://code.google.com/p/chromium/issues/detail?id=55776 |
302 } break; | 302 } break; |
303 case PDFACTION_URI: { | 303 case PDFACTION_URI: { |
304 if (target) { | 304 if (target) { |
305 size_t buffer_size = | 305 size_t buffer_size = |
306 FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0); | 306 FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0); |
307 if (buffer_size > 1) { | 307 if (buffer_size > 1) { |
308 void* data = WriteInto(&target->url, buffer_size); | 308 void* data = WriteInto(&target->url, buffer_size + 1); |
309 FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size); | 309 FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size); |
310 } | 310 } |
311 } | 311 } |
312 return WEBLINK_AREA; | 312 return WEBLINK_AREA; |
313 } break; | 313 } break; |
314 // TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH | 314 // TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH |
315 // at the moment. | 315 // at the moment. |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 return; | 382 return; |
383 | 383 |
384 calculated_links_ = true; | 384 calculated_links_ = true; |
385 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage()); | 385 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage()); |
386 int count = FPDFLink_CountWebLinks(links); | 386 int count = FPDFLink_CountWebLinks(links); |
387 for (int i = 0; i < count; ++i) { | 387 for (int i = 0; i < count; ++i) { |
388 base::string16 url; | 388 base::string16 url; |
389 int url_length = FPDFLink_GetURL(links, i, NULL, 0); | 389 int url_length = FPDFLink_GetURL(links, i, NULL, 0); |
390 if (url_length > 1) { // WriteInto needs at least 2 characters. | 390 if (url_length > 1) { // WriteInto needs at least 2 characters. |
391 unsigned short* data = | 391 unsigned short* data = |
392 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length)); | 392 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1)); |
393 FPDFLink_GetURL(links, i, data, url_length); | 393 FPDFLink_GetURL(links, i, data, url_length); |
394 } | 394 } |
395 Link link; | 395 Link link; |
396 link.url = base::UTF16ToUTF8(url); | 396 link.url = base::UTF16ToUTF8(url); |
397 | 397 |
398 // If the link cannot be converted to a pp::Var, then it is not possible to | 398 // If the link cannot be converted to a pp::Var, then it is not possible to |
399 // pass it to JS. In this case, ignore the link like other PDF viewers. | 399 // pass it to JS. In this case, ignore the link like other PDF viewers. |
400 // See http://crbug.com/312882 for an example. | 400 // See http://crbug.com/312882 for an example. |
401 pp::Var link_var(link.url); | 401 pp::Var link_var(link.url); |
402 if (!link_var.is_string()) | 402 if (!link_var.is_string()) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 new_left, new_top, new_right - new_left + 1, new_bottom - new_top + 1); | 468 new_left, new_top, new_right - new_left + 1, new_bottom - new_top + 1); |
469 } | 469 } |
470 | 470 |
471 PDFiumPage::Link::Link() { | 471 PDFiumPage::Link::Link() { |
472 } | 472 } |
473 | 473 |
474 PDFiumPage::Link::~Link() { | 474 PDFiumPage::Link::~Link() { |
475 } | 475 } |
476 | 476 |
477 } // namespace chrome_pdf | 477 } // namespace chrome_pdf |
OLD | NEW |