Reland "[serial] Remove all code from Android Blink build"

This reverts commit e4f4664139bfa9511c6b90c14826feb3a73d814a.

Reason for revert: Build failure fixed.

Original change's description:
> Revert "[serial] Remove all code from Android Blink build"
> 
> This reverts commit 5cd5e69c82a5018288f282fb6d918ed0ce6e0f27.
> 
> Reason for revert: Failure on android-rel.
> 
> Original change's description:
> > [serial] Remove all code from Android Blink build
> > 
> > This reverts r629504 and instead removes all of the Serial API code from
> > the Blink build on Android to further reduce binary size.
> > 
> > Bug: 884928
> > Change-Id: I02cd550753d8020b6f8d796d576ca70caf378e39
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497363
> > Reviewed-by: Kentaro Hara <haraken@chromium.org>
> > Reviewed-by: Ken Buchanan <kenrb@chromium.org>
> > Commit-Queue: Reilly Grant <reillyg@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#637439}
> 
> TBR=kenrb@chromium.org,reillyg@chromium.org,haraken@chromium.org
> 
> Change-Id: I2ff8c789992ceabfdaa856ec9c0bd6fae268fca0
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 884928
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1500939
> Reviewed-by: Reilly Grant <reillyg@chromium.org>
> Commit-Queue: Reilly Grant <reillyg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#637453}

TBR=kenrb@chromium.org,reillyg@chromium.org,haraken@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 884928
Change-Id: I6b5d786589c28debac3e2ba8ff4b4f1a174b7bd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526750
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642034}
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index cc016c9..78dea6664 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -120,7 +120,6 @@
 #include "chrome/browser/safe_browsing/ui_manager.h"
 #include "chrome/browser/safe_browsing/url_checker_delegate_impl.h"
 #include "chrome/browser/search/search.h"
-#include "chrome/browser/serial/chrome_serial_delegate.h"
 #include "chrome/browser/sessions/session_tab_helper.h"
 #include "chrome/browser/signin/chrome_signin_proxying_url_loader_factory.h"
 #include "chrome/browser/signin/chrome_signin_url_loader_throttle.h"
@@ -452,6 +451,7 @@
 #include "chrome/browser/payments/payment_request_factory.h"
 #include "chrome/browser/search/instant_service.h"
 #include "chrome/browser/search/instant_service_factory.h"
+#include "chrome/browser/serial/chrome_serial_delegate.h"
 #include "chrome/browser/ui/passwords/google_password_manager_navigation_throttle.h"
 #include "chrome/browser/ui/search/new_tab_page_navigation_throttle.h"
 #include "chrome/common/importer/profile_import.mojom.h"
diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h
index 455fc85..c8e8068 100644
--- a/content/browser/frame_host/render_frame_host_impl.h
+++ b/content/browser/frame_host/render_frame_host_impl.h
@@ -70,7 +70,6 @@
 #include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
 #include "third_party/blink/public/mojom/frame/navigation_initiator.mojom.h"
 #include "third_party/blink/public/mojom/presentation/presentation.mojom.h"
-#include "third_party/blink/public/mojom/serial/serial.mojom.h"
 #include "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom.h"
 #include "third_party/blink/public/mojom/worker/dedicated_worker_host_factory.mojom.h"
 #include "third_party/blink/public/platform/modules/bluetooth/web_bluetooth.mojom.h"
@@ -91,6 +90,8 @@
 
 #if defined(OS_ANDROID)
 #include "services/device/public/mojom/nfc.mojom.h"
+#else
+#include "third_party/blink/public/mojom/serial/serial.mojom.h"
 #endif
 
 class GURL;
diff --git a/third_party/blink/public/mojom/BUILD.gn b/third_party/blink/public/mojom/BUILD.gn
index 906c4ae..991bcfe 100644
--- a/third_party/blink/public/mojom/BUILD.gn
+++ b/third_party/blink/public/mojom/BUILD.gn
@@ -84,7 +84,6 @@
     "renderer_preferences.mojom",
     "reporting/reporting.mojom",
     "script/script_type.mojom",
-    "serial/serial.mojom",
     "service_worker/dispatch_fetch_event_params.mojom",
     "service_worker/navigation_preload_state.mojom",
     "service_worker/service_worker_client.mojom",
@@ -116,6 +115,10 @@
     "worker/worker_main_script_load_params.mojom",
   ]
 
+  if (!is_android) {
+    sources += [ "serial/serial.mojom" ]
+  }
+
   if (is_win) {
     sources += [ "dwrite_font_proxy/dwrite_font_proxy.mojom" ]
   }
diff --git a/third_party/blink/public/platform/web_runtime_features.h b/third_party/blink/public/platform/web_runtime_features.h
index b9630aa..d7d6014 100644
--- a/third_party/blink/public/platform/web_runtime_features.h
+++ b/third_party/blink/public/platform/web_runtime_features.h
@@ -174,7 +174,6 @@
   BLINK_PLATFORM_EXPORT static void EnableScriptedSpeechSynthesis(bool);
   BLINK_PLATFORM_EXPORT static void EnableScrollAnchorSerialization(bool);
   BLINK_PLATFORM_EXPORT static void EnableSecMetadata(bool);
