Commit 1de878d8 authored by Sheng-Hao Tsao's avatar Sheng-Hao Tsao Committed by Commit Bot

Show consolidated camera icon on shelf

This CL fixes 2 bugs:

1. Users might pin the internal app to the shelf. Clicking on it would
launch a real camera app, causing 2 camera icons shown on the shelf.
2. Users might pin the currently running camera app on the shelf. If the
users click on it afterward, it will bypass the internal app deciding
logic and always launch that specific app.

pinned the internal camera app icon, and launching camera app from it
does not show 2 camera icons on shelf.

Bug: b:117909556
Test: Tested on eve that pinning camera app on launcher or on shelf both
Change-Id: I0300456595e6c4c00c1a47f7a3bc7309d1230553
Reviewed-on: https://chromium-review.googlesource.com/c/1303327
Commit-Queue: Sheng-hao Tsao <shenghao@google.com>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603793}
parent 09cd46bb
......@@ -99,8 +99,11 @@ void ArcAppWindow::SetDefaultAppIcon() {
profile_, extension_misc::EXTENSION_ICON_SMALL, this);
}
DCHECK(!image_fetching_);
base::AutoReset<bool> auto_image_fetching(&image_fetching_, true);
app_icon_loader_->FetchImage(app_shelf_id_.ToString());
std::string app_id = app_shelf_id_.ToString();
if (app_icon_loader_->CanLoadImageForApp(app_id)) {
base::AutoReset<bool> auto_image_fetching(&image_fetching_, true);
app_icon_loader_->FetchImage(app_id);
}
}
void ArcAppWindow::SetIcon(const gfx::ImageSkia& icon) {
......
......@@ -6,6 +6,7 @@
#include <string>
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/window_properties.h"
......@@ -35,6 +36,17 @@ namespace {
constexpr size_t kMaxIconPngSize = 64 * 1024; // 64 kb
// Generated as ArcAppListPrefs::GetAppIdByPackageName(
// "com.google.android.GoogleCameraArc").
constexpr char kAndroidCameraAppId[] = "goamfaniemdfcajgcmmflhchgkmbngka";
// Generated as ArcAppListPrefs::GetAppIdByPackageName(
// "com.android.camera2").
constexpr char kAndroidLegacyCameraAppId[] = "obfofkigjfamlldmipdegnjlcpincibc";
// Generated as ArcAppListPrefs::GetAppIdByPackageName(
// "com.android.googlecameramigration").
constexpr char kAndroidCameraMigrationAppId[] =
"ngmkobaiicipbagcngcmilfkhejlnfci";
} // namespace
// The information about the arc application window which has to be kept
......@@ -295,8 +307,17 @@ void ArcAppWindowLauncherController::OnTaskCreated(
DCHECK(!GetAppWindowForTask(task_id));
const std::string arc_app_id =
ArcAppListPrefs::GetAppId(package_name, activity_name);
std::string app_id_consolidated = arc_app_id;
// For camera app, always put the internal app icon onto shelf.
if (arc_app_id.compare(kAndroidCameraAppId) == 0 ||
arc_app_id.compare(kAndroidCameraMigrationAppId) == 0 ||
arc_app_id.compare(kAndroidLegacyCameraAppId) == 0) {
app_id_consolidated = app_list::kInternalAppIdCamera;
}
const arc::ArcAppShelfId arc_app_shelf_id =
arc::ArcAppShelfId::FromIntentAndAppId(intent, arc_app_id);
arc::ArcAppShelfId::FromIntentAndAppId(intent, app_id_consolidated);
task_id_to_app_window_info_[task_id] =
std::make_unique<AppWindowInfo>(arc_app_shelf_id, intent, package_name);
// Don't create shelf icon for non-primary user.
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/window_properties.h"
......@@ -27,6 +28,8 @@ using extensions::AppWindowRegistry;
namespace {
constexpr char kChromeCameraAppId[] = "hfhhnacclhffhdffklopdkcgdhifgngh";
// Get the ShelfID for a given |app_window|.
ash::ShelfID GetShelfId(AppWindow* app_window) {
// Set launch_id default value to an empty string. If showInShelf parameter
......@@ -39,7 +42,12 @@ ash::ShelfID GetShelfId(AppWindow* app_window) {
else
launch_id = base::StringPrintf("%d", app_window->session_id().id());
}
return ash::ShelfID(app_window->extension_id(), launch_id);
// For camera app, always put the internal app icon onto shelf.
std::string app_id = app_window->extension_id();
if (app_id.compare(kChromeCameraAppId) == 0)
app_id = app_list::kInternalAppIdCamera;
return ash::ShelfID(app_id, launch_id);
}
} // namespace
......
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