Commit ffdbe6cd authored by khmel's avatar khmel Committed by Commit bot

arc: Fix Drag&Drop for PlayStore item from App List to Shelf.

PlayStore is special app that actually represents 2 apps in Chrome.
One is OptIn flow as native Platform App, second is Android Play
Store app itself. For user we represent them as one app and do
special mapping for Chrome shelf. This CL adds missing functionality
for correct mapping.

TEST=unit_tests
TEST=Manually on device with all combination, app was pinned or
     not before, App (PlayStore and OptIn) was running or not.
BUG=b/31556052
BUG=648285

Review-Url: https://codereview.chromium.org/2349263002
Cr-Commit-Position: refs/heads/master@{#419502}
parent 1ec533fa
......@@ -30,10 +30,11 @@ ArcPlaystoreShortcutLauncherItemController::Activate(ash::LaunchSource source) {
DCHECK(arc_app_prefs);
DCHECK(auth_service->IsAllowed());
const bool arc_was_enabled = auth_service->IsArcEnabled();
auth_service->EnableArc();
// Deferred launcher.
if (arc_app_prefs->IsRegistered(arc::kPlayStoreAppId)) {
if (arc_app_prefs->IsRegistered(arc::kPlayStoreAppId) && arc_was_enabled) {
// Known apps can be launched directly or deferred.
arc::LaunchApp(controller()->GetProfile(), arc::kPlayStoreAppId, true);
} else {
......
......@@ -909,11 +909,13 @@ ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID(
ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID(
const std::string& app_id,
const std::string& launch_id) {
const std::string shelf_app_id =
ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
for (const auto& id_to_item_controller_pair : id_to_item_controller_map_) {
if (id_to_item_controller_pair.second->type() ==
LauncherItemController::TYPE_APP_PANEL)
continue; // Don't include panels
if (id_to_item_controller_pair.second->app_id() == app_id &&
if (id_to_item_controller_pair.second->app_id() == shelf_app_id &&
id_to_item_controller_pair.second->launch_id() == launch_id) {
return id_to_item_controller_pair.first;
}
......@@ -934,27 +936,33 @@ const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID(
}
void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) {
if (GetPinnableForAppID(app_id, profile_) ==
const std::string shelf_app_id =
ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
if (GetPinnableForAppID(shelf_app_id, profile_) ==
AppListControllerDelegate::PIN_EDITABLE)
DoPinAppWithID(app_id);
DoPinAppWithID(shelf_app_id);
else
NOTREACHED();
}
bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) {
const std::string shelf_app_id =
ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
for (IDToItemControllerMap::const_iterator i =
id_to_item_controller_map_.begin();
i != id_to_item_controller_map_.end(); ++i) {
if (IsPinned(i->first) && i->second->app_id() == app_id)
if (IsPinned(i->first) && i->second->app_id() == shelf_app_id)
return true;
}
return false;
}
void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) {
if (GetPinnableForAppID(app_id, profile_) ==
const std::string shelf_app_id =
ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
if (GetPinnableForAppID(shelf_app_id, profile_) ==
AppListControllerDelegate::PIN_EDITABLE)
DoUnpinAppWithID(app_id, true /* update_prefs */);
DoUnpinAppWithID(shelf_app_id, true /* update_prefs */);
else
NOTREACHED();
}
......
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