OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/about_ui.h" | 5 #include "chrome/browser/ui/webui/about_ui.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <brotli/decode.h> | |
msw
2016/11/29 19:28:40
Why change the include type? Is this common for th
eustas
2016/11/29 23:19:22
Brotli API headers refer each other in a "system i
msw
2016/11/29 23:35:59
I'm not sure if that's true; really, I just don't
Kunihiko Sakamoto
2016/11/30 06:17:31
It seems #include "third_party/..." style is more
eustas
2016/12/02 11:49:42
Fixed
| |
11 #include <string> | 12 #include <string> |
12 #include <utility> | 13 #include <utility> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/bind.h" | 16 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
17 #include "base/callback.h" | 18 #include "base/callback.h" |
18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
19 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
20 #include "base/format_macros.h" | 21 #include "base/format_macros.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "content/public/browser/web_contents.h" | 58 #include "content/public/browser/web_contents.h" |
58 #include "content/public/common/content_client.h" | 59 #include "content/public/common/content_client.h" |
59 #include "content/public/common/process_type.h" | 60 #include "content/public/common/process_type.h" |
60 #include "google_apis/gaia/google_service_auth_error.h" | 61 #include "google_apis/gaia/google_service_auth_error.h" |
61 #include "net/base/escape.h" | 62 #include "net/base/escape.h" |
62 #include "net/base/filename_util.h" | 63 #include "net/base/filename_util.h" |
63 #include "net/base/load_flags.h" | 64 #include "net/base/load_flags.h" |
64 #include "net/http/http_response_headers.h" | 65 #include "net/http/http_response_headers.h" |
65 #include "net/url_request/url_fetcher.h" | 66 #include "net/url_request/url_fetcher.h" |
66 #include "net/url_request/url_request_status.h" | 67 #include "net/url_request/url_request_status.h" |
67 #include "third_party/brotli/dec/decode.h" | |
68 #include "ui/base/l10n/l10n_util.h" | 68 #include "ui/base/l10n/l10n_util.h" |
69 #include "ui/base/resource/resource_bundle.h" | 69 #include "ui/base/resource/resource_bundle.h" |
70 #include "ui/base/webui/jstemplate_builder.h" | 70 #include "ui/base/webui/jstemplate_builder.h" |
71 #include "ui/base/webui/web_ui_util.h" | 71 #include "ui/base/webui/web_ui_util.h" |
72 #include "url/gurl.h" | 72 #include "url/gurl.h" |
73 | 73 |
74 #if defined(ENABLE_THEMES) | 74 #if defined(ENABLE_THEMES) |
75 #include "chrome/browser/ui/webui/theme_source.h" | 75 #include "chrome/browser/ui/webui/theme_source.h" |
76 #endif | 76 #endif |
77 | 77 |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 if (path == kCreditsJsPath) | 757 if (path == kCreditsJsPath) |
758 idr = IDR_ABOUT_UI_CREDITS_JS; | 758 idr = IDR_ABOUT_UI_CREDITS_JS; |
759 #if defined(OS_CHROMEOS) | 759 #if defined(OS_CHROMEOS) |
760 else if (path == kKeyboardUtilsPath) | 760 else if (path == kKeyboardUtilsPath) |
761 idr = IDR_KEYBOARD_UTILS_JS; | 761 idr = IDR_KEYBOARD_UTILS_JS; |
762 #endif | 762 #endif |
763 | 763 |
764 base::StringPiece raw_response = | 764 base::StringPiece raw_response = |
765 ResourceBundle::GetSharedInstance().GetRawDataResource(idr); | 765 ResourceBundle::GetSharedInstance().GetRawDataResource(idr); |
766 if (idr == IDR_ABOUT_UI_CREDITS_HTML) { | 766 if (idr == IDR_ABOUT_UI_CREDITS_HTML) { |
767 size_t decoded_size; | 767 const uint8_t* in = reinterpret_cast<const uint8_t*>(raw_response.data()); |
768 const uint8_t* encoded_response_buffer = | 768 size_t available_in = raw_response.size(); |
769 reinterpret_cast<const uint8_t*>(raw_response.data()); | 769 BrotliDecoderState* decoder = BrotliDecoderCreateInstance(0, 0, 0); |
msw
2016/11/29 19:28:40
Someone familiar with Brotli should probably revie
eustas
2016/11/29 23:19:22
FWIW, I develop and support Brotli last 20 months.
msw
2016/11/29 23:35:59
That doesn't qualify me to review your changes in
eustas
2016/12/02 11:49:42
It might be difficult to find the right person.
We
| |
770 CHECK(BrotliDecompressedSize(raw_response.size(), encoded_response_buffer, | 770 CHECK(!!decoder); |
771 &decoded_size)); | 771 while (!BrotliDecoderIsFinished(decoder)) { |
772 | 772 size_t available_out = 0; |
773 // Resizing the response and using it as the buffer Brotli decompresses | 773 CHECK(BrotliDecoderDecompressStream(decoder, &available_in, &in, |
774 // into. | 774 &available_out, 0, |
775 response.resize(decoded_size); | 775 0) != BROTLI_DECODER_RESULT_ERROR); |
776 CHECK(BrotliDecompressBuffer(raw_response.size(), encoded_response_buffer, | 776 const uint8_t* out = BrotliDecoderTakeOutput(decoder, &available_out); |
777 &decoded_size, | 777 response.insert(response.end(), out, out + available_out); |
778 reinterpret_cast<uint8_t*>(&response[0])) == | 778 } |
779 BROTLI_RESULT_SUCCESS); | 779 BrotliDecoderDestroyInstance(decoder); |
780 } else { | 780 } else { |
781 response = raw_response.as_string(); | 781 response = raw_response.as_string(); |
782 } | 782 } |
783 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 783 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
784 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { | 784 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { |
785 response = AboutDiscards(path); | 785 response = AboutDiscards(path); |
786 #endif | 786 #endif |
787 } else if (source_name_ == chrome::kChromeUIDNSHost) { | 787 } else if (source_name_ == chrome::kChromeUIDNSHost) { |
788 AboutDnsHandler::Start(profile(), callback); | 788 AboutDnsHandler::Start(profile(), callback); |
789 return; | 789 return; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 Profile* profile = Profile::FromWebUI(web_ui); | 856 Profile* profile = Profile::FromWebUI(web_ui); |
857 | 857 |
858 #if defined(ENABLE_THEMES) | 858 #if defined(ENABLE_THEMES) |
859 // Set up the chrome://theme/ source. | 859 // Set up the chrome://theme/ source. |
860 ThemeSource* theme = new ThemeSource(profile); | 860 ThemeSource* theme = new ThemeSource(profile); |
861 content::URLDataSource::Add(profile, theme); | 861 content::URLDataSource::Add(profile, theme); |
862 #endif | 862 #endif |
863 | 863 |
864 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 864 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
865 } | 865 } |
OLD | NEW |