Commit bfbe9939 authored by nancylingwang's avatar nancylingwang Committed by Commit Bot

Modify fake app instance to return the foreground and background data.

ARC app.mojom is modified to return the foreground and background files
separately to generate the ARC app standard icon on the Chromium side,
so modify the fake app instance to return the foreground and background
data to keep consistent with the mojom change, and the ARC side return
value.
DD: go/appservice-adaptive-icon

BUG=1083331

Change-Id: I9147be31ffbea4fa2d647fe90667a09a8781feeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2389742Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804736}
parent dffbe66e
......@@ -20,6 +20,21 @@
#include "base/threading/thread_restrictions.h"
#include "components/arc/app/arc_playstore_search_request_state.h"
namespace {
void FillRawIconPngData(const std::string& icon_png_data_as_string,
arc::mojom::RawIconPngData* icon) {
icon->is_adaptive_icon = true;
icon->icon_png_data = std::vector<uint8_t>(icon_png_data_as_string.begin(),
icon_png_data_as_string.end());
icon->foreground_icon_png_data = std::vector<uint8_t>(
icon_png_data_as_string.begin(), icon_png_data_as_string.end());
icon->background_icon_png_data = std::vector<uint8_t>(
icon_png_data_as_string.begin(), icon_png_data_as_string.end());
}
} // namespace
namespace mojo {
template <>
......@@ -144,9 +159,7 @@ void FakeAppInstance::SendTaskDescription(
const std::string& label,
const std::string& icon_png_data_as_string) {
arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New();
icon->is_adaptive_icon = false;
icon->icon_png_data = std::vector<uint8_t>(icon_png_data_as_string.begin(),
icon_png_data_as_string.end());
FillRawIconPngData(icon_png_data_as_string, icon.get());
app_host_->OnTaskDescriptionChanged(taskId, label, std::move(icon));
}
......@@ -171,19 +184,17 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GenerateIconResponse(
icon_responses_.erase(previous_response);
arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New();
icon->is_adaptive_icon = false;
switch (icon_response_type_) {
case IconResponseType::ICON_RESPONSE_SKIP:
return nullptr;
case IconResponseType::ICON_RESPONSE_SEND_BAD: {
std::string bad_png_data_as_string = "BAD_ICON_CONTENT";
icon->icon_png_data = std::vector<uint8_t>(bad_png_data_as_string.begin(),
bad_png_data_as_string.end());
FillRawIconPngData(bad_png_data_as_string, icon.get());
icon_responses_[dimension] = bad_png_data_as_string;
return icon;
}
case IconResponseType::ICON_RESPONSE_SEND_EMPTY: {
icon->icon_png_data = std::vector<uint8_t>();
FillRawIconPngData(std::string(), icon.get());
icon_responses_[dimension] = std::string();
return icon;
}
......@@ -204,8 +215,7 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GenerateIconResponse(
<< icon_file_path.MaybeAsASCII();
CHECK(base::ReadFileToString(icon_file_path, &good_png_data_as_string));
}
icon->icon_png_data = std::vector<uint8_t>(
good_png_data_as_string.begin(), good_png_data_as_string.end());
FillRawIconPngData(good_png_data_as_string, icon.get());
icon_responses_[dimension] = good_png_data_as_string;
return icon;
}
......@@ -260,9 +270,7 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GetFakeIcon(
CHECK(base::ReadFileToString(icon_file_path, &png_data_as_string));
arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New();
icon->is_adaptive_icon = false;
icon->icon_png_data = std::vector<uint8_t>(png_data_as_string.begin(),
png_data_as_string.end());
FillRawIconPngData(png_data_as_string, icon.get());
return icon;
}
......
......@@ -267,6 +267,9 @@ class FakeAppInstance : public mojom::AppInstance {
private:
using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>;
arc::mojom::RawIconPngDataPtr GetFakeIcon(mojom::ScaleFactor scale_factor);
// Mojo endpoints.
mojom::AppHost* app_host_;
// Number of requests to start PAI flows.
......@@ -306,8 +309,6 @@ class FakeAppInstance : public mojom::AppInstance {
// routed.
mojo::Remote<mojom::AppHost> host_remote_;
arc::mojom::RawIconPngDataPtr GetFakeIcon(mojom::ScaleFactor scale_factor);
DISALLOW_COPY_AND_ASSIGN(FakeAppInstance);
};
......
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