| 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> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
| 58 #include "content/public/common/content_client.h" | 58 #include "content/public/common/content_client.h" |
| 59 #include "content/public/common/process_type.h" | 59 #include "content/public/common/process_type.h" |
| 60 #include "google_apis/gaia/google_service_auth_error.h" | 60 #include "google_apis/gaia/google_service_auth_error.h" |
| 61 #include "net/base/escape.h" | 61 #include "net/base/escape.h" |
| 62 #include "net/base/filename_util.h" | 62 #include "net/base/filename_util.h" |
| 63 #include "net/base/load_flags.h" | 63 #include "net/base/load_flags.h" |
| 64 #include "net/http/http_response_headers.h" | 64 #include "net/http/http_response_headers.h" |
| 65 #include "net/url_request/url_fetcher.h" | 65 #include "net/url_request/url_fetcher.h" |
| 66 #include "net/url_request/url_request_status.h" | 66 #include "net/url_request/url_request_status.h" |
| 67 #include "third_party/brotli/dec/decode.h" | 67 #include "third_party/brotli/include/brotli/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* next_encoded_byte = |
| 768 const uint8_t* encoded_response_buffer = | |
| 769 reinterpret_cast<const uint8_t*>(raw_response.data()); | 768 reinterpret_cast<const uint8_t*>(raw_response.data()); |
| 770 CHECK(BrotliDecompressedSize(raw_response.size(), encoded_response_buffer, | 769 size_t input_size_remaining = raw_response.size(); |
| 771 &decoded_size)); | 770 BrotliDecoderState* decoder = |
| 772 | 771 BrotliDecoderCreateInstance(nullptr /* no custom allocator */, |
| 773 // Resizing the response and using it as the buffer Brotli decompresses | 772 nullptr /* no custom deallocator */, |
| 774 // into. | 773 nullptr /* no custom memory handle */); |
| 775 response.resize(decoded_size); | 774 CHECK(!!decoder); |
| 776 CHECK(BrotliDecompressBuffer(raw_response.size(), encoded_response_buffer, | 775 while (!BrotliDecoderIsFinished(decoder)) { |
| 777 &decoded_size, | 776 size_t output_size_remianing = 0; |
| 778 reinterpret_cast<uint8_t*>(&response[0])) == | 777 CHECK(BrotliDecoderDecompressStream( |
| 779 BROTLI_RESULT_SUCCESS); | 778 decoder, &input_size_remaining, &next_encoded_byte, |
| 779 &output_size_remianing, nullptr, |
| 780 nullptr) != BROTLI_DECODER_RESULT_ERROR); |
| 781 const uint8_t* out = |
| 782 BrotliDecoderTakeOutput(decoder, &output_size_remianing); |
| 783 response.insert(response.end(), out, out + output_size_remianing); |
| 784 } |
| 785 BrotliDecoderDestroyInstance(decoder); |
| 780 } else { | 786 } else { |
| 781 response = raw_response.as_string(); | 787 response = raw_response.as_string(); |
| 782 } | 788 } |
| 783 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 789 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
| 784 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { | 790 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { |
| 785 response = AboutDiscards(path); | 791 response = AboutDiscards(path); |
| 786 #endif | 792 #endif |
| 787 } else if (source_name_ == chrome::kChromeUIDNSHost) { | 793 } else if (source_name_ == chrome::kChromeUIDNSHost) { |
| 788 AboutDnsHandler::Start(profile(), callback); | 794 AboutDnsHandler::Start(profile(), callback); |
| 789 return; | 795 return; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 Profile* profile = Profile::FromWebUI(web_ui); | 862 Profile* profile = Profile::FromWebUI(web_ui); |
| 857 | 863 |
| 858 #if defined(ENABLE_THEMES) | 864 #if defined(ENABLE_THEMES) |
| 859 // Set up the chrome://theme/ source. | 865 // Set up the chrome://theme/ source. |
| 860 ThemeSource* theme = new ThemeSource(profile); | 866 ThemeSource* theme = new ThemeSource(profile); |
| 861 content::URLDataSource::Add(profile, theme); | 867 content::URLDataSource::Add(profile, theme); |
| 862 #endif | 868 #endif |
| 863 | 869 |
| 864 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 870 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
| 865 } | 871 } |
| OLD | NEW |