Restrict use of GN target //media/base/android:android

As //media/base/android:android is a source_set, multiple targets referencing
it using DEPS result in multiple copies of the code being used when
is_component_build = true. Adding a visibility restriction to the target,
and changing all users to use //media (which should be the only target
including the code).

BUG=702438
TEST=gn check passes
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2757463004
Cr-Commit-Position: refs/heads/master@{#458207}
diff --git a/android_webview/native/BUILD.gn b/android_webview/native/BUILD.gn
index 474e675b..e28bf52 100644
--- a/android_webview/native/BUILD.gn
+++ b/android_webview/native/BUILD.gn
@@ -19,7 +19,7 @@
     "//components/web_contents_delegate_android:web_contents_delegate_android",
     "//content/public/common",
     "//device/battery:mojo_bindings",
-    "//media/base/android:android",
+    "//media",
     "//net",
     "//skia",
     "//storage/browser",
diff --git a/chromecast/common/media/BUILD.gn b/chromecast/common/media/BUILD.gn
index fdac214..d519c7e 100644
--- a/chromecast/common/media/BUILD.gn
+++ b/chromecast/common/media/BUILD.gn
@@ -27,7 +27,6 @@
     deps += [
       "//chromecast/media",
       "//components/cdm/common",
-      "//media/base/android",
     ]
   }
 
diff --git a/chromecast/media/cdm/BUILD.gn b/chromecast/media/cdm/BUILD.gn
index d6fb2ea..f5a1b28 100644
--- a/chromecast/media/cdm/BUILD.gn
+++ b/chromecast/media/cdm/BUILD.gn
@@ -37,7 +37,5 @@
       "playready_drm_delegate_android.cc",
       "playready_drm_delegate_android.h",
     ]
-
-    deps += [ "//media/base/android" ]
   }
 }
diff --git a/content/gpu/BUILD.gn b/content/gpu/BUILD.gn
index 0ba3548..3b37afa 100644
--- a/content/gpu/BUILD.gn
+++ b/content/gpu/BUILD.gn
@@ -60,6 +60,10 @@
     "//gpu/ipc/service",
     "//ipc",
     "//media/gpu",
+
+    # TODO(jrummell): As //media/gpu/ipc/service is a source_set in a
+    # component build, determine if it should not be included here.
+    # http://crbug.com/702833.
     "//media/gpu/ipc/service",
     "//services/service_manager/public/cpp",
     "//services/service_manager/public/interfaces",
@@ -75,7 +79,7 @@
   ]
 
   if (is_android) {
-    deps += [ "//media/base/android" ]
+    deps += [ "//media" ]
   }
 
   if (mojo_media_host == "gpu") {
diff --git a/content/shell/android/BUILD.gn b/content/shell/android/BUILD.gn
index 7831a5c..e1e5ef9 100644
--- a/content/shell/android/BUILD.gn
+++ b/content/shell/android/BUILD.gn
@@ -23,7 +23,7 @@
     "//components/crash/content/browser",
     "//content/shell:content_shell_lib",
     "//content/shell:pak",
-    "//media/base/android",
+    "//media",
     "//skia",
   ]
   sources = [
diff --git a/media/BUILD.gn b/media/BUILD.gn
index b47595c..3f96b8b 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -389,11 +389,6 @@
       "filters/decrypting_video_decoder.cc",
       "filters/decrypting_video_decoder.h",
     ]
-    deps += [
-      "//media/base/android",
-      "//media/base/android:media_jni_headers",
-    ]
-    allow_circular_includes_from = [ "//media/base/android" ]
   }
 
   if (current_cpu != "arm" && is_chromeos) {
diff --git a/media/base/android/BUILD.gn b/media/base/android/BUILD.gn
index 956460f..c262376 100644
--- a/media/base/android/BUILD.gn
+++ b/media/base/android/BUILD.gn
@@ -10,9 +10,11 @@
 if (is_android) {
   import("//build/config/android/rules.gni")
 
-  # APK targets that depend on this, either directly or indirectly, should also
+  # This is bundled into //media, so all dependencies should be on //media.
+  # APK targets that depend on this indirectly, should also
   # depend on :media_java to get the corresponding Java classes.
   source_set("android") {
+    visibility = [ "//media/base:base" ]
     sources = [
       "android_cdm_factory.cc",
       "android_cdm_factory.h",
@@ -69,6 +71,7 @@
 
   source_set("unit_tests") {
     testonly = true
+    visibility = [ "//media/base:unit_tests" ]
     sources = [
       "media_codec_bridge_impl_unittest.cc",
       "media_codec_loop_unittest.cc",
@@ -81,7 +84,7 @@
     ]
 
     deps = [
-      ":android",
+      "//media",
       "//media/base:test_support",
       "//testing/gmock",
       "//testing/gtest",
diff --git a/media/blink/BUILD.gn b/media/blink/BUILD.gn
index 9c0bc7f..57bafc2 100644
--- a/media/blink/BUILD.gn
+++ b/media/blink/BUILD.gn
@@ -151,7 +151,6 @@
 
   if (is_android) {
     deps += [
-      "//media/base/android",
       "//media/base/android:media_java",
       "//v8:v8_external_startup_data_assets",
     ]
diff --git a/media/gpu/BUILD.gn b/media/gpu/BUILD.gn
index 2bd2fe0..491032a 100644
--- a/media/gpu/BUILD.gn
+++ b/media/gpu/BUILD.gn
@@ -449,7 +449,7 @@
       ":gpu",
       "//base/test:test_support",
       "//gpu:test_support",
-      "//media/base/android",
+      "//media",
       "//testing/gmock",
       "//testing/gtest",
     ]