Enable compiling with clang chrome plugins for GYP build

For standalone build, enable the compilation with
clang_use_chrome_plugins. Also remove the previous
clang_use_pdfium_plugins to be consistent with chrome
build, also avoid errors on chromeos_ozone build.

BUG=pdfium:469

Review-Url: https://codereview.chromium.org/2115813002
diff --git a/build_gyp/standalone.gypi b/build_gyp/standalone.gypi
index b2ec4b9..1affc3c 100644
--- a/build_gyp/standalone.gypi
+++ b/build_gyp/standalone.gypi
@@ -42,8 +42,10 @@
       },
       'host_arch%': '<(host_arch)',
       'target_arch%': '<(target_arch)',
+      'clang_use_chrome_plugins%': 0,
     },
     'clang_dir%': 'third_party/llvm-build/Release+Asserts',
+    'clang_use_chrome_plugins%': '<(clang_use_chrome_plugins)',
     # These two are needed by V8.
     'host_arch%': '<(host_arch)',
     'target_arch%': '<(target_arch)',
@@ -71,6 +73,40 @@
       }, {
         'gomadir%': '<!(/bin/echo -n ${HOME}/goma)',
       }],
+      ['clang_use_chrome_plugins==1', {
+        # Share the same settings as chromium in build/common.gypi.
+        'variables': {
+          'conditions': [
+            ['OS!="win"', {
+              'variables': {
+                'conditions': [
+                  ['OS=="mac" or OS=="ios"', {
+                    'clang_lib_path%': '<!(cd <(DEPTH) && pwd -P)/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib',
+                  }, { # OS != "mac" and OS != "ios"
+                    'clang_lib_path%': '<!(cd <(DEPTH) && pwd -P)/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so',
+                  }],
+                ],
+              },
+              'clang_dynlib_flags%': '-Xclang -load -Xclang <(clang_lib_path) ',
+            }, { # OS == "win"
+              # On Windows, the plugin is built directly into clang, so there's
+              # no need to load it dynamically.
+              'clang_dynlib_flags%': '',
+            }],
+            ['OS=="android" or OS=="linux"', {
+              'clang_plugin_check_ipc_arg': '-Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc',
+            }, {
+              'clang_plugin_check_ipc_arg': '',
+            }],
+          ],
+          'clang_plugin_args%': '-Xclang -plugin-arg-find-bad-constructs -Xclang check-templates '
+          '-Xclang -plugin-arg-find-bad-constructs -Xclang follow-macro-expansion '
+          '-Xclang -plugin-arg-find-bad-constructs -Xclang check-implicit-copy-ctors ',
+        },
+        'clang_chrome_plugins_flags%':
+          '<(clang_dynlib_flags)'
+          '-Xclang -add-plugin -Xclang find-bad-constructs <(clang_plugin_args) <(clang_plugin_check_ipc_arg)',
+      }],
     ],
   },
   'target_defaults': {
@@ -326,6 +362,11 @@
               '-Wno-microsoft-cast',  # http://crbug.com/550065
             ],
           }],
+          ['clang==1 and clang_use_chrome_plugins==1', {
+            'AdditionalOptions': [
+              '<@(clang_chrome_plugins_flags)',
+            ],
+          }],
           ['OS=="win" and clang==1 and MSVS_VERSION == "2013"', {
             'AdditionalOptions': [
               '-fmsc-version=1800',
@@ -378,6 +419,13 @@
         '-Wextra',
         '-Wno-unused-parameter',
       ],
+      'conditions': [
+        ['clang==1 and clang_use_chrome_plugins==1', {
+          'OTHER_CFLAGS': [
+            '<@(clang_chrome_plugins_flags)',
+          ],
+        }],
+      ],
     },
     'variables': {
       'chromium_code%': '<(chromium_code)',
@@ -388,6 +436,11 @@
     },
     'includes': [ 'set_clang_warning_flags.gypi', ],
     'conditions': [
+      ['clang==1 and clang_use_chrome_plugins==1', {
+        'cflags': [
+          '<@(clang_chrome_plugins_flags)',
+        ],
+      }],
       ['component=="shared_library"', {
         'cflags': [
           '-fPIC',
diff --git a/pdfium.gyp b/pdfium.gyp
index ca9f3f8..e54223c 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -5,15 +5,12 @@
 {
   'variables': {
     'chromium_code': 1,
-
-    'variables': {
-      'clang_use_pdfium_plugins%': 0,
-    },
-    'clang_use_pdfium_plugins%': '<(clang_use_pdfium_plugins)',
-
     'pdf_use_skia%': 0,
     'pdf_enable_v8%': 1,
     'pdf_enable_xfa%': 0, # Set to 1 by standalone.gypi in a standalone build.
+    'variables': {
+      'clang_use_chrome_plugins': 1,
+    },
     'conditions': [
       ['OS=="linux"', {
         'bundle_freetype%': 0,
@@ -21,33 +18,6 @@
             # few methods are used from it.
         'bundle_freetype%': 1,
       }],
-      ['clang_use_pdfium_plugins==1', {
-        'variables': {
-          'conditions': [
-            ['OS!="win"', {
-              'variables': {
-                'conditions': [
-                  ['OS=="mac" or OS=="ios"', {
-                    'clang_lib_path%': '<!(cd <(DEPTH) && pwd -P)/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib',
-                  }, { # OS != "mac" or OS != "ios"
-                    'clang_lib_path%': '<!(cd <(DEPTH) && pwd -P)/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so',
-                  }],
-                ],
-              },
-              'clang_dynlib_flags%': '-Xclang -load -Xclang <(clang_lib_path) ',
-            }, { # OS == "win"
-              # On Windows, the plugin is built directly into clang, so there's
-              # no need to load it dynamically.
-              'clang_dynlib_flags%': '',
-            }],
-          ],
-          'clang_plugin_args%': '-Xclang -plugin-arg-find-bad-constructs -Xclang check-templates '
-          '-Xclang -plugin-arg-find-bad-constructs -Xclang follow-macro-expansion ',
-        },
-        'clang_pdfium_plugins_flags%':
-          '<(clang_dynlib_flags)'
-          '-Xclang -add-plugin -Xclang find-bad-constructs <(clang_plugin_args)',
-      }],
     ],
   },
   'target_defaults': {
@@ -85,11 +55,6 @@
           }],
         ],
       }],
-      ['clang==1 and clang_use_pdfium_plugins==1', {
-        'cflags': [
-          '<@(clang_pdfium_plugins_flags)',
-        ],
-      }],
     ],
     'msvs_disabled_warnings': [
       4267,
diff --git a/xfa.gyp b/xfa.gyp
index 6a0d562..791a91d 100644
--- a/xfa.gyp
+++ b/xfa.gyp
@@ -2,6 +2,9 @@
   "variables": {
     "chromium_code": 1,
     "pdf_enable_v8%": 1,
+     "variables": {
+      'clang_use_chrome_plugins': 1,
+    },
   },
   "target_defaults": {
     "defines": [