Commit f5665658 authored by David Black's avatar David Black Committed by Commit Bot

Base64 encodes card html.

This involved:
- Using an API from base to perform base64 encoding.
- Modifying the data prefix to: "data:text/html;base64,".

Bug: b:109951173
Change-Id: I69c366af2bd4912e55f2bfde18b12241cdeb17c3
Reviewed-on: https://chromium-review.googlesource.com/1097542
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566895}
parent 9e766eaa
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/assistant/ui/main_stage/assistant_query_view.h" #include "ash/assistant/ui/main_stage/assistant_query_view.h"
#include "ash/assistant/ui/main_stage/assistant_text_element_view.h" #include "ash/assistant/ui/main_stage/assistant_text_element_view.h"
#include "ash/public/cpp/app_list/answer_card_contents_registry.h" #include "ash/public/cpp/app_list/answer_card_contents_registry.h"
#include "base/base64.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -18,7 +19,7 @@ namespace ash { ...@@ -18,7 +19,7 @@ namespace ash {
namespace { namespace {
constexpr char kDataUriPrefix[] = "data:text/html,"; constexpr char kDataUriPrefix[] = "data:text/html;base64,";
} // namespace } // namespace
...@@ -106,10 +107,14 @@ void UiElementContainerView::OnCardElementAdded( ...@@ -106,10 +107,14 @@ void UiElementContainerView::OnCardElementAdded(
// card resources when it is no longer needed. // card resources when it is no longer needed.
base::UnguessableToken id_token = base::UnguessableToken::Create(); base::UnguessableToken id_token = base::UnguessableToken::Create();
// Encode the card HTML in base64.
std::string encoded_html;
base::Base64Encode(card_element->html(), &encoded_html);
// Configure parameters for the card. // Configure parameters for the card.
ash::mojom::ManagedWebContentsParamsPtr params( ash::mojom::ManagedWebContentsParamsPtr params(
ash::mojom::ManagedWebContentsParams::New()); ash::mojom::ManagedWebContentsParams::New());
params->url = GURL(kDataUriPrefix + card_element->html()); params->url = GURL(kDataUriPrefix + encoded_html);
params->min_size_dip = gfx::Size(kPreferredWidthDip - 2 * kPaddingDip, 1); params->min_size_dip = gfx::Size(kPreferredWidthDip - 2 * kPaddingDip, 1);
params->max_size_dip = params->max_size_dip =
gfx::Size(kPreferredWidthDip - 2 * kPaddingDip, INT_MAX); gfx::Size(kPreferredWidthDip - 2 * kPaddingDip, INT_MAX);
......
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