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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #endif | 84 #endif |
85 | 85 |
86 using base::Time; | 86 using base::Time; |
87 using base::TimeDelta; | 87 using base::TimeDelta; |
88 using content::BrowserThread; | 88 using content::BrowserThread; |
89 using content::WebContents; | 89 using content::WebContents; |
90 | 90 |
91 namespace { | 91 namespace { |
92 | 92 |
93 const char kCreditsJsPath[] = "credits.js"; | 93 const char kCreditsJsPath[] = "credits.js"; |
| 94 const char kKeyboardUtilsPath[] = "keyboard_utils.js"; |
94 const char kMemoryJsPath[] = "memory.js"; | 95 const char kMemoryJsPath[] = "memory.js"; |
95 const char kMemoryCssPath[] = "about_memory.css"; | 96 const char kMemoryCssPath[] = "about_memory.css"; |
96 const char kStatsJsPath[] = "stats.js"; | 97 const char kStatsJsPath[] = "stats.js"; |
97 const char kStringsJsPath[] = "strings.js"; | 98 const char kStringsJsPath[] = "strings.js"; |
98 | 99 |
99 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
100 // chrome://terms falls back to offline page after kOnlineTermsTimeoutSec. | 101 // chrome://terms falls back to offline page after kOnlineTermsTimeoutSec. |
101 const int kOnlineTermsTimeoutSec = 7; | 102 const int kOnlineTermsTimeoutSec = 7; |
102 #endif // defined(OS_CHROMEOS) | 103 #endif // defined(OS_CHROMEOS) |
103 | 104 |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 void AboutUIHTMLSource::StartDataRequest( | 997 void AboutUIHTMLSource::StartDataRequest( |
997 const std::string& path, | 998 const std::string& path, |
998 int render_process_id, | 999 int render_process_id, |
999 int render_frame_id, | 1000 int render_frame_id, |
1000 const content::URLDataSource::GotDataCallback& callback) { | 1001 const content::URLDataSource::GotDataCallback& callback) { |
1001 std::string response; | 1002 std::string response; |
1002 // Add your data source here, in alphabetical order. | 1003 // Add your data source here, in alphabetical order. |
1003 if (source_name_ == chrome::kChromeUIChromeURLsHost) { | 1004 if (source_name_ == chrome::kChromeUIChromeURLsHost) { |
1004 response = ChromeURLs(); | 1005 response = ChromeURLs(); |
1005 } else if (source_name_ == chrome::kChromeUICreditsHost) { | 1006 } else if (source_name_ == chrome::kChromeUICreditsHost) { |
1006 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; | 1007 int idr = IDR_CREDITS_HTML; |
| 1008 if (path == kCreditsJsPath) |
| 1009 idr = IDR_CREDITS_JS; |
| 1010 else if (path == kKeyboardUtilsPath) |
| 1011 idr = IDR_KEYBOARD_UTILS_JS; |
| 1012 |
1007 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1013 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1008 idr).as_string(); | 1014 idr).as_string(); |
1009 #if defined(OS_CHROMEOS) | 1015 #if defined(OS_CHROMEOS) |
1010 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { | 1016 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { |
1011 response = AboutDiscards(path); | 1017 response = AboutDiscards(path); |
1012 #endif | 1018 #endif |
1013 } else if (source_name_ == chrome::kChromeUIDNSHost) { | 1019 } else if (source_name_ == chrome::kChromeUIDNSHost) { |
1014 AboutDnsHandler::Start(profile(), callback); | 1020 AboutDnsHandler::Start(profile(), callback); |
1015 return; | 1021 return; |
1016 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1022 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
1017 } else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) { | 1023 } else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) { |
1018 response = AboutLinuxProxyConfig(); | 1024 response = AboutLinuxProxyConfig(); |
1019 #endif | 1025 #endif |
1020 } else if (source_name_ == chrome::kChromeUIMemoryHost) { | 1026 } else if (source_name_ == chrome::kChromeUIMemoryHost) { |
1021 response = GetAboutMemoryRedirectResponse(profile()); | 1027 response = GetAboutMemoryRedirectResponse(profile()); |
1022 } else if (source_name_ == chrome::kChromeUIMemoryRedirectHost) { | 1028 } else if (source_name_ == chrome::kChromeUIMemoryRedirectHost) { |
1023 FinishMemoryDataRequest(path, callback); | 1029 FinishMemoryDataRequest(path, callback); |
1024 return; | 1030 return; |
1025 #if defined(OS_CHROMEOS) | 1031 #if defined(OS_CHROMEOS) |
1026 } else if (source_name_ == chrome::kChromeUIOSCreditsHost) { | 1032 } else if (source_name_ == chrome::kChromeUIOSCreditsHost) { |
| 1033 int idr = IDR_OS_CREDITS_HTML; |
| 1034 if (path == kKeyboardUtilsPath) |
| 1035 idr = IDR_KEYBOARD_UTILS_JS; |
1027 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1036 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1028 IDR_OS_CREDITS_HTML).as_string(); | 1037 idr).as_string(); |
1029 #endif | 1038 #endif |
1030 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1039 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
1031 } else if (source_name_ == chrome::kChromeUISandboxHost) { | 1040 } else if (source_name_ == chrome::kChromeUISandboxHost) { |
1032 response = AboutSandbox(); | 1041 response = AboutSandbox(); |
1033 #endif | 1042 #endif |
1034 } else if (source_name_ == chrome::kChromeUIStatsHost) { | 1043 } else if (source_name_ == chrome::kChromeUIStatsHost) { |
1035 response = AboutStats(path); | 1044 response = AboutStats(path); |
1036 } else if (source_name_ == chrome::kChromeUITermsHost) { | 1045 } else if (source_name_ == chrome::kChromeUITermsHost) { |
1037 #if defined(OS_CHROMEOS) | 1046 #if defined(OS_CHROMEOS) |
1038 ChromeOSTermsHandler::Start(path, callback); | 1047 ChromeOSTermsHandler::Start(path, callback); |
1039 return; | 1048 return; |
1040 #else | 1049 #else |
1041 response = l10n_util::GetStringUTF8(IDS_TERMS_HTML); | 1050 response = l10n_util::GetStringUTF8(IDS_TERMS_HTML); |
1042 #endif | 1051 #endif |
1043 } | 1052 } |
1044 | 1053 |
1045 FinishDataRequest(response, callback); | 1054 FinishDataRequest(response, callback); |
1046 } | 1055 } |
1047 | 1056 |
1048 void AboutUIHTMLSource::FinishDataRequest( | 1057 void AboutUIHTMLSource::FinishDataRequest( |
1049 const std::string& html, | 1058 const std::string& html, |
1050 const content::URLDataSource::GotDataCallback& callback) { | 1059 const content::URLDataSource::GotDataCallback& callback) { |
1051 std::string html_copy(html); | 1060 std::string html_copy(html); |
1052 callback.Run(base::RefCountedString::TakeString(&html_copy)); | 1061 callback.Run(base::RefCountedString::TakeString(&html_copy)); |
1053 } | 1062 } |
1054 | 1063 |
1055 std::string AboutUIHTMLSource::GetMimeType(const std::string& path) const { | 1064 std::string AboutUIHTMLSource::GetMimeType(const std::string& path) const { |
1056 if (path == kCreditsJsPath || | 1065 if (path == kCreditsJsPath || |
1057 path == kStatsJsPath || | 1066 path == kKeyboardUtilsPath || |
1058 path == kStringsJsPath || | 1067 path == kStatsJsPath || |
| 1068 path == kStringsJsPath || |
1059 path == kMemoryJsPath) { | 1069 path == kMemoryJsPath) { |
1060 return "application/javascript"; | 1070 return "application/javascript"; |
1061 } | 1071 } |
1062 return "text/html"; | 1072 return "text/html"; |
1063 } | 1073 } |
1064 | 1074 |
1065 bool AboutUIHTMLSource::ShouldAddContentSecurityPolicy() const { | 1075 bool AboutUIHTMLSource::ShouldAddContentSecurityPolicy() const { |
1066 #if defined(OS_CHROMEOS) | 1076 #if defined(OS_CHROMEOS) |
1067 if (source_name_ == chrome::kChromeUIOSCreditsHost) | 1077 if (source_name_ == chrome::kChromeUIOSCreditsHost) |
1068 return false; | 1078 return false; |
(...skipping 16 matching lines...) Expand all Loading... |
1085 Profile* profile = Profile::FromWebUI(web_ui); | 1095 Profile* profile = Profile::FromWebUI(web_ui); |
1086 | 1096 |
1087 #if defined(ENABLE_THEMES) | 1097 #if defined(ENABLE_THEMES) |
1088 // Set up the chrome://theme/ source. | 1098 // Set up the chrome://theme/ source. |
1089 ThemeSource* theme = new ThemeSource(profile); | 1099 ThemeSource* theme = new ThemeSource(profile); |
1090 content::URLDataSource::Add(profile, theme); | 1100 content::URLDataSource::Add(profile, theme); |
1091 #endif | 1101 #endif |
1092 | 1102 |
1093 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 1103 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
1094 } | 1104 } |
OLD | NEW |