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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "content/public/common/process_type.h" | 58 #include "content/public/common/process_type.h" |
59 #include "crypto/nss_util.h" | 59 #include "crypto/nss_util.h" |
60 #include "googleurl/src/gurl.h" | 60 #include "googleurl/src/gurl.h" |
61 #include "grit/browser_resources.h" | 61 #include "grit/browser_resources.h" |
62 #include "grit/chromium_strings.h" | 62 #include "grit/chromium_strings.h" |
63 #include "grit/generated_resources.h" | 63 #include "grit/generated_resources.h" |
64 #include "grit/locale_settings.h" | 64 #include "grit/locale_settings.h" |
65 #include "net/base/escape.h" | 65 #include "net/base/escape.h" |
66 #include "net/base/net_util.h" | 66 #include "net/base/net_util.h" |
67 #include "ui/base/l10n/l10n_util.h" | 67 #include "ui/base/l10n/l10n_util.h" |
| 68 #include "ui/base/layout.h" |
68 #include "ui/base/resource/resource_bundle.h" | 69 #include "ui/base/resource/resource_bundle.h" |
69 #include "v8/include/v8.h" | 70 #include "v8/include/v8.h" |
70 #include "webkit/glue/user_agent.h" | 71 #include "webkit/glue/user_agent.h" |
71 #include "webkit/glue/webkit_glue.h" | 72 #include "webkit/glue/webkit_glue.h" |
72 #include "webkit/plugins/webplugininfo.h" | 73 #include "webkit/plugins/webplugininfo.h" |
73 | 74 |
74 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 75 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 76 #include "content/public/browser/zygote_host_linux.h" |
75 #include "content/public/common/sandbox_linux.h" | 77 #include "content/public/common/sandbox_linux.h" |
76 #include "content/public/browser/zygote_host_linux.h" | |
77 #endif | 78 #endif |
78 | 79 |
79 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
80 #include "chrome/browser/enumerate_modules_model_win.h" | 81 #include "chrome/browser/enumerate_modules_model_win.h" |
81 #endif | 82 #endif |
82 | 83 |
83 #if defined(OS_CHROMEOS) | 84 #if defined(OS_CHROMEOS) |
84 #include "chrome/browser/chromeos/cros/cros_library.h" | 85 #include "chrome/browser/chromeos/cros/cros_library.h" |
85 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 86 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
86 #include "chrome/browser/chromeos/cros/network_library.h" | 87 #include "chrome/browser/chromeos/cros/network_library.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 BrowserThread::UI, FROM_HERE, | 240 BrowserThread::UI, FROM_HERE, |
240 base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this)); | 241 base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this)); |
241 } | 242 } |
242 | 243 |
243 void ResponseOnUIThread() { | 244 void ResponseOnUIThread() { |
244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
245 // If we fail to load Chrome OS EULA from disk, load it from resources. | 246 // If we fail to load Chrome OS EULA from disk, load it from resources. |
246 // Do nothing if OEM EULA load failed. | 247 // Do nothing if OEM EULA load failed. |
247 if (contents_.empty() && path_ != chrome::kOemEulaURLPath) { | 248 if (contents_.empty() && path_ != chrome::kOemEulaURLPath) { |
248 contents_ = ResourceBundle::GetSharedInstance().GetRawDataResource( | 249 contents_ = ResourceBundle::GetSharedInstance().GetRawDataResource( |
249 IDR_TERMS_HTML).as_string(); | 250 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string(); |
250 } | 251 } |
251 source_->FinishDataRequest(contents_, request_id_); | 252 source_->FinishDataRequest(contents_, request_id_); |
252 } | 253 } |
253 | 254 |
254 // Where the results are fed to. | 255 // Where the results are fed to. |
255 scoped_refptr<AboutUIHTMLSource> source_; | 256 scoped_refptr<AboutUIHTMLSource> source_; |
256 | 257 |
257 // Path in the URL. | 258 // Path in the URL. |
258 std::string path_; | 259 std::string path_; |
259 | 260 |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want | 833 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want |
833 // the refcount to be greater than 0. | 834 // the refcount to be greater than 0. |
834 scoped_refptr<AboutMemoryHandler> | 835 scoped_refptr<AboutMemoryHandler> |
835 handler(new AboutMemoryHandler(source, request_id)); | 836 handler(new AboutMemoryHandler(source, request_id)); |
836 // TODO(jamescook): Maybe this shouldn't update UMA? | 837 // TODO(jamescook): Maybe this shouldn't update UMA? |
837 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); | 838 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
838 } else { | 839 } else { |
839 source->FinishDataRequest( | 840 source->FinishDataRequest( |
840 ResourceBundle::GetSharedInstance().GetRawDataResource( | 841 ResourceBundle::GetSharedInstance().GetRawDataResource( |
841 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : | 842 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : |
842 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); | 843 IDR_ABOUT_MEMORY_HTML, |
| 844 ui::SCALE_FACTOR_NONE).as_string(), request_id); |
843 } | 845 } |
844 } | 846 } |
845 | 847 |
846 // Handler for filling in the "about:stats" page, as called by the browser's | 848 // Handler for filling in the "about:stats" page, as called by the browser's |
847 // About handler processing. | 849 // About handler processing. |
848 // |query| is roughly the query string of the about:stats URL. | 850 // |query| is roughly the query string of the about:stats URL. |
849 // Returns a string containing the HTML to render for the about:stats page. | 851 // Returns a string containing the HTML to render for the about:stats page. |
850 // Conditional Output: | 852 // Conditional Output: |
851 // if |query| is "json", returns a JSON format of all counters. | 853 // if |query| is "json", returns a JSON format of all counters. |
852 // if |query| is "raw", returns plain text of counter deltas. | 854 // if |query| is "raw", returns plain text of counter deltas. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 data.append(name); | 985 data.append(name); |
984 data.append(":"); | 986 data.append(":"); |
985 data.append(base::IntToString(delta)); | 987 data.append(base::IntToString(delta)); |
986 data.append("\n"); | 988 data.append("\n"); |
987 } | 989 } |
988 } | 990 } |
989 data.append("</pre>"); | 991 data.append("</pre>"); |
990 } else { | 992 } else { |
991 // Get about_stats.html/js from resource bundle. | 993 // Get about_stats.html/js from resource bundle. |
992 data = ResourceBundle::GetSharedInstance().GetRawDataResource( | 994 data = ResourceBundle::GetSharedInstance().GetRawDataResource( |
993 (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML)). | 995 (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML), |
994 as_string(); | 996 ui::SCALE_FACTOR_NONE).as_string(); |
995 | 997 |
996 if (query != kStatsJsPath) { | 998 if (query != kStatsJsPath) { |
997 // Clear the timer list since we stored the data in the timers list | 999 // Clear the timer list since we stored the data in the timers list |
998 // as well. | 1000 // as well. |
999 for (int index = static_cast<int>(timers->GetSize())-1; index >= 0; | 1001 for (int index = static_cast<int>(timers->GetSize())-1; index >= 0; |
1000 index--) { | 1002 index--) { |
1001 Value* value; | 1003 Value* value; |
1002 timers->Remove(index, &value); | 1004 timers->Remove(index, &value); |
1003 // We don't care about the value pointer; it's still tracked | 1005 // We don't care about the value pointer; it's still tracked |
1004 // on the counters list. | 1006 // on the counters list. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1081 |
1080 AppendFooter(&data); | 1082 AppendFooter(&data); |
1081 return data; | 1083 return data; |
1082 } | 1084 } |
1083 #endif | 1085 #endif |
1084 | 1086 |
1085 std::string AboutVersionStaticContent(const std::string& query) { | 1087 std::string AboutVersionStaticContent(const std::string& query) { |
1086 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 1088 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
1087 query == kVersionJsPath ? | 1089 query == kVersionJsPath ? |
1088 IDR_ABOUT_VERSION_JS : | 1090 IDR_ABOUT_VERSION_JS : |
1089 IDR_ABOUT_VERSION_HTML).as_string(); | 1091 IDR_ABOUT_VERSION_HTML, ui::SCALE_FACTOR_NONE).as_string(); |
1090 } | 1092 } |
1091 | 1093 |
1092 std::string AboutVersionStrings(DictionaryValue* localized_strings, | 1094 std::string AboutVersionStrings(DictionaryValue* localized_strings, |
1093 Profile* profile) { | 1095 Profile* profile) { |
1094 DCHECK(profile); | 1096 DCHECK(profile); |
1095 localized_strings->SetString("title", | 1097 localized_strings->SetString("title", |
1096 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); | 1098 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); |
1097 chrome::VersionInfo version_info; | 1099 chrome::VersionInfo version_info; |
1098 | 1100 |
1099 localized_strings->SetString("name", | 1101 localized_strings->SetString("name", |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 bool is_incognito, | 1382 bool is_incognito, |
1381 int request_id) { | 1383 int request_id) { |
1382 std::string response; | 1384 std::string response; |
1383 std::string host = source_name(); | 1385 std::string host = source_name(); |
1384 // Add your data source here, in alphabetical order. | 1386 // Add your data source here, in alphabetical order. |
1385 if (host == chrome::kChromeUIChromeURLsHost) { | 1387 if (host == chrome::kChromeUIChromeURLsHost) { |
1386 response = ChromeURLs(); | 1388 response = ChromeURLs(); |
1387 } else if (host == chrome::kChromeUICreditsHost) { | 1389 } else if (host == chrome::kChromeUICreditsHost) { |
1388 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; | 1390 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; |
1389 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1391 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1390 idr).as_string(); | 1392 idr, ui::SCALE_FACTOR_NONE).as_string(); |
1391 #if defined(OS_CHROMEOS) | 1393 #if defined(OS_CHROMEOS) |
1392 } else if (host == chrome::kChromeUICryptohomeHost) { | 1394 } else if (host == chrome::kChromeUICryptohomeHost) { |
1393 FinishCryptohomeDataRequest(this, path, request_id); | 1395 FinishCryptohomeDataRequest(this, path, request_id); |
1394 return; | 1396 return; |
1395 } else if (host == chrome::kChromeUIDiscardsHost) { | 1397 } else if (host == chrome::kChromeUIDiscardsHost) { |
1396 response = AboutDiscards(path); | 1398 response = AboutDiscards(path); |
1397 #endif | 1399 #endif |
1398 #if defined(USE_ASH) | 1400 #if defined(USE_ASH) |
1399 } else if (host == chrome::kChromeUITransparencyHost) { | 1401 } else if (host == chrome::kChromeUITransparencyHost) { |
1400 response = AboutTransparency(path); | 1402 response = AboutTransparency(path); |
(...skipping 10 matching lines...) Expand all Loading... |
1411 } else if (host == chrome::kChromeUIMemoryHost) { | 1413 } else if (host == chrome::kChromeUIMemoryHost) { |
1412 response = GetAboutMemoryRedirectResponse(profile()); | 1414 response = GetAboutMemoryRedirectResponse(profile()); |
1413 } else if (host == chrome::kChromeUIMemoryRedirectHost) { | 1415 } else if (host == chrome::kChromeUIMemoryRedirectHost) { |
1414 FinishMemoryDataRequest(path, this, request_id); | 1416 FinishMemoryDataRequest(path, this, request_id); |
1415 return; | 1417 return; |
1416 #if defined(OS_CHROMEOS) | 1418 #if defined(OS_CHROMEOS) |
1417 } else if (host == chrome::kChromeUINetworkHost) { | 1419 } else if (host == chrome::kChromeUINetworkHost) { |
1418 response = AboutNetwork(path); | 1420 response = AboutNetwork(path); |
1419 } else if (host == chrome::kChromeUIOSCreditsHost) { | 1421 } else if (host == chrome::kChromeUIOSCreditsHost) { |
1420 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1422 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1421 IDR_OS_CREDITS_HTML).as_string(); | 1423 IDR_OS_CREDITS_HTML, ui::SCALE_FACTOR_NONE).as_string(); |
1422 #endif | 1424 #endif |
1423 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1425 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
1424 } else if (host == chrome::kChromeUISandboxHost) { | 1426 } else if (host == chrome::kChromeUISandboxHost) { |
1425 response = AboutSandbox(); | 1427 response = AboutSandbox(); |
1426 #endif | 1428 #endif |
1427 } else if (host == chrome::kChromeUIStatsHost) { | 1429 } else if (host == chrome::kChromeUIStatsHost) { |
1428 response = AboutStats(path); | 1430 response = AboutStats(path); |
1429 } else if (host == chrome::kChromeUITermsHost) { | 1431 } else if (host == chrome::kChromeUITermsHost) { |
1430 #if defined(OS_CHROMEOS) | 1432 #if defined(OS_CHROMEOS) |
1431 ChromeOSTermsHandler::Start(this, path, request_id); | 1433 ChromeOSTermsHandler::Start(this, path, request_id); |
1432 return; | 1434 return; |
1433 #else | 1435 #else |
1434 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1436 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1435 IDR_TERMS_HTML).as_string(); | 1437 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string(); |
1436 #endif | 1438 #endif |
1437 } else if (host == chrome::kChromeUIVersionHost) { | 1439 } else if (host == chrome::kChromeUIVersionHost) { |
1438 if (path == kStringsJsPath) { | 1440 if (path == kStringsJsPath) { |
1439 // The Flash version information is needed on this page, so make sure | 1441 // The Flash version information is needed on this page, so make sure |
1440 // the plugins are loaded. | 1442 // the plugins are loaded. |
1441 PluginService::GetInstance()->GetPlugins( | 1443 PluginService::GetInstance()->GetPlugins( |
1442 base::Bind(&HandleAboutVersionStrings, | 1444 base::Bind(&HandleAboutVersionStrings, |
1443 make_scoped_refptr(this), request_id)); | 1445 make_scoped_refptr(this), request_id)); |
1444 return; | 1446 return; |
1445 } else { | 1447 } else { |
(...skipping 23 matching lines...) Expand all Loading... |
1469 | 1471 |
1470 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) | 1472 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) |
1471 : WebUIController(web_ui) { | 1473 : WebUIController(web_ui) { |
1472 Profile* profile = Profile::FromWebUI(web_ui); | 1474 Profile* profile = Profile::FromWebUI(web_ui); |
1473 ChromeURLDataManager::DataSource* source = | 1475 ChromeURLDataManager::DataSource* source = |
1474 new AboutUIHTMLSource(name, profile); | 1476 new AboutUIHTMLSource(name, profile); |
1475 if (source) { | 1477 if (source) { |
1476 ChromeURLDataManager::AddDataSource(profile, source); | 1478 ChromeURLDataManager::AddDataSource(profile, source); |
1477 } | 1479 } |
1478 } | 1480 } |
OLD | NEW |