| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "chrome/common/render_messages.h" | 48 #include "chrome/common/render_messages.h" |
| 49 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
| 50 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
| 51 #include "content/public/browser/plugin_service.h" | 51 #include "content/public/browser/plugin_service.h" |
| 52 #include "content/public/browser/render_process_host.h" | 52 #include "content/public/browser/render_process_host.h" |
| 53 #include "content/public/browser/render_view_host.h" | 53 #include "content/public/browser/render_view_host.h" |
| 54 #include "content/public/browser/web_contents.h" | 54 #include "content/public/browser/web_contents.h" |
| 55 #include "content/public/browser/web_ui.h" | 55 #include "content/public/browser/web_ui.h" |
| 56 #include "content/public/common/content_client.h" | 56 #include "content/public/common/content_client.h" |
| 57 #include "content/public/common/process_type.h" | 57 #include "content/public/common/process_type.h" |
| 58 #include "crypto/nss_util.h" | |
| 59 #include "googleurl/src/gurl.h" | 58 #include "googleurl/src/gurl.h" |
| 60 #include "grit/browser_resources.h" | 59 #include "grit/browser_resources.h" |
| 61 #include "grit/chromium_strings.h" | 60 #include "grit/chromium_strings.h" |
| 62 #include "grit/generated_resources.h" | 61 #include "grit/generated_resources.h" |
| 63 #include "grit/locale_settings.h" | 62 #include "grit/locale_settings.h" |
| 64 #include "net/base/escape.h" | 63 #include "net/base/escape.h" |
| 65 #include "net/base/net_util.h" | 64 #include "net/base/net_util.h" |
| 66 #include "ui/base/l10n/l10n_util.h" | 65 #include "ui/base/l10n/l10n_util.h" |
| 67 #include "ui/base/layout.h" | 66 #include "ui/base/layout.h" |
| 68 #include "ui/base/resource/resource_bundle.h" | 67 #include "ui/base/resource/resource_bundle.h" |
| 69 #include "v8/include/v8.h" | 68 #include "v8/include/v8.h" |
| 70 #include "webkit/glue/user_agent.h" | 69 #include "webkit/glue/user_agent.h" |
| 71 #include "webkit/glue/webkit_glue.h" | 70 #include "webkit/glue/webkit_glue.h" |
| 72 #include "webkit/plugins/webplugininfo.h" | 71 #include "webkit/plugins/webplugininfo.h" |
| 73 | 72 |
| 74 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 73 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 75 #include "content/public/browser/zygote_host_linux.h" | 74 #include "content/public/browser/zygote_host_linux.h" |
| 76 #include "content/public/common/sandbox_linux.h" | 75 #include "content/public/common/sandbox_linux.h" |
| 77 #endif | 76 #endif |
| 78 | 77 |
| 79 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
| 80 #include "chrome/browser/enumerate_modules_model_win.h" | 79 #include "chrome/browser/enumerate_modules_model_win.h" |
| 81 #endif | 80 #endif |
| 82 | 81 |
| 83 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
| 84 #include "chrome/browser/chromeos/cros/cros_library.h" | 83 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 85 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | |
| 86 #include "chrome/browser/chromeos/cros/network_library.h" | 84 #include "chrome/browser/chromeos/cros/network_library.h" |
| 87 #include "chrome/browser/chromeos/customization_document.h" | 85 #include "chrome/browser/chromeos/customization_document.h" |
| 88 #include "chrome/browser/chromeos/login/wizard_controller.h" | 86 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 89 #include "chrome/browser/chromeos/oom_priority_manager.h" | 87 #include "chrome/browser/chromeos/oom_priority_manager.h" |
| 90 #include "chrome/browser/chromeos/version_loader.h" | 88 #include "chrome/browser/chromeos/version_loader.h" |
| 91 #include "chromeos/dbus/cryptohome_client.h" | |
| 92 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 93 #endif | 89 #endif |
| 94 | 90 |
| 95 #if defined(USE_ASH) | 91 #if defined(USE_ASH) |
| 96 #include "ash/wm/frame_painter.h" | 92 #include "ash/wm/frame_painter.h" |
| 97 #include "base/string_split.h" | 93 #include "base/string_split.h" |
| 98 #endif | 94 #endif |
| 99 | 95 |
| 100 using base::Time; | 96 using base::Time; |
| 101 using base::TimeDelta; | 97 using base::TimeDelta; |
| 102 using content::BrowserThread; | 98 using content::BrowserThread; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 AppendFooter(&output); | 495 AppendFooter(&output); |
| 500 return output; | 496 return output; |
| 501 } | 497 } |
| 502 | 498 |
| 503 std::string AboutNetwork(const std::string& query) { | 499 std::string AboutNetwork(const std::string& query) { |
| 504 int refresh; | 500 int refresh; |
| 505 base::StringToInt(query, &refresh); | 501 base::StringToInt(query, &refresh); |
| 506 return GetNetworkHtmlInfo(refresh); | 502 return GetNetworkHtmlInfo(refresh); |
| 507 } | 503 } |
| 508 | 504 |
| 509 std::string AddBoolRow(const std::string& name, bool value) { | |
| 510 std::string row; | |
| 511 row.append(WrapWithTD(name)); | |
| 512 row.append(WrapWithTD(value ? "true" : "false")); | |
| 513 return WrapWithTR(row); | |
| 514 } | |
| 515 | |
| 516 std::string AddStringRow(const std::string& name, const std::string& value) { | 505 std::string AddStringRow(const std::string& name, const std::string& value) { |
| 517 std::string row; | 506 std::string row; |
| 518 row.append(WrapWithTD(name)); | 507 row.append(WrapWithTD(name)); |
| 519 row.append(WrapWithTD(value)); | 508 row.append(WrapWithTD(value)); |
| 520 return WrapWithTR(row); | 509 return WrapWithTR(row); |
| 521 } | 510 } |
| 522 | 511 |
| 523 class CryptohomeDataRequest : public base::RefCounted<CryptohomeDataRequest> { | |
| 524 public: | |
| 525 CryptohomeDataRequest(scoped_refptr<AboutUIHTMLSource> source, | |
| 526 const std::string& query, | |
| 527 int request_id) | |
| 528 : source_(source), | |
| 529 query_(query), | |
| 530 request_id_(request_id), | |
| 531 num_pending_values_(0), | |
| 532 is_mounted_(false), | |
| 533 tpm_is_ready_(false), | |
| 534 tpm_is_enabled_(false), | |
| 535 tpm_is_owned_(false), | |
| 536 tpm_is_being_owned_(false), | |
| 537 is_tpm_token_ready_(false) { | |
| 538 } | |
| 539 | |
| 540 // Starts asynchronous value fetching to finish data request. | |
| 541 void Start() { | |
| 542 // Request bool values asynchronously. | |
| 543 RequestBoolProperty(&chromeos::CryptohomeClient::TpmIsReady, | |
| 544 &tpm_is_ready_); | |
| 545 RequestBoolProperty(&chromeos::CryptohomeClient::Pkcs11IsTpmTokenReady, | |
| 546 &is_tpm_token_ready_); | |
| 547 | |
| 548 // TODO(hashimoto): Get these values asynchronously. crbug.com/126674 | |
| 549 chromeos::CryptohomeLibrary* cryptohome_library = | |
| 550 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | |
| 551 is_mounted_ = cryptohome_library->IsMounted(); | |
| 552 tpm_is_enabled_ = cryptohome_library->TpmIsEnabled(); | |
| 553 tpm_is_owned_ = cryptohome_library->TpmIsOwned(); | |
| 554 tpm_is_being_owned_ = cryptohome_library->TpmIsBeingOwned(); | |
| 555 } | |
| 556 | |
| 557 private: | |
| 558 // Member function pointer to CryptohomeClient's bool value getter. | |
| 559 typedef void (chromeos::CryptohomeClient::*CryptohomeBoolGetterMethod)( | |
| 560 const chromeos::CryptohomeClient::BoolMethodCallback&); | |
| 561 | |
| 562 ~CryptohomeDataRequest() {} | |
| 563 | |
| 564 // Requests Cryptohome's bool property. OnBoolValueReceived will be called. | |
| 565 void RequestBoolProperty(CryptohomeBoolGetterMethod getter, | |
| 566 bool* destination) { | |
| 567 ++num_pending_values_; | |
| 568 (chromeos::DBusThreadManager::Get()->GetCryptohomeClient()->*getter)( | |
| 569 base::Bind(&CryptohomeDataRequest::OnBoolValueReceived, | |
| 570 this, | |
| 571 destination)); | |
| 572 } | |
| 573 | |
| 574 // Called when a bool property is received. This method finishes data request | |
| 575 // when there is no pending values to be received. | |
| 576 void OnBoolValueReceived(bool* destination, | |
| 577 chromeos::DBusMethodCallStatus call_status, | |
| 578 bool value) { | |
| 579 if (call_status == chromeos::DBUS_METHOD_CALL_SUCCESS) | |
| 580 *destination = value; | |
| 581 if (--num_pending_values_ == 0) | |
| 582 Finish(); | |
| 583 } | |
| 584 | |
| 585 // Finishes data request. | |
| 586 void Finish() { | |
| 587 int refresh = 0; | |
| 588 base::StringToInt(query_, &refresh); | |
| 589 | |
| 590 std::string output; | |
| 591 AppendHeader(&output, refresh, "About Cryptohome"); | |
| 592 AppendBody(&output); | |
| 593 AppendRefresh(&output, refresh, "cryptohome"); | |
| 594 | |
| 595 output.append("<h3>CryptohomeLibrary:</h3>"); | |
| 596 output.append("<table>"); | |
| 597 output.append(AddBoolRow("IsMounted", is_mounted_)); | |
| 598 output.append(AddBoolRow("TpmIsReady", tpm_is_ready_)); | |
| 599 output.append(AddBoolRow("TpmIsEnabled", tpm_is_enabled_)); | |
| 600 output.append(AddBoolRow("TpmIsOwned", tpm_is_owned_)); | |
| 601 output.append(AddBoolRow("TpmIsBeingOwned", tpm_is_being_owned_)); | |
| 602 output.append(AddBoolRow("Pkcs11IsTpmTokenReady", is_tpm_token_ready_)); | |
| 603 output.append("</table>"); | |
| 604 | |
| 605 output.append("<h3>crypto:</h3>"); | |
| 606 output.append("<table>"); | |
| 607 output.append(AddBoolRow("IsTPMTokenReady", crypto::IsTPMTokenReady())); | |
| 608 std::string token_name, user_pin; | |
| 609 if (crypto::IsTPMTokenReady()) | |
| 610 crypto::GetTPMTokenInfo(&token_name, &user_pin); | |
| 611 output.append(AddStringRow("token_name", token_name)); | |
| 612 output.append( | |
| 613 AddStringRow("user_pin", std::string(user_pin.length(), '*'))); | |
| 614 output.append("</table>"); | |
| 615 AppendFooter(&output); | |
| 616 | |
| 617 source_->FinishDataRequest(output, request_id_); | |
| 618 } | |
| 619 | |
| 620 // Data request parameters. | |
| 621 scoped_refptr<AboutUIHTMLSource> source_; | |
| 622 std::string query_; | |
| 623 int request_id_; | |
| 624 | |
| 625 // Number of pending values to be received. | |
| 626 int num_pending_values_; | |
| 627 | |
| 628 // Bool values to be appended to the output. | |
| 629 bool is_mounted_; | |
| 630 bool tpm_is_ready_; | |
| 631 bool tpm_is_enabled_; | |
| 632 bool tpm_is_owned_; | |
| 633 bool tpm_is_being_owned_; | |
| 634 bool is_tpm_token_ready_; | |
| 635 | |
| 636 friend class base::RefCounted<CryptohomeDataRequest>; | |
| 637 }; | |
| 638 | |
| 639 std::string AboutDiscardsRun() { | 512 std::string AboutDiscardsRun() { |
| 640 std::string output; | 513 std::string output; |
| 641 AppendHeader(&output, 0, "About discards"); | 514 AppendHeader(&output, 0, "About discards"); |
| 642 output.append(StringPrintf("<meta http-equiv=\"refresh\" content=\"2;%s\">", | 515 output.append(StringPrintf("<meta http-equiv=\"refresh\" content=\"2;%s\">", |
| 643 chrome::kChromeUIDiscardsURL)); | 516 chrome::kChromeUIDiscardsURL)); |
| 644 output.append(WrapWithTag("p", "Discarding a tab...")); | 517 output.append(WrapWithTag("p", "Discarding a tab...")); |
| 645 g_browser_process->oom_priority_manager()->LogMemoryAndDiscardTab(); | 518 g_browser_process->oom_priority_manager()->LogMemoryAndDiscardTab(); |
| 646 AppendFooter(&output); | 519 AppendFooter(&output); |
| 647 return output; | 520 return output; |
| 648 } | 521 } |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 std::string response; | 1293 std::string response; |
| 1421 std::string host = source_name(); | 1294 std::string host = source_name(); |
| 1422 // Add your data source here, in alphabetical order. | 1295 // Add your data source here, in alphabetical order. |
| 1423 if (host == chrome::kChromeUIChromeURLsHost) { | 1296 if (host == chrome::kChromeUIChromeURLsHost) { |
| 1424 response = ChromeURLs(); | 1297 response = ChromeURLs(); |
| 1425 } else if (host == chrome::kChromeUICreditsHost) { | 1298 } else if (host == chrome::kChromeUICreditsHost) { |
| 1426 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; | 1299 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; |
| 1427 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1300 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 1428 idr, ui::SCALE_FACTOR_NONE).as_string(); | 1301 idr, ui::SCALE_FACTOR_NONE).as_string(); |
| 1429 #if defined(OS_CHROMEOS) | 1302 #if defined(OS_CHROMEOS) |
| 1430 } else if (host == chrome::kChromeUICryptohomeHost) { | |
| 1431 scoped_refptr<CryptohomeDataRequest> request( | |
| 1432 new CryptohomeDataRequest(this, path, request_id)); | |
| 1433 request->Start(); | |
| 1434 return; | |
| 1435 } else if (host == chrome::kChromeUIDiscardsHost) { | 1303 } else if (host == chrome::kChromeUIDiscardsHost) { |
| 1436 response = AboutDiscards(path); | 1304 response = AboutDiscards(path); |
| 1437 #endif | 1305 #endif |
| 1438 #if defined(USE_ASH) | 1306 #if defined(USE_ASH) |
| 1439 } else if (host == chrome::kChromeUITransparencyHost) { | 1307 } else if (host == chrome::kChromeUITransparencyHost) { |
| 1440 response = AboutTransparency(path); | 1308 response = AboutTransparency(path); |
| 1441 #endif | 1309 #endif |
| 1442 } else if (host == chrome::kChromeUIDNSHost) { | 1310 } else if (host == chrome::kChromeUIDNSHost) { |
| 1443 AboutDnsHandler::Start(this, request_id); | 1311 AboutDnsHandler::Start(this, request_id); |
| 1444 return; | 1312 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 | 1374 |
| 1507 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) | 1375 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) |
| 1508 : WebUIController(web_ui) { | 1376 : WebUIController(web_ui) { |
| 1509 Profile* profile = Profile::FromWebUI(web_ui); | 1377 Profile* profile = Profile::FromWebUI(web_ui); |
| 1510 ChromeURLDataManager::DataSource* source = | 1378 ChromeURLDataManager::DataSource* source = |
| 1511 new AboutUIHTMLSource(name, profile); | 1379 new AboutUIHTMLSource(name, profile); |
| 1512 if (source) { | 1380 if (source) { |
| 1513 ChromeURLDataManager::AddDataSource(profile, source); | 1381 ChromeURLDataManager::AddDataSource(profile, source); |
| 1514 } | 1382 } |
| 1515 } | 1383 } |
| OLD | NEW |