Sync gRPC APIs with native app defs.

PiperOrigin-RevId: 688720047
Change-Id: I4e24b3e0b7f4b867699b3b107df3e46b79b05511
Reviewed-on: https://chromium-review.googlesource.com/c/cast_core/public/+/5933643
Tested-by: Shawn Quereshi <shawnq@google.com>
Reviewed-by: Shawn Quereshi <shawnq@google.com>
diff --git a/build/chromium/cast_core_grpc_generator.cc b/build/chromium/cast_core_grpc_generator.cc
index 43f8527..7be9c0b 100644
--- a/build/chromium/cast_core_grpc_generator.cc
+++ b/build/chromium/cast_core_grpc_generator.cc
@@ -2,10 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <algorithm>
+#include <cctype>
 #include <fstream>
-#include <ostream>
+#include <iostream>
+#include <memory>
+#include <set>
 #include <sstream>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "third_party/protobuf/src/google/protobuf/compiler/importer.h"
diff --git a/proto/bindings/BUILD.gn b/proto/bindings/BUILD.gn
index 2fb9394..1b176e6 100644
--- a/proto/bindings/BUILD.gn
+++ b/proto/bindings/BUILD.gn
@@ -24,13 +24,17 @@
 }
 
 cast_core_proto_library("cast_channel_proto") {
-    sources = ["cast_channel.proto"]
+    sources = [
+        "cast_channel.proto",
+    ]
     generate_javascript = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_proto_library("media_capabilities_proto") {
-    sources = ["media_capabilities.proto"]
+    sources = [
+        "media_capabilities.proto",
+    ]
     generate_javascript = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
diff --git a/proto/bindings/api_bindings.proto b/proto/bindings/api_bindings.proto
index 6e889c8..0816f84 100644
--- a/proto/bindings/api_bindings.proto
+++ b/proto/bindings/api_bindings.proto
@@ -23,6 +23,8 @@
 message ApiBinding {
   // Script to execute before the load of a web document.
   string before_load_script = 1;
+  // Name of script
+  string script_name = 2;
 }
 
 message GetAllRequest {}
diff --git a/proto/common/BUILD.gn b/proto/common/BUILD.gn
index 5549264..d7a2784 100644
--- a/proto/common/BUILD.gn
+++ b/proto/common/BUILD.gn
@@ -41,7 +41,9 @@
     sources = [
         "runtime_metadata.proto",
     ]
-    deps = [":duration_proto"]
+    deps = [
+        ":duration_proto",
+    ]
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
diff --git a/proto/common/application_config.proto b/proto/common/application_config.proto
index ff96a4c..c1263fa 100644
--- a/proto/common/application_config.proto
+++ b/proto/common/application_config.proto
@@ -76,10 +76,25 @@
   }
 }
 
+// A cast application that supports Cast-to-Native (non Android).
+message NativePackage {
+  // An identifier for what platform the package refers to. This must match an
+  // identifier provided by the OEM and reported by cast to DCS.
+  string platform = 1;
+  // opaque to cast OEM version string.
+  string min_app_version = 2;
+  // Opaque launch intent with schema that is owned and handled by the
+  // OEM's platform, could be a direct associated package name, or contain a
+  // json blob with things like package name, launch args, etc.
+  string package_launch_info = 3;
+}
+
 // Config for applications running in native runtime.
 message NativeApplicationConfig {
   // Cast application URL (https).
   // NOTE: this field is added ONLY FOR TESTING purposes. Proper integration
   // with native runtimes is still TBD.
-  string url = 1;
+  string url = 1 [deprecated = true];
+  // A set of native packages for this application.
+  repeated NativePackage native_applications = 2;
 }
diff --git a/proto/common/runtime_metadata.proto b/proto/common/runtime_metadata.proto
index 5c25f27..0b073e5 100644
--- a/proto/common/runtime_metadata.proto
+++ b/proto/common/runtime_metadata.proto
@@ -28,6 +28,8 @@
   RuntimeType.Type type = 2;
   // Various Runtime capabilities.
   RuntimeCapabilities runtime_capabilities = 3;
+  // cast to native capabilities, only enabled if type == NATIVE
+  CastNativeCapabilities cast_native_capabilities = 4;
 }
 
 message RuntimeType {
@@ -43,13 +45,22 @@
     CAST_WEB = 1;
     // Cast Lite runtime for audio.
     CAST_LITE = 2;
-    // Runtimes native to specific platform (Netflix, YouTube applications etc)
+    // Runtimes native to specific platform (Netflix, YouTube applications etc),
+    // or cast functional runtimes (follower, mirroring, etc)
     NATIVE = 3;
     // Cast Web runtime on Cobalt.
     CAST_COBALT = 4;
+    // Runtime that can only be launched and not stopped/prelaunched.
+    // This runtime does not expose a gRPC endpoint.
+    LAUNCH_ONLY = 5;
   }
 }
 
