Commit d702c390 authored by khmel's avatar khmel Committed by Commit Bot

arc: Hide default Play Store icon on shelf for AOSP images.

This prevents appearing default Play Store icon on the shelf for AOSP
images.

Test: Unit test + manually
Bug: b/36133646
Change-Id: I90d05513d98c57a7ec514b66a8b468255434e841
Reviewed-on: https://chromium-review.googlesource.com/580646Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Yury Khmel <khmel@google.com>
Cr-Commit-Position: refs/heads/master@{#488705}
parent 4af5a864
...@@ -632,9 +632,10 @@ std::vector<ash::ShelfID> GetPinnedAppsFromPrefs( ...@@ -632,9 +632,10 @@ std::vector<ash::ShelfID> GetPinnedAppsFromPrefs(
// Return default apps in case profile is not synced yet. // Return default apps in case profile is not synced yet.
sync_preferences::PrefServiceSyncable* const pref_service_syncable = sync_preferences::PrefServiceSyncable* const pref_service_syncable =
PrefServiceSyncableFromProfile(helper->profile()); PrefServiceSyncableFromProfile(helper->profile());
if (!pref_service_syncable->IsSyncing()) if (!pref_service_syncable->IsSyncing()) {
return AppIdsToShelfIDs( return AppIdsToShelfIDs(
GetPinnedAppsFromPrefsLegacy(prefs, helper, true)); GetPinnedAppsFromPrefsLegacy(prefs, helper, true));
}
// We need to import legacy pins model and convert it to sync based // We need to import legacy pins model and convert it to sync based
// model. // model.
......
...@@ -3924,6 +3924,29 @@ INSTANTIATE_TEST_CASE_P(, ...@@ -3924,6 +3924,29 @@ INSTANTIATE_TEST_CASE_P(,
ChromeLauncherControllerArcDefaultAppsTest, ChromeLauncherControllerArcDefaultAppsTest,
::testing::Bool()); ::testing::Bool());
class ChromeLauncherControllerPlayStoreAvailabilityTest
: public ChromeLauncherControllerTest,
public ::testing::WithParamInterface<bool> {
public:
ChromeLauncherControllerPlayStoreAvailabilityTest() = default;
~ChromeLauncherControllerPlayStoreAvailabilityTest() override = default;
protected:
void SetUp() override {
if (GetParam())
arc::SetArcAlwaysStartForTesting(false);
ArcDefaultAppList::UseTestAppsDirectory();
ChromeLauncherControllerTest::SetUp();
}
private:
DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPlayStoreAvailabilityTest);
};
INSTANTIATE_TEST_CASE_P(,
ChromeLauncherControllerPlayStoreAvailabilityTest,
::testing::Bool());
} // namespace } // namespace
TEST_P(ChromeLauncherControllerOrientationTest, TEST_P(ChromeLauncherControllerOrientationTest,
...@@ -4136,6 +4159,24 @@ TEST_P(ChromeLauncherControllerArcDefaultAppsTest, PlayStoreDeferredLaunch) { ...@@ -4136,6 +4159,24 @@ TEST_P(ChromeLauncherControllerArcDefaultAppsTest, PlayStoreDeferredLaunch) {
arc::kPlayStoreAppId)); arc::kPlayStoreAppId));
} }
// Tests that the Play Store is not visible in AOSP image and visible in default
// images.
TEST_P(ChromeLauncherControllerPlayStoreAvailabilityTest, Visible) {
extension_service_->AddExtension(arc_support_host_.get());
arc_test_.SetUp(profile());
InitLauncherController();
StartPrefSyncService(syncer::SyncDataList());
ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
EXPECT_EQ(arc::IsPlayStoreAvailable(),
prefs->IsRegistered(arc::kPlayStoreAppId));
// If the Play Store available, it is pinned by default.
EXPECT_EQ(arc::IsPlayStoreAvailable(),
launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
arc_test_.TearDown();
}
// Checks the case when several app items have the same ordinal position (which // Checks the case when several app items have the same ordinal position (which
// is valid case). // is valid case).
TEST_F(ChromeLauncherControllerTest, CheckPositionConflict) { TEST_F(ChromeLauncherControllerTest, CheckPositionConflict) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "chrome/browser/ui/extensions/extension_enable_flow.h" #include "chrome/browser/ui/extensions/extension_enable_flow.h"
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "components/arc/arc_util.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
...@@ -149,10 +150,11 @@ bool LauncherControllerHelper::IsValidIDForCurrentUser( ...@@ -149,10 +150,11 @@ bool LauncherControllerHelper::IsValidIDForCurrentUser(
const ArcAppListPrefs* arc_prefs = GetArcAppListPrefs(); const ArcAppListPrefs* arc_prefs = GetArcAppListPrefs();
if (arc_prefs && arc_prefs->IsRegistered(id)) if (arc_prefs && arc_prefs->IsRegistered(id))
return true; return true;
if (!GetExtensionByID(profile_, id)) if (!GetExtensionByID(profile_, id))
return false; return false;
if (id == arc::kPlayStoreAppId) { if (id == arc::kPlayStoreAppId) {
if (!arc::IsArcAllowedForProfile(profile())) if (!arc::IsArcAllowedForProfile(profile()) || !arc::IsPlayStoreAvailable())
return false; return false;
const arc::ArcSessionManager* arc_session_manager = const arc::ArcSessionManager* arc_session_manager =
arc::ArcSessionManager::Get(); arc::ArcSessionManager::Get();
......
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