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 @@ ...@@ -20,6 +20,21 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "components/arc/app/arc_playstore_search_request_state.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 { namespace mojo {
template <> template <>
...@@ -144,9 +159,7 @@ void FakeAppInstance::SendTaskDescription( ...@@ -144,9 +159,7 @@ void FakeAppInstance::SendTaskDescription(
const std::string& label, const std::string& label,
const std::string& icon_png_data_as_string) { const std::string& icon_png_data_as_string) {
arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New(); arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New();
icon->is_adaptive_icon = false; FillRawIconPngData(icon_png_data_as_string, icon.get());
icon->icon_png_data = std::vector<uint8_t>(icon_png_data_as_string.begin(),
icon_png_data_as_string.end());
app_host_->OnTaskDescriptionChanged(taskId, label, std::move(icon)); app_host_->OnTaskDescriptionChanged(taskId, label, std::move(icon));
} }
...@@ -171,19 +184,17 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GenerateIconResponse( ...@@ -171,19 +184,17 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GenerateIconResponse(
icon_responses_.erase(previous_response); icon_responses_.erase(previous_response);
arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New(); arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New();
icon->is_adaptive_icon = false;
switch (icon_response_type_) { switch (icon_response_type_) {
case IconResponseType::ICON_RESPONSE_SKIP: case IconResponseType::ICON_RESPONSE_SKIP:
return nullptr; return nullptr;
case IconResponseType::ICON_RESPONSE_SEND_BAD: { case IconResponseType::ICON_RESPONSE_SEND_BAD: {
std::string bad_png_data_as_string = "BAD_ICON_CONTENT"; std::string bad_png_data_as_string = "BAD_ICON_CONTENT";
icon->icon_png_data = std::vector<uint8_t>(bad_png_data_as_string.begin(), FillRawIconPngData(bad_png_data_as_string, icon.get());
bad_png_data_as_string.end());
icon_responses_[dimension] = bad_png_data_as_string; icon_responses_[dimension] = bad_png_data_as_string;
return icon; return icon;
} }
case IconResponseType::ICON_RESPONSE_SEND_EMPTY: { case IconResponseType::ICON_RESPONSE_SEND_EMPTY: {
icon->icon_png_data = std::vector<uint8_t>(); FillRawIconPngData(std::string(), icon.get());
icon_responses_[dimension] = std::string(); icon_responses_[dimension] = std::string();
return icon; return icon;
} }
...@@ -204,8 +215,7 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GenerateIconResponse( ...@@ -204,8 +215,7 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GenerateIconResponse(
<< icon_file_path.MaybeAsASCII(); << icon_file_path.MaybeAsASCII();
CHECK(base::ReadFileToString(icon_file_path, &good_png_data_as_string)); CHECK(base::ReadFileToString(icon_file_path, &good_png_data_as_string));
} }
icon->icon_png_data = std::vector<uint8_t>( FillRawIconPngData(good_png_data_as_string, icon.get());
good_png_data_as_string.begin(), good_png_data_as_string.end());
icon_responses_[dimension] = good_png_data_as_string; icon_responses_[dimension] = good_png_data_as_string;
return icon; return icon;
} }
...@@ -260,9 +270,7 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GetFakeIcon( ...@@ -260,9 +270,7 @@ arc::mojom::RawIconPngDataPtr FakeAppInstance::GetFakeIcon(
CHECK(base::ReadFileToString(icon_file_path, &png_data_as_string)); CHECK(base::ReadFileToString(icon_file_path, &png_data_as_string));
arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New(); arc::mojom::RawIconPngDataPtr icon = arc::mojom::RawIconPngData::New();
icon->is_adaptive_icon = false; FillRawIconPngData(png_data_as_string, icon.get());
icon->icon_png_data = std::vector<uint8_t>(png_data_as_string.begin(),
png_data_as_string.end());
return icon; return icon;
} }
......
...@@ -267,6 +267,9 @@ class FakeAppInstance : public mojom::AppInstance { ...@@ -267,6 +267,9 @@ class FakeAppInstance : public mojom::AppInstance {
private: private:
using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>;
arc::mojom::RawIconPngDataPtr GetFakeIcon(mojom::ScaleFactor scale_factor);
// Mojo endpoints. // Mojo endpoints.
mojom::AppHost* app_host_; mojom::AppHost* app_host_;
// Number of requests to start PAI flows. // Number of requests to start PAI flows.
...@@ -306,8 +309,6 @@ class FakeAppInstance : public mojom::AppInstance { ...@@ -306,8 +309,6 @@ class FakeAppInstance : public mojom::AppInstance {
// routed. // routed.
mojo::Remote<mojom::AppHost> host_remote_; mojo::Remote<mojom::AppHost> host_remote_;
arc::mojom::RawIconPngDataPtr GetFakeIcon(mojom::ScaleFactor scale_factor);
DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); 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