Properly support the use_system_libtiff GN build option

The changes in https://pdfium-review.googlesource.com/105650 were not
sufficient, as it still relied on //third_party/libtiff headers. Change
the C++ code to use the system libtiff header when appropriate, similar
to how use_system_libpng is implemented.

Bug: chromium:1501495
Change-Id: I194ef66ba02067222a55630259151f247bae9ecf
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/113595
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/tiff/tiff_decoder.cpp b/core/fxcodec/tiff/tiff_decoder.cpp
index 928b7eb..a26f7b8 100644
--- a/core/fxcodec/tiff/tiff_decoder.cpp
+++ b/core/fxcodec/tiff/tiff_decoder.cpp
@@ -23,7 +23,11 @@
 #include "third_party/base/numerics/safe_conversions.h"
 
 extern "C" {
+#if defined(USE_SYSTEM_LIBTIFF)
+#include <tiffio.h>
+#else
 #include "third_party/libtiff/tiffio.h"
+#endif
 }  // extern C
 
 namespace {
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index bf12e49..04ad71d 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -457,6 +457,7 @@
   if (use_system_libtiff) {
     config("system_tiff_config") {
       libs = [ "tiff" ]
+      defines = [ "USE_SYSTEM_LIBTIFF" ]
     }
   } else {
     source_set("fx_tiff") {