Commit fee0a321 authored by Collin Baker's avatar Collin Baker Committed by Chromium LUCI CQ

Handle blank thumbnails in TabStripUIHandler

For security reasons, the thumbnail system must be able to clear the
thumbnail for a tab and notify subscribers. A recent CL implemented
this behavior but resulted in crashes in
TabStripUIHandler::HandleThumbnailUpdate

This CL fixes the crashes due to the null pointer access and handles
blank thumbnails by sending an empty URI to the WebUI.

Fixed: 1167502
Change-Id: I679500882b671b799f3a3c00b55ac20d8e1fb561
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638635
Auto-Submit: Collin Baker <collinbaker@chromium.org>
Commit-Queue: John Lee <johntlee@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845280}
parent 51ad7cb7
...@@ -862,9 +862,11 @@ void TabStripUIHandler::HandleReportTabCreationDuration( ...@@ -862,9 +862,11 @@ void TabStripUIHandler::HandleReportTabCreationDuration(
void TabStripUIHandler::HandleThumbnailUpdate( void TabStripUIHandler::HandleThumbnailUpdate(
content::WebContents* tab, content::WebContents* tab,
ThumbnailTracker::CompressedThumbnailData image) { ThumbnailTracker::CompressedThumbnailData image) {
// Send base-64 encoded image to JS side. // Send base-64 encoded image to JS side. If |image| is blank (i.e.
std::string data_uri = // there is no data), send a blank URI.
webui::MakeDataURIForImage(base::make_span(image->data), "jpeg"); std::string data_uri;
if (image)
data_uri = webui::MakeDataURIForImage(base::make_span(image->data), "jpeg");
const int tab_id = extensions::ExtensionTabUtil::GetTabId(tab); const int tab_id = extensions::ExtensionTabUtil::GetTabId(tab);
FireWebUIListener("tab-thumbnail-updated", base::Value(tab_id), FireWebUIListener("tab-thumbnail-updated", base::Value(tab_id),
......
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