Work on "gn check" of content/*

This fixes most, but not all, errors identified by "gn check"

[email protected]

Review URL: https://codereview.chromium.org/551103002

Cr-Commit-Position: refs/heads/master@{#294036}
diff --git a/content/BUILD.gn b/content/BUILD.gn
index 22c0332..7f4a198 100644
--- a/content/BUILD.gn
+++ b/content/BUILD.gn
@@ -12,7 +12,7 @@
 content_shared_components = [
   "//content/gpu",
   "//content/plugin",
-  "//content/public/browser:sources",
+  "//content/public/browser:browser_sources",
   "//content/public/child",
   "//content/public/common",
   "//content/public/plugin",
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 36898fb3..da48444 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -27,11 +27,13 @@
     "//content:resources",
     "//content/browser/service_worker:proto",
     "//content/browser/speech/proto",
+    "//content/public/common",
     "//crypto",
     "//google_apis",
     "//net",
     "//skia",
     "//sql",
+    "//third_party/npapi",
     "//third_party/re2",
     "//third_party/WebKit/public:blink_headers",
     "//third_party/zlib",
@@ -43,8 +45,11 @@
     "//ui/events:gesture_detection",
     "//ui/gfx",
     "//ui/gfx/geometry",
+    "//ui/gl",
+    "//ui/native_theme",
     "//ui/resources",
     "//ui/snapshot",
+    "//ui/wm",
   ]
 
   if (is_ios) {
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index ee23601..2b1b7a2 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -265,7 +265,6 @@
       'renderer/media/media_stream_constraints_util.h',
       'renderer/media/media_stream_dispatcher.h',
       'renderer/media/media_stream_dispatcher_eventhandler.h',
-      'renderer/media/media_stream_impl.h',
       'renderer/media/media_stream_track.cc',
       'renderer/media/media_stream_track.h',
       'renderer/media/midi_dispatcher.cc',
@@ -430,7 +429,6 @@
       'renderer/npapi/webplugin_impl.h',
       'renderer/pepper/audio_helper.cc',
       'renderer/pepper/audio_helper.h',
-      'renderer/pepper/common.h',
       'renderer/pepper/content_decryptor_delegate.cc',
       'renderer/pepper/content_decryptor_delegate.h',
       'renderer/pepper/content_renderer_pepper_host_factory.cc',
diff --git a/content/public/app/BUILD.gn b/content/public/app/BUILD.gn
index fa087e3..bcced87 100644
--- a/content/public/app/BUILD.gn
+++ b/content/public/app/BUILD.gn
@@ -3,12 +3,13 @@
 # found in the LICENSE file.
 
 # Used internally to hold the sources shared between the various targets below.
-source_set("app_sources") {
+source_set("app_shared_sources") {
+  # content_main_delegate.cc has ifdefs that depend on whether the file is
+  # being used in the context of the browser or child process. So that file has
+  # to be included in the per-type targets below rather than in this shared one.
   sources = [
     "android_library_loader_hooks.h",
     "content_main.h",
-    "content_main_delegate.cc",
-    "content_main_delegate.h",
     "content_main_runner.h",
     "startup_helper_win.h",
   ]
@@ -19,6 +20,7 @@
     "//base",
     "//base:i18n",
     "//content:export",
+    "//content/common",
     "//content/public/plugin",
     "//content/public/renderer",
     "//content/public/utility",
@@ -28,10 +30,17 @@
 # The structure of this is like the private content/app implementation.
 if (is_component_build) {
 
-  group("app") {
+  source_set("app") {
+    sources = [
+      "content_main_delegate.cc",
+      "content_main_delegate.h",
+    ]
+
     deps = [
-      ":app_sources",
+      ":app_shared_sources",
       "//content/app",
+      "//content/common",
+      "//content/public/browser",
     ]
   }
   group("browser") {
@@ -46,22 +55,54 @@
 
 } else {
 
-  group("browser") {
+  source_set("browser") {
+    # See comment in "child" target.
+    check_includes = false
+    sources = [
+      "content_main_delegate.cc",
+      "content_main_delegate.h",
+    ]
     deps = [
-      ":app_sources",
-      "//content/app:browser"
+      ":app_shared_sources",
+      "//content/app:browser",
+      "//content/public/browser",
+      "//content/public/common",
     ]
   }
-  group("child") {
+  source_set("child") {
+    # content_main_delegate.cc conditionally includes content_browser_client.h
+    # from //content/public/browser when it's not the child build. However,
+    # the header checker doesn't know this doesn't apply and throws an error.
+    #
+    # TODO(brettw) either teach the header checker to understand simple
+    # ifdefs or split the file apart so we can enable header checking here.
+    # Furthermore, since this file exists in more than one target, they all
+    # have to opt-out of header checking (a file is checked once for all
+    # targets using a source file).
+    check_includes = false
+
+    sources = [
+      "content_main_delegate.cc",
+      "content_main_delegate.h",
+    ]
     deps = [
-      ":app_sources",
-      "//content/app:child"
+      ":app_shared_sources",
+      "//content/app:child",
+      "//content/public/common",
     ]
   }
-  group("both") {
+  source_set("both") {
+    # See comment in "child" target.
+    check_includes = false
+    sources = [
+      "content_main_delegate.cc",
+      "content_main_delegate.h",
+    ]
     deps = [
-      ":app_sources",
-      "//content/app:both"
+      ":app_shared_sources",
+      "//content/app:both",
+      "//content/public/browser",
+      "//content/public/common",
     ]
   }
 
diff --git a/content/public/app/content_main_delegate.cc b/content/public/app/content_main_delegate.cc
index 498bc865..e86f6c8c3 100644
--- a/content/public/app/content_main_delegate.cc
+++ b/content/public/app/content_main_delegate.cc
@@ -4,7 +4,9 @@
 
 #include "content/public/app/content_main_delegate.h"
 
+#if !defined(CHROME_MULTIPLE_DLL_CHILD)
 #include "content/public/browser/content_browser_client.h"
+#endif
 
 #if !defined(OS_IOS)
 #include "content/public/plugin/content_plugin_client.h"
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn
index a9534846..c51628f 100644
--- a/content/public/browser/BUILD.gn
+++ b/content/public/browser/BUILD.gn
@@ -9,12 +9,12 @@
   if (is_component_build) {
     deps = [ "//content" ]
   } else {
-    deps = [ ":sources" ]
+    deps = [ ":browser_sources" ]
   }
   forward_dependent_configs_from = deps
 }
 
-source_set("sources") {
+source_set("browser_sources") {
   if (is_ios) {
     # iOS doesn't get the normal file list and only takes these whitelisted
     # files.
@@ -40,7 +40,18 @@
 
   deps = [
     "//content/browser",
+    "//content/public/common",
+    "//net",
     "//skia",
+    "//ui/accessibility",
+    "//ui/base",
+    "//ui/events",
+  ]
+
+  allow_circular_includes_from = [
+    # This target is a pair with content/browser. They always go together and
+    # include headers from each other.
+    "//content/browser",
   ]
 
   # We expose skia headers in the public API.
diff --git a/content/public/child/BUILD.gn b/content/public/child/BUILD.gn
index 9dc2c30..9a7c49e5 100644
--- a/content/public/child/BUILD.gn
+++ b/content/public/child/BUILD.gn
@@ -14,5 +14,6 @@
 
   deps = [
     "//content/child",
+    "//content/public/common",
   ]
 }
diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn
index 8e1038d..60bb14c 100644
--- a/content/public/common/BUILD.gn
+++ b/content/public/common/BUILD.gn
@@ -15,11 +15,16 @@
 
   deps = [
     "//content/common",
+    "//net",
     "//skia",
     "//third_party/WebKit/public:blink_headers",
     "//third_party/icu",
+    "//ui/base",
+    "//ui/gfx",
   ]
 
+  forward_dependent_configs_from = [ "//content/common" ]
+
   if (!enable_plugins) {
     sources -= [
       "pepper_plugin_info.cc",
diff --git a/content/public/plugin/BUILD.gn b/content/public/plugin/BUILD.gn
index 9147cb8..587043e 100644
--- a/content/public/plugin/BUILD.gn
+++ b/content/public/plugin/BUILD.gn
@@ -8,6 +8,8 @@
   ]
 
   deps = [
+    "//base",
     "//content/plugin",
+    "//content/public/common",
   ]
 }
diff --git a/content/public/renderer/BUILD.gn b/content/public/renderer/BUILD.gn
index 37ccf23..021f08a 100644
--- a/content/public/renderer/BUILD.gn
+++ b/content/public/renderer/BUILD.gn
@@ -14,14 +14,22 @@
   ]
 
   deps = [
+    "//content/public/common",
     "//content/renderer",
     "//skia",
     "//third_party/libjingle",
     "//third_party/WebKit/public:blink_headers",
     "//third_party/widevine/cdm:version_h",
+    "//ui/gfx",
     "//v8",
   ]
 
+  allow_circular_includes_from = [
+    # This target is a pair with content/renderer. They always go together and
+    # include headers from each other.
+    "//content/renderer",
+  ]
+
   if (enable_webrtc) {
     sources += rebase_path(
         content_renderer_gypi_values.public_renderer_webrtc_sources,
diff --git a/content/public/utility/BUILD.gn b/content/public/utility/BUILD.gn
index 7813b39..a1ab076 100644
--- a/content/public/utility/BUILD.gn
+++ b/content/public/utility/BUILD.gn
@@ -15,8 +15,15 @@
   deps = [
     "//base",
     "//content:export",
+    "//content/public/common",
     "//content/utility",
     "//ipc",
   ]
+
+  allow_circular_includes_from = [
+    # This target is a pair with content/browser. They always go together and
+    # include headers from each other.
+    "//content/utility",
+  ]
 }
 
diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
index eaad7f2..7f689a5 100644
--- a/content/renderer/BUILD.gn
+++ b/content/renderer/BUILD.gn
@@ -23,9 +23,12 @@
     "//crypto:platform",
 
     "//base/allocator",
+    "//cc",
     "//cc/blink",
     "//content:resources",
     "//content/common:mojo_bindings",
+    "//content/public/child",
+    "//content/public/common",
     "//gin",
     "//jingle:jingle_glue",
     "//media",
@@ -43,7 +46,10 @@
     "//third_party/WebKit/public:blink",
     "//third_party/widevine/cdm:version_h",
     "//ui/accessibility",
+    "//ui/base",
+    "//ui/events:events_base",
     "//ui/events:dom4_keycode_converter",
+    "//ui/gl",
     "//ui/native_theme",
     "//ui/surface",
     "//v8",
@@ -113,7 +119,6 @@
       "media/media_stream_constraints_util.h",
       "media/media_stream_dispatcher.h",
       "media/media_stream_dispatcher_eventhandler.h",
-      "media/media_stream_impl.h",
       "media/media_stream_track.cc",
       "media/media_stream_track.h",
     ]
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
index 0b07f6b..42b36db 100644
--- a/content/test/BUILD.gn
+++ b/content/test/BUILD.gn
@@ -16,6 +16,7 @@
 static_library("test_support") {
   testonly = true
   deps = [
+    "//cc/blink",
     "//content/public/app:both",
     "//content/public/browser",
     "//content/public/common",
@@ -32,6 +33,7 @@
     "//ui/events:test_support",
     "//ui/events:gesture_detection",
     "//ui/gfx:test_support",
+    "//ui/gl",
     "//ui/resources",
     "//url",
   ]
@@ -152,6 +154,9 @@
 
     deps = [
       ":test_support",
+      "//cc",
+      "//cc/blink",
+      "//content/public/common",
       "//skia",
       "//v8",
       "//ui/accessibility:ax_gen",
diff --git a/content/utility/BUILD.gn b/content/utility/BUILD.gn
index 06d06bbb..8fa734d2 100644
--- a/content/utility/BUILD.gn
+++ b/content/utility/BUILD.gn
@@ -16,6 +16,8 @@
   deps = [
     "//base",
     "//content:export",
+    "//content/public/child",
+    "//content/public/common",
     "//courgette:courgette_lib",
     "//mojo/public/interfaces/application",
     "//third_party/WebKit/public:blink_headers",