OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_about_handler.h" | 5 #include "chrome/browser/browser_about_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
15 #include "base/i18n/number_formatting.h" | 16 #include "base/i18n/number_formatting.h" |
16 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
17 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
19 #include "base/metrics/stats_table.h" | 20 #include "base/metrics/stats_table.h" |
20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
21 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
22 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
(...skipping 17 matching lines...) Expand all Loading... |
40 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 41 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
41 #include "chrome/common/about_handler.h" | 42 #include "chrome/common/about_handler.h" |
42 #include "chrome/common/chrome_paths.h" | 43 #include "chrome/common/chrome_paths.h" |
43 #include "chrome/common/chrome_version_info.h" | 44 #include "chrome/common/chrome_version_info.h" |
44 #include "chrome/common/jstemplate_builder.h" | 45 #include "chrome/common/jstemplate_builder.h" |
45 #include "chrome/common/net/gaia/google_service_auth_error.h" | 46 #include "chrome/common/net/gaia/google_service_auth_error.h" |
46 #include "chrome/common/render_messages.h" | 47 #include "chrome/common/render_messages.h" |
47 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
48 #include "content/browser/browser_thread.h" | 49 #include "content/browser/browser_thread.h" |
49 #include "content/browser/gpu/gpu_process_host.h" | 50 #include "content/browser/gpu/gpu_process_host.h" |
| 51 #include "content/browser/plugin_service.h" |
50 #include "content/browser/renderer_host/render_process_host.h" | 52 #include "content/browser/renderer_host/render_process_host.h" |
51 #include "content/browser/renderer_host/render_view_host.h" | 53 #include "content/browser/renderer_host/render_view_host.h" |
52 #include "content/browser/sensors/sensors_provider.h" | 54 #include "content/browser/sensors/sensors_provider.h" |
53 #include "content/common/gpu/gpu_messages.h" | 55 #include "content/common/gpu/gpu_messages.h" |
54 #include "crypto/nss_util.h" | 56 #include "crypto/nss_util.h" |
55 #include "googleurl/src/gurl.h" | 57 #include "googleurl/src/gurl.h" |
56 #include "grit/browser_resources.h" | 58 #include "grit/browser_resources.h" |
57 #include "grit/chromium_strings.h" | 59 #include "grit/chromium_strings.h" |
58 #include "grit/generated_resources.h" | 60 #include "grit/generated_resources.h" |
59 #include "grit/locale_settings.h" | 61 #include "grit/locale_settings.h" |
60 #include "net/base/escape.h" | 62 #include "net/base/escape.h" |
61 #include "net/base/net_util.h" | 63 #include "net/base/net_util.h" |
62 #include "ui/base/l10n/l10n_util.h" | 64 #include "ui/base/l10n/l10n_util.h" |
63 #include "ui/base/resource/resource_bundle.h" | 65 #include "ui/base/resource/resource_bundle.h" |
64 #include "v8/include/v8.h" | 66 #include "v8/include/v8.h" |
65 #include "webkit/glue/user_agent.h" | 67 #include "webkit/glue/user_agent.h" |
66 #include "webkit/glue/webkit_glue.h" | 68 #include "webkit/glue/webkit_glue.h" |
67 #include "webkit/plugins/npapi/plugin_list.h" | |
68 #include "webkit/plugins/webplugininfo.h" | 69 #include "webkit/plugins/webplugininfo.h" |
69 | 70 |
70 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
71 #include "chrome/browser/enumerate_modules_model_win.h" | 72 #include "chrome/browser/enumerate_modules_model_win.h" |
72 #elif defined(OS_CHROMEOS) | 73 #elif defined(OS_CHROMEOS) |
73 #include "chrome/browser/chromeos/cros/cros_library.h" | 74 #include "chrome/browser/chromeos/cros/cros_library.h" |
74 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 75 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
75 #include "chrome/browser/chromeos/cros/network_library.h" | 76 #include "chrome/browser/chromeos/cros/network_library.h" |
76 #include "chrome/browser/chromeos/customization_document.h" | 77 #include "chrome/browser/chromeos/customization_document.h" |
77 #include "chrome/browser/chromeos/login/wizard_controller.h" | 78 #include "chrome/browser/chromeos/login/wizard_controller.h" |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 localized_strings->SetString("platform", | 1161 localized_strings->SetString("platform", |
1161 l10n_util::GetStringUTF16(IDS_PLATFORM_LABEL)); | 1162 l10n_util::GetStringUTF16(IDS_PLATFORM_LABEL)); |
1162 localized_strings->SetString("os_type", version_info.OSType()); | 1163 localized_strings->SetString("os_type", version_info.OSType()); |
1163 localized_strings->SetString("webkit_version", | 1164 localized_strings->SetString("webkit_version", |
1164 webkit_glue::GetWebKitVersion()); | 1165 webkit_glue::GetWebKitVersion()); |
1165 localized_strings->SetString("js_engine", "V8"); | 1166 localized_strings->SetString("js_engine", "V8"); |
1166 localized_strings->SetString("js_version", v8::V8::GetVersion()); | 1167 localized_strings->SetString("js_version", v8::V8::GetVersion()); |
1167 | 1168 |
1168 // Obtain the version of the first enabled Flash plugin. | 1169 // Obtain the version of the first enabled Flash plugin. |
1169 std::vector<webkit::WebPluginInfo> info_array; | 1170 std::vector<webkit::WebPluginInfo> info_array; |
1170 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( | 1171 PluginService::GetInstance()->GetPluginInfoArray( |
1171 GURL(), "application/x-shockwave-flash", false, NULL, &info_array, NULL); | 1172 GURL(), "application/x-shockwave-flash", false, &info_array, NULL); |
1172 string16 flash_version = | 1173 string16 flash_version = |
1173 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); | 1174 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); |
1174 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); | 1175 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); |
1175 for (size_t i = 0; i < info_array.size(); ++i) { | 1176 for (size_t i = 0; i < info_array.size(); ++i) { |
1176 if (plugin_prefs->IsPluginEnabled(info_array[i])) { | 1177 if (plugin_prefs->IsPluginEnabled(info_array[i])) { |
1177 flash_version = info_array[i].version; | 1178 flash_version = info_array[i].version; |
1178 break; | 1179 break; |
1179 } | 1180 } |
1180 } | 1181 } |
1181 localized_strings->SetString("flash_plugin", "Flash"); | 1182 localized_strings->SetString("flash_plugin", "Flash"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 } else { | 1235 } else { |
1235 localized_strings->SetString("profile_path", | 1236 localized_strings->SetString("profile_path", |
1236 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PATH_NOTFOUND)); | 1237 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PATH_NOTFOUND)); |
1237 } | 1238 } |
1238 | 1239 |
1239 std::string data; | 1240 std::string data; |
1240 jstemplate_builder::AppendJsonJS(localized_strings, &data); | 1241 jstemplate_builder::AppendJsonJS(localized_strings, &data); |
1241 return data; | 1242 return data; |
1242 } | 1243 } |
1243 | 1244 |
| 1245 // Used as a callback for PluginService::GetPlugins(). |
| 1246 void HandleAboutVersionStrings(AboutSource* source, |
| 1247 int request_id, |
| 1248 const std::vector<webkit::WebPluginInfo>&) { |
| 1249 #if defined(OS_CHROMEOS) |
| 1250 new ChromeOSAboutVersionHandler(source, request_id); |
| 1251 #else |
| 1252 DictionaryValue localized_strings; |
| 1253 localized_strings.SetString("os_version", ""); |
| 1254 source->FinishDataRequest( |
| 1255 AboutVersionStrings(&localized_strings, source->profile()), |
| 1256 request_id); |
| 1257 #endif |
| 1258 } |
| 1259 |
1244 // AboutMemoryHandler ---------------------------------------------------------- | 1260 // AboutMemoryHandler ---------------------------------------------------------- |
1245 | 1261 |
1246 // Helper for AboutMemory to bind results from a ProcessMetrics object | 1262 // Helper for AboutMemory to bind results from a ProcessMetrics object |
1247 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects | 1263 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects |
1248 // can be used in caller's scope (e.g for appending to a net total). | 1264 // can be used in caller's scope (e.g for appending to a net total). |
1249 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, | 1265 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, |
1250 ProcessMemoryInformation* info) { | 1266 ProcessMemoryInformation* info) { |
1251 DCHECK(data && info); | 1267 DCHECK(data && info); |
1252 | 1268 |
1253 // Bind metrics to dictionary. | 1269 // Bind metrics to dictionary. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 } else if (host == chrome::kChromeUITermsHost) { | 1480 } else if (host == chrome::kChromeUITermsHost) { |
1465 #if defined(OS_CHROMEOS) | 1481 #if defined(OS_CHROMEOS) |
1466 ChromeOSTermsHandler::Start(this, path, request_id); | 1482 ChromeOSTermsHandler::Start(this, path, request_id); |
1467 return; | 1483 return; |
1468 #else | 1484 #else |
1469 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1485 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1470 IDR_TERMS_HTML).as_string(); | 1486 IDR_TERMS_HTML).as_string(); |
1471 #endif | 1487 #endif |
1472 } else if (host == chrome::kChromeUIVersionHost) { | 1488 } else if (host == chrome::kChromeUIVersionHost) { |
1473 if (path == kStringsJsPath) { | 1489 if (path == kStringsJsPath) { |
1474 #if defined(OS_CHROMEOS) | 1490 // The Flash version information is needed on this page, so make sure |
1475 new ChromeOSAboutVersionHandler(this, request_id); | 1491 // the plugins are loaded. |
| 1492 PluginService::GetInstance()->GetPlugins( |
| 1493 base::Bind(&HandleAboutVersionStrings, |
| 1494 make_scoped_refptr(this), request_id)); |
1476 return; | 1495 return; |
1477 #else | |
1478 DictionaryValue localized_strings; | |
1479 localized_strings.SetString("os_version", ""); | |
1480 response = AboutVersionStrings(&localized_strings, profile_); | |
1481 #endif | |
1482 } else { | 1496 } else { |
1483 response = AboutVersionStaticContent(path); | 1497 response = AboutVersionStaticContent(path); |
1484 } | 1498 } |
1485 } | 1499 } |
1486 | 1500 |
1487 FinishDataRequest(response, request_id); | 1501 FinishDataRequest(response, request_id); |
1488 } | 1502 } |
1489 | 1503 |
1490 void AboutSource::FinishDataRequest(const std::string& html, int request_id) { | 1504 void AboutSource::FinishDataRequest(const std::string& html, int request_id) { |
1491 std::string html_copy(html); | 1505 std::string html_copy(html); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 return false; | 1632 return false; |
1619 } | 1633 } |
1620 | 1634 |
1621 std::vector<std::string> ChromePaths() { | 1635 std::vector<std::string> ChromePaths() { |
1622 std::vector<std::string> paths; | 1636 std::vector<std::string> paths; |
1623 paths.reserve(arraysize(kChromePaths)); | 1637 paths.reserve(arraysize(kChromePaths)); |
1624 for (size_t i = 0; i < arraysize(kChromePaths); i++) | 1638 for (size_t i = 0; i < arraysize(kChromePaths); i++) |
1625 paths.push_back(kChromePaths[i]); | 1639 paths.push_back(kChromePaths[i]); |
1626 return paths; | 1640 return paths; |
1627 } | 1641 } |
OLD | NEW |