+message CastNativeCapabilities {
+  // The platforms the OEM supports for this runtime.
+  repeated string supported_platforms = 1;
+}
+
 message MediaCapabilities {
   // Flags if runtime has video support.
   bool video_supported = 2;
diff --git a/proto/core/BUILD.gn b/proto/core/BUILD.gn
index ca7e1f6..724d1c9 100644
--- a/proto/core/BUILD.gn
+++ b/proto/core/BUILD.gn
@@ -14,11 +14,13 @@
 
 import("//third_party/cast_core/public/src/proto/proto.gni")
 cast_core_grpc_library("cast_core_service_proto") {
-    sources = ["cast_core_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "cast_core_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/common:runtime_metadata_proto",
         "//third_party/cast_core/public/src/proto/common:service_info_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
diff --git a/proto/platform/BUILD.gn b/proto/platform/BUILD.gn
index 81f4325..3c17dc7 100644
--- a/proto/platform/BUILD.gn
+++ b/proto/platform/BUILD.gn
@@ -17,10 +17,10 @@
     sources = [
         "platform_service.proto",
     ]
-    generate_castcore_stubs = true
     deps = [
         "//third_party/cast_core/public/src/proto/common:duration_proto",
         "//third_party/cast_core/public/src/proto/common:service_info_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
diff --git a/proto/platform/platform_service.proto b/proto/platform/platform_service.proto
index 9c89c8a..3035ca7 100644
--- a/proto/platform/platform_service.proto
+++ b/proto/platform/platform_service.proto
@@ -50,6 +50,8 @@
   cast.common.ServiceInfo runtime_service_info = 2;
   // Flag to indicate that the request is for prelaunch.
   bool prelaunch = 3;
+  // Home directory which must be used by CAST_WEB runtimes.
+  string runtime_home = 4;
 }
 
 message StartRuntimeResponse {}
diff --git a/proto/runtime/BUILD.gn b/proto/runtime/BUILD.gn
index 93efbb7..cb2381a 100644
--- a/proto/runtime/BUILD.gn
+++ b/proto/runtime/BUILD.gn
@@ -17,7 +17,6 @@
     sources = [
         "runtime_service.proto",
     ]
-    generate_castcore_stubs = true
     deps = [
         "//third_party/cast_core/public/src/proto/common:application_config_proto",
         "//third_party/cast_core/public/src/proto/common:application_state_proto",
@@ -25,6 +24,7 @@
         "//third_party/cast_core/public/src/proto/common:service_info_proto",
         "//third_party/cast_core/public/src/proto/v2:url_rewrite_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
@@ -32,9 +32,9 @@
     sources = [
         "cast_audio_channel_service.proto",
     ]
-    generate_castcore_stubs = true
     deps = [
         "//third_party/cast_core/public/src/proto/common:duration_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
diff --git a/proto/v2/BUILD.gn b/proto/v2/BUILD.gn
index 15f5cc2..d3b6102 100644
--- a/proto/v2/BUILD.gn
+++ b/proto/v2/BUILD.gn
@@ -14,64 +14,78 @@
 
 import("//third_party/cast_core/public/src/proto/proto.gni")
 cast_core_grpc_library("core_application_service_proto") {
-    sources = ["core_application_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "core_application_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/common:application_state_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_grpc_library("core_message_port_application_service_proto") {
-    sources = ["core_message_port_application_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "core_message_port_application_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/bindings:api_bindings_proto",
         "//third_party/cast_core/public/src/proto/web:message_channel_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_grpc_library("core_v2_application_service_proto") {
-    sources = ["core_v2_application_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "core_v2_application_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/bindings:cast_channel_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_grpc_library("runtime_application_service_proto") {
-    sources = ["runtime_application_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "runtime_application_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/bindings:cast_channel_proto",
         "//third_party/cast_core/public/src/proto/common:application_state_proto",
         "//third_party/cast_core/public/src/proto/v2:url_rewrite_proto",
         "//third_party/cast_core/public/src/proto/web:message_channel_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_grpc_library("runtime_message_port_application_service_proto") {
-    sources = ["runtime_message_port_application_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "runtime_message_port_application_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/web:message_channel_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_grpc_library("runtime_v2_application_service_proto") {
-    sources = ["runtime_v2_application_service.proto"]
-    generate_castcore_stubs = true
+    sources = [
+        "runtime_v2_application_service.proto",
+    ]
     deps = [
         "//third_party/cast_core/public/src/proto/bindings:cast_channel_proto",
     ]
+    generate_castcore_stubs = true
     proto_in_dir = "//third_party/cast_core/public/src"
 }
 
 cast_core_proto_library("url_rewrite_proto") {
-    sources = ["url_rewrite.proto"]
+    sources = [
+        "url_rewrite.proto",
+    ]
     proto_in_dir = "//third_party/cast_core/public/src"
 }
diff --git a/proto/v2/core_application_service.proto b/proto/v2/core_application_service.proto
index 8185e3c..ff05753 100644
--- a/proto/v2/core_application_service.proto
+++ b/proto/v2/core_application_service.proto
@@ -24,10 +24,6 @@
 // Runtime to report status and request additional application information. This
 // service is scoped per application.
 service CoreApplicationService {
-  // GetWebUIResource request
-  rpc GetWebUIResource(GetWebUIResourceRequest)
-      returns (GetWebUIResourceResponse);
-
   // Notifies that application has been started.
   rpc ApplicationStarted(ApplicationStartedRequest)
       returns (ApplicationStartedResponse);
@@ -45,16 +41,6 @@
       returns (VisibilityChangedResponse);
 }
 
-message GetWebUIResourceRequest {
-  // Resource identifier. It can either be name of the resource or a url.
-  string resource_id = 1;
-}
-
-message GetWebUIResourceResponse {
-  // Path to the resource file on device.
-  string resource_path = 1;
-}
-
 message ApplicationStartedRequest {
   // The Cast session ID whose application status changed.
   string cast_session_id = 1;