[go: up one dir, main page]

Add a method to query if an app is installable in the Play Store.

This CL adds a new method on app.mojom that allows Chrome OS to query
ARC for whether a given package name is currently installable.

BUG=969560

(cherry picked from commit 005c16e190882cd9a3e18a36e8f489c4ebae1b38)

Change-Id: Ia525a92944b9b4afb4fd5f6a1ccb150e931a22ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640917
Reviewed-by: Yury Khmel <khmel@chromium.org>
Reviewed-by: Yusuke Sato <yusukes@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#666171}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660293
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#334}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/components/arc/common/app.mojom b/components/arc/common/app.mojom
index a453b9d..3fca7a0 100644
--- a/components/arc/common/app.mojom
+++ b/components/arc/common/app.mojom
@@ -350,7 +350,7 @@
 };
 
 // TODO(lhchavez): Migrate all request/response messages to Mojo.
-// Next method ID: 34
+// Next method ID: 35
 // Deprecated method IDs: 2, 3, 13
 interface AppInstance {
   // DEPRECATED: Please use Init@21 instead.
@@ -488,4 +488,10 @@
   [MinVersion=37] RequestAssistStructure@29() =>
         (ax.mojom.AssistantExtra? assistant_extra,
          ax.mojom.AssistantTree? assistant_tree);
+
+  // Queries whether |package_name| is installable for the current user. This
+  // may return false if the user has already installed |package_name|, or if
+  // it isn't available in the user's store.
+  [MinVersion=43] IsInstallable@34(string package_name) =>
+      (bool is_installable);
 };
diff --git a/components/arc/test/fake_app_instance.cc b/components/arc/test/fake_app_instance.cc
index 84cd13c..15903e9 100644
--- a/components/arc/test/fake_app_instance.cc
+++ b/components/arc/test/fake_app_instance.cc
@@ -485,6 +485,11 @@
   std::move(callback).Run(nullptr, nullptr);
 }
 
+void FakeAppInstance::IsInstallable(const std::string& package_name,
+                                    IsInstallableCallback callback) {
+  std::move(callback).Run(false);
+}
+
 void FakeAppInstance::LaunchIntentDeprecated(
     const std::string& intent_uri,
     const base::Optional<gfx::Rect>& dimension_on_screen) {
diff --git a/components/arc/test/fake_app_instance.h b/components/arc/test/fake_app_instance.h
index dfb720d..47489d6 100644
--- a/components/arc/test/fake_app_instance.h
+++ b/components/arc/test/fake_app_instance.h
@@ -159,6 +159,8 @@
   void StartFastAppReinstallFlow(
       const std::vector<std::string>& package_names) override;
   void RequestAssistStructure(RequestAssistStructureCallback callback) override;
+  void IsInstallable(const std::string& package_name,
+                     IsInstallableCallback callback) override;
 
   // Methods to reply messages.
   void SendRefreshAppList(const std::vector<mojom::AppInfo>& apps);