// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_WEBUI_SANITIZED_IMAGE_SOURCE_H_ #define CHROME_BROWSER_UI_WEBUI_SANITIZED_IMAGE_SOURCE_H_ #include <memory> #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "components/signin/public/identity_manager/access_token_info.h" #include "content/public/browser/url_data_source.h" #include "services/data_decoder/public/cpp/data_decoder.h" #include "services/data_decoder/public/cpp/decode_image.h" #include "services/data_decoder/public/mojom/image_decoder.mojom.h" #include "url/gurl.h" class Profile; class SkBitmap; namespace network { class SharedURLLoaderFactory; class SimpleURLLoader; } // namespace network namespace signin { class IdentityManager; } // namespace signin // The sanitized image source provides a convenient mean to embed images into // WebUIs. For security reasons WebUIs are not allowed to download and decode // external images in their renderer process. The sanitized image source allows // external images in WebUIs by downloading the image in the browser process, // decoding the image in an isolated utility process, re-encoding the image and // sending the now sanitized image back to the requesting WebUI. You can reach // the image source in the following ways: // // chrome://image?<external image URL> // chrome://image?url=<external image URL> // // If `static-encode` attribute is set, the image will be re-encoded as a static // PNG, or a static WebP image depending on if `encode-type` attribute is set to // `webp`. You can use these attributes in the following ways: // // chrome://image?url=<external image URL>&staticEncode=true // chrome://image?url=<external image URL>&encodeType=webp // chrome://image?url=<external image URL>&staticEncode=true&encodeType=webp // // If the image source points to Google Photos storage, meaning it needs an auth // token, you can use the `is-google-photos` attribute in the following way: // // chrome://image?url=<external image URL>&isGooglePhotos=true // // [CrOS only]: If the source is an animated image, it will be re-encoded as an // animated WebP image; otherwise it will be re-encoded as a static image as // though `static-encode` attribute had been set. class SanitizedImageSource : public content::URLDataSource { … }; #endif // CHROME_BROWSER_UI_WEBUI_SANITIZED_IMAGE_SOURCE_H_