-  BLINK_PLATFORM_EXPORT static void EnableSerial(bool);
   BLINK_PLATFORM_EXPORT static void EnableSharedArrayBuffer(bool);
   BLINK_PLATFORM_EXPORT static void EnableSharedWorker(bool);
   BLINK_PLATFORM_EXPORT static void EnableTextFragmentAnchor(bool);
diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn
index 33f1943..762da04 100644
--- a/third_party/blink/renderer/modules/BUILD.gn
+++ b/third_party/blink/renderer/modules/BUILD.gn
@@ -141,7 +141,6 @@
     "//third_party/blink/renderer/modules/remoteplayback",
     "//third_party/blink/renderer/modules/screen_orientation",
     "//third_party/blink/renderer/modules/sensor",
-    "//third_party/blink/renderer/modules/serial",
     "//third_party/blink/renderer/modules/service_worker",
     "//third_party/blink/renderer/modules/shapedetection",
     "//third_party/blink/renderer/modules/speech",
@@ -168,6 +167,10 @@
     "//third_party/zlib",
   ]
 
+  if (!is_android) {
+    deps += [ "//third_party/blink/renderer/modules/serial" ]
+  }
+
   if (is_win) {
     cflags = [ "/wd4334" ]  # Result of 32-bit shift implicitly converted to 64 bits.
   }
diff --git a/third_party/blink/renderer/modules/modules_idl_files.gni b/third_party/blink/renderer/modules/modules_idl_files.gni
index 982d855..f4373f5 100644
--- a/third_party/blink/renderer/modules/modules_idl_files.gni
+++ b/third_party/blink/renderer/modules/modules_idl_files.gni
@@ -289,8 +289,6 @@
           "sensor/relative_orientation_sensor.idl",
           "sensor/sensor.idl",
           "sensor/sensor_error_event.idl",
-          "serial/serial.idl",
-          "serial/serial_port.idl",
           "service_worker/client.idl",
           "service_worker/clients.idl",
           "service_worker/extendable_event.idl",
@@ -483,6 +481,14 @@
         ],
         "abspath")
 
+if (!is_android) {
+  modules_idl_files += get_path_info([
+                                       "serial/serial.idl",
+                                       "serial/serial_port.idl",
+                                     ],
+                                     "abspath")
+}
+
 if (support_webgl2_compute_context) {
   modules_idl_files +=
       get_path_info([ "webgl/webgl2_compute_rendering_context.idl" ], "abspath")
@@ -689,8 +695,6 @@
           "sensor/sensor_error_event_init.idl",
           "sensor/sensor_options.idl",
           "sensor/spatial_sensor_options.idl",
-          "serial/serial_options.idl",
-          "serial/serial_port_request_options.idl",
           "service_worker/client_query_options.idl",
           "service_worker/extendable_event_init.idl",
           "service_worker/extendable_message_event_init.idl",
@@ -758,6 +762,15 @@
         ],
         "abspath")
 
+if (!is_android) {
+  modules_dictionary_idl_files +=
+      get_path_info([
+                      "serial/serial_options.idl",
+                      "serial/serial_port_request_options.idl",
+                    ],
+                    "abspath")
+}
+
 # 'partial interface' or target (right side of) 'implements'
 modules_dependency_idl_files =
     get_path_info(
@@ -842,8 +855,6 @@
           "quota/worker_navigator_storage_quota.idl",
           "remoteplayback/html_media_element_remote_playback.idl",
           "screen_orientation/screen_screen_orientation.idl",
-          "serial/navigator_serial.idl",
-          "serial/worker_navigator_serial.idl",
           "service_worker/navigator_service_worker.idl",
           "speech/window_speech.idl",
           "speech/window_speech_synthesis.idl",
@@ -864,6 +875,15 @@
         ],
         "abspath")
 
+if (!is_android) {
+  modules_dependency_idl_files +=
+      get_path_info([
+                      "serial/navigator_serial.idl",
+                      "serial/worker_navigator_serial.idl",
+                    ],
+                    "abspath")
+}
+
 if (support_webgl2_compute_context) {
   modules_dependency_idl_files += get_path_info(
           [
diff --git a/third_party/blink/renderer/modules/serial/BUILD.gn b/third_party/blink/renderer/modules/serial/BUILD.gn
index f135be8..cf08466 100644
--- a/third_party/blink/renderer/modules/serial/BUILD.gn
+++ b/third_party/blink/renderer/modules/serial/BUILD.gn
@@ -4,6 +4,10 @@
 
 import("//third_party/blink/renderer/modules/modules.gni")
 
+# The Serial API will not be supported on Android. Assert here to ensure it
+# doesn't sneak back into the build.
+assert(!is_android)
+
 blink_modules_sources("serial") {
   sources = [
     "navigator_serial.cc",
diff --git a/third_party/blink/renderer/platform/exported/web_runtime_features.cc b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
index 6eaafde..1f13abe 100644
--- a/third_party/blink/renderer/platform/exported/web_runtime_features.cc
+++ b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
@@ -530,10 +530,6 @@
   RuntimeEnabledFeatures::SetSecMetadataEnabled(enable);
 }
 
-void WebRuntimeFeatures::EnableSerial(bool enable) {
-  RuntimeEnabledFeatures::SetSerialEnabled(enable);
-}
-
 void WebRuntimeFeatures::EnableTimerThrottlingForBackgroundTabs(bool enable) {
   RuntimeEnabledFeatures::SetTimerThrottlingForBackgroundTabsEnabled(enable);
 }