Commit e0aa0ed1 authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

[IntentHandling] Enable play store when launching default arc app.

Currently if we try to launch default arc app (e.g. play store) from
intent picker when play store disabled, nothing will happen. This CL
adapts the functionatliy to enable play store in this scenario.

BUG = 1096903, 853604

Change-Id: Ib1efaba445d0dc957b2c425c61ffee164f838dee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351350Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798546}
parent 9e7692c8
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "chrome/browser/apps/app_service/file_utils.h" #include "chrome/browser/apps/app_service/file_utils.h"
#include "chrome/browser/apps/app_service/menu_util.h" #include "chrome/browser/apps/app_service/menu_util.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon.h" #include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/arc/app_permissions/arc_app_permissions_bridge.h" #include "components/arc/app_permissions/arc_app_permissions_bridge.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
#include "components/arc/arc_util.h"
#include "components/arc/intent_helper/intent_constants.h" #include "components/arc/intent_helper/intent_constants.h"
#include "components/arc/mojom/app_permissions.mojom.h" #include "components/arc/mojom/app_permissions.mojom.h"
#include "components/arc/mojom/file_system.mojom.h" #include "components/arc/mojom/file_system.mojom.h"
...@@ -750,6 +752,7 @@ void ArcApps::LaunchAppWithIntent(const std::string& app_id, ...@@ -750,6 +752,7 @@ void ArcApps::LaunchAppWithIntent(const std::string& app_id,
return; return;
} }
if (app_info->ready) {
arc::mojom::ActivityNamePtr activity = arc::mojom::ActivityName::New(); arc::mojom::ActivityNamePtr activity = arc::mojom::ActivityName::New();
activity->package_name = app_info->package_name; activity->package_name = app_info->package_name;
activity->activity_name = app_info->activity; activity->activity_name = app_info->activity;
...@@ -790,6 +793,47 @@ void ArcApps::LaunchAppWithIntent(const std::string& app_id, ...@@ -790,6 +793,47 @@ void ArcApps::LaunchAppWithIntent(const std::string& app_id,
instance->HandleIntent(std::move(arc_intent), std::move(activity)); instance->HandleIntent(std::move(arc_intent), std::move(activity));
prefs->SetLastLaunchTime(app_id); prefs->SetLastLaunchTime(app_id);
return;
}
if (arc::IsArcPlayStoreEnabledForProfile(profile_)) {
// Handle the case when default app tries to re-activate OptIn flow.
if (arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) &&
!arc::ArcSessionManager::Get()->enable_requested() &&
prefs->IsDefault(app_id)) {
arc::SetArcPlayStoreEnabledForProfile(profile_, true);
// PlayStore item has special handling for shelf controllers. In order
// to avoid unwanted initial animation for PlayStore item do not create
// deferred launch request when PlayStore item enables Google Play
// Store.
if (app_id == arc::kPlayStoreAppId) {
prefs->SetLastLaunchTime(app_id);
return;
}
}
} else {
if (prefs->IsDefault(app_id)) {
// The setting can fail if the preference is managed. However, the
// caller is responsible to not call this function in such case. DCHECK
// is here to prevent possible mistake.
if (!arc::SetArcPlayStoreEnabledForProfile(profile_, true)) {
return;
}
DCHECK(arc::IsArcPlayStoreEnabledForProfile(profile_));
// PlayStore item has special handling for shelf controllers. In order
// to avoid unwanted initial animation for PlayStore item do not create
// deferred launch request when PlayStore item enables Google Play
// Store.
if (app_id == arc::kPlayStoreAppId) {
prefs->SetLastLaunchTime(app_id);
return;
}
} else {
// Only reachable when ARC always starts.
DCHECK(arc::ShouldArcAlwaysStart());
}
}
} }
void ArcApps::SetPermission(const std::string& app_id, void ArcApps::SetPermission(const std::string& app_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment