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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "content/public/common/process_type.h" | 56 #include "content/public/common/process_type.h" |
57 #include "google_apis/gaia/google_service_auth_error.h" | 57 #include "google_apis/gaia/google_service_auth_error.h" |
58 #include "grit/browser_resources.h" | 58 #include "grit/browser_resources.h" |
59 #include "grit/components_resources.h" | 59 #include "grit/components_resources.h" |
60 #include "net/base/escape.h" | 60 #include "net/base/escape.h" |
61 #include "net/base/filename_util.h" | 61 #include "net/base/filename_util.h" |
62 #include "net/base/load_flags.h" | 62 #include "net/base/load_flags.h" |
63 #include "net/http/http_response_headers.h" | 63 #include "net/http/http_response_headers.h" |
64 #include "net/url_request/url_fetcher.h" | 64 #include "net/url_request/url_fetcher.h" |
65 #include "net/url_request/url_request_status.h" | 65 #include "net/url_request/url_request_status.h" |
| 66 #include "third_party/brotli/dec/decode.h" |
66 #include "ui/base/l10n/l10n_util.h" | 67 #include "ui/base/l10n/l10n_util.h" |
67 #include "ui/base/resource/resource_bundle.h" | 68 #include "ui/base/resource/resource_bundle.h" |
68 #include "ui/base/webui/jstemplate_builder.h" | 69 #include "ui/base/webui/jstemplate_builder.h" |
69 #include "ui/base/webui/web_ui_util.h" | 70 #include "ui/base/webui/web_ui_util.h" |
70 #include "url/gurl.h" | 71 #include "url/gurl.h" |
71 | 72 |
72 #if defined(ENABLE_THEMES) | 73 #if defined(ENABLE_THEMES) |
73 #include "chrome/browser/ui/webui/theme_source.h" | 74 #include "chrome/browser/ui/webui/theme_source.h" |
74 #endif | 75 #endif |
75 | 76 |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 response = ChromeURLs(); | 754 response = ChromeURLs(); |
754 } else if (source_name_ == chrome::kChromeUICreditsHost) { | 755 } else if (source_name_ == chrome::kChromeUICreditsHost) { |
755 int idr = IDR_ABOUT_UI_CREDITS_HTML; | 756 int idr = IDR_ABOUT_UI_CREDITS_HTML; |
756 if (path == kCreditsJsPath) | 757 if (path == kCreditsJsPath) |
757 idr = IDR_ABOUT_UI_CREDITS_JS; | 758 idr = IDR_ABOUT_UI_CREDITS_JS; |
758 #if defined(OS_CHROMEOS) | 759 #if defined(OS_CHROMEOS) |
759 else if (path == kKeyboardUtilsPath) | 760 else if (path == kKeyboardUtilsPath) |
760 idr = IDR_KEYBOARD_UTILS_JS; | 761 idr = IDR_KEYBOARD_UTILS_JS; |
761 #endif | 762 #endif |
762 | 763 |
763 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 764 base::StringPiece raw_response = |
764 idr).as_string(); | 765 ResourceBundle::GetSharedInstance().GetRawDataResource(idr); |
| 766 if (idr == IDR_ABOUT_UI_CREDITS_HTML) { |
| 767 size_t decoded_size; |
| 768 const uint8_t* encoded_response_buffer = |
| 769 reinterpret_cast<const uint8_t*>(raw_response.data()); |
| 770 CHECK(BrotliDecompressedSize(raw_response.size(), encoded_response_buffer, |
| 771 &decoded_size)); |
| 772 |
| 773 // Resizing the response and using it as the buffer Brotli decompresses |
| 774 // into. |
| 775 response.resize(decoded_size); |
| 776 CHECK(BrotliDecompressBuffer(raw_response.size(), encoded_response_buffer, |
| 777 &decoded_size, |
| 778 reinterpret_cast<uint8_t*>(&response[0])) == |
| 779 BROTLI_RESULT_SUCCESS); |
| 780 } else { |
| 781 response = raw_response.as_string(); |
| 782 } |
765 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | 783 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
766 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { | 784 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { |
767 response = AboutDiscards(path); | 785 response = AboutDiscards(path); |
768 #endif | 786 #endif |
769 } else if (source_name_ == chrome::kChromeUIDNSHost) { | 787 } else if (source_name_ == chrome::kChromeUIDNSHost) { |
770 AboutDnsHandler::Start(profile(), callback); | 788 AboutDnsHandler::Start(profile(), callback); |
771 return; | 789 return; |
772 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 790 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
773 } else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) { | 791 } else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) { |
774 response = AboutLinuxProxyConfig(); | 792 response = AboutLinuxProxyConfig(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 Profile* profile = Profile::FromWebUI(web_ui); | 856 Profile* profile = Profile::FromWebUI(web_ui); |
839 | 857 |
840 #if defined(ENABLE_THEMES) | 858 #if defined(ENABLE_THEMES) |
841 // Set up the chrome://theme/ source. | 859 // Set up the chrome://theme/ source. |
842 ThemeSource* theme = new ThemeSource(profile); | 860 ThemeSource* theme = new ThemeSource(profile); |
843 content::URLDataSource::Add(profile, theme); | 861 content::URLDataSource::Add(profile, theme); |
844 #endif | 862 #endif |
845 | 863 |
846 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 864 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
847 } | 865 } |
OLD | NEW |