Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: ios/chrome/browser/ui/webui/about_ui.cc

Issue 2015133003: Decompress credits page on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/DEPS ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/webui/about_ui.cc
diff --git a/ios/chrome/browser/ui/webui/about_ui.cc b/ios/chrome/browser/ui/webui/about_ui.cc
index bda0b8a48a4202fd10d6b220067bf589afbee032..73b5e62795fbbcaf07365fe745b1ef7359d48f45 100644
--- a/ios/chrome/browser/ui/webui/about_ui.cc
+++ b/ios/chrome/browser/ui/webui/about_ui.cc
@@ -20,6 +20,7 @@
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/web/public/url_data_source_ios.h"
#include "net/base/escape.h"
+#include "third_party/brotli/dec/decode.h"
#include "ui/base/device_form_factor.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
@@ -126,8 +127,24 @@ void AboutUIHTMLSource::StartDataRequest(
int idr = IDR_ABOUT_UI_CREDITS_HTML;
if (path == kCreditsJsPath)
idr = IDR_ABOUT_UI_CREDITS_JS;
- response =
- ResourceBundle::GetSharedInstance().GetRawDataResource(idr).as_string();
+ base::StringPiece raw_response =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(idr);
+ if (idr == IDR_ABOUT_UI_CREDITS_HTML) {
+ size_t decoded_size;
+ const uint8_t* encoded_response_buffer =
+ reinterpret_cast<const uint8_t*>(raw_response.data());
+ CHECK(BrotliDecompressedSize(raw_response.size(), encoded_response_buffer,
+ &decoded_size));
+ // Resizing the response and using it as the buffer Brotli decompresses
+ // into.
+ response.resize(decoded_size);
+ CHECK(BrotliDecompressBuffer(raw_response.size(), encoded_response_buffer,
+ &decoded_size,
+ reinterpret_cast<uint8_t*>(&response[0])) ==
+ BROTLI_RESULT_SUCCESS);
+ } else {
+ response = raw_response.as_string();
+ }
} else if (source_name_ == kChromeUIHistogramHost) {
// Note: On other platforms, this is implemented in //content. If there is
// ever a need for embedders other than //ios/chrome to use
« no previous file with comments | « ios/chrome/browser/DEPS ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698