Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Side by Side Diff: chrome/browser/ui/webui/about_ui.cc

Issue 10703162: chromeos: Remove CryptohomeLibrary::TpmGetPassword and TpmIsReady (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromium style error Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 return WrapWithTR(row); 514 return WrapWithTR(row);
515 } 515 }
516 516
517 std::string AddStringRow(const std::string& name, const std::string& value) { 517 std::string AddStringRow(const std::string& name, const std::string& value) {
518 std::string row; 518 std::string row;
519 row.append(WrapWithTD(name)); 519 row.append(WrapWithTD(name));
520 row.append(WrapWithTD(value)); 520 row.append(WrapWithTD(value));
521 return WrapWithTR(row); 521 return WrapWithTR(row);
522 } 522 }
523 523
524 void FinishCryptohomeDataRequestInternal( 524 class CryptohomeDataRequest : public base::RefCounted<CryptohomeDataRequest> {
stevenjb 2012/07/12 15:32:02 This seems like it belongs in its own file, not ab
525 scoped_refptr<AboutUIHTMLSource> source, 525 public:
526 int refresh, 526 CryptohomeDataRequest(scoped_refptr<AboutUIHTMLSource> source,
527 int request_id, 527 const std::string& query,
528 chromeos::DBusMethodCallStatus call_status, 528 int request_id)
529 bool is_tpm_token_ready) { 529 : source_(source),
530 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) 530 query_(query),
531 is_tpm_token_ready = false; 531 request_id_(request_id),
532 num_pending_values_(0),
533 is_mounted_(false),
534 tpm_is_ready_(false),
535 tpm_is_enabled_(false),
536 tpm_is_owned_(false),
537 tpm_is_being_owned_(false),
538 is_tpm_token_ready_(false) {
539 }
532 540
533 chromeos::CryptohomeLibrary* cryptohome = 541 // Starts asynchronous value fetching to finish data request.
534 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); 542 void Start() {
535 std::string output; 543 // Request bool values asynchronously.
536 AppendHeader(&output, refresh, "About Cryptohome"); 544 RequestBoolProperty(&chromeos::CryptohomeClient::TpmIsReady,
537 AppendBody(&output); 545 &tpm_is_ready_);
538 AppendRefresh(&output, refresh, "cryptohome"); 546 RequestBoolProperty(&chromeos::CryptohomeClient::Pkcs11IsTpmTokenReady,
547 &is_tpm_token_ready_);
539 548
540 output.append("<h3>CryptohomeLibrary:</h3>"); 549 // TODO(hashimoto): Get these values asynchronously. crbug.com/126674
stevenjb 2012/07/12 15:32:02 We could, however, wait to move this until address
hashimoto 2012/07/13 04:27:21 Yes, let's fix crbug.com/126674 first.
541 output.append("<table>"); 550 chromeos::CryptohomeLibrary* cryptohome_library =
542 output.append(AddBoolRow("IsMounted", cryptohome->IsMounted())); 551 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary();
543 output.append(AddBoolRow("TpmIsReady", cryptohome->TpmIsReady())); 552 is_mounted_ = cryptohome_library->IsMounted();
544 output.append(AddBoolRow("TpmIsEnabled", cryptohome->TpmIsEnabled())); 553 tpm_is_enabled_ = cryptohome_library->TpmIsEnabled();
545 output.append(AddBoolRow("TpmIsOwned", cryptohome->TpmIsOwned())); 554 tpm_is_owned_ = cryptohome_library->TpmIsOwned();
546 output.append(AddBoolRow("TpmIsBeingOwned", cryptohome->TpmIsBeingOwned())); 555 tpm_is_being_owned_ = cryptohome_library->TpmIsBeingOwned();
547 output.append(AddBoolRow("Pkcs11IsTpmTokenReady", is_tpm_token_ready)); 556 }
548 output.append("</table>");
549 557
550 output.append("<h3>crypto:</h3>"); 558 private:
551 output.append("<table>"); 559 // Member function pointer to CryptohomeClient's bool value getter.
552 output.append(AddBoolRow("IsTPMTokenReady", crypto::IsTPMTokenReady())); 560 typedef void (chromeos::CryptohomeClient::*CryptohomeBoolGetterMethod)(
553 std::string token_name, user_pin; 561 const chromeos::CryptohomeClient::BoolMethodCallback&);
stevenjb 2012/07/12 15:32:02 This is extremely difficult to read/parse. I don't
hashimoto 2012/07/13 04:27:21 Agree, member-function-pointer and operator '->*'
554 if (crypto::IsTPMTokenReady())
555 crypto::GetTPMTokenInfo(&token_name, &user_pin);
556 output.append(AddStringRow("token_name", token_name));
557 output.append(AddStringRow("user_pin", std::string(user_pin.length(), '*')));
558 output.append("</table>");
559 AppendFooter(&output);
560 562
561 source->FinishDataRequest(output, request_id); 563 ~CryptohomeDataRequest() {}
562 }
563 564
564 void FinishCryptohomeDataRequest(scoped_refptr<AboutUIHTMLSource> source, 565 // Requests Cryptohome's bool property. OnBoolValueReceived will be called.
565 const std::string& query, 566 void RequestBoolProperty(CryptohomeBoolGetterMethod getter,
566 int request_id) { 567 bool* destination) {
567 int refresh; 568 ++num_pending_values_;
568 base::StringToInt(query, &refresh); 569 (chromeos::DBusThreadManager::Get()->GetCryptohomeClient()->*getter)(
570 base::Bind(&CryptohomeDataRequest::OnBoolValueReceived,
571 this,
572 destination));
stevenjb 2012/07/12 15:32:02 Also very confusing.
573 }
569 574
570 chromeos::DBusThreadManager::Get()->GetCryptohomeClient()-> 575 // Called when a bool property is received. This method finishes data request
571 Pkcs11IsTpmTokenReady(base::Bind(&FinishCryptohomeDataRequestInternal, 576 // when there is no pending values to be received.
572 source, 577 void OnBoolValueReceived(bool* destination,
573 refresh, 578 chromeos::DBusMethodCallStatus call_status,
574 request_id)); 579 bool value) {
575 } 580 if (call_status == chromeos::DBUS_METHOD_CALL_SUCCESS)
581 *destination = value;
582 if (--num_pending_values_ == 0)
583 Finish();
584 }
585
586 // Finishes data request.
587 void Finish() {
588 int refresh = 0;
589 base::StringToInt(query_, &refresh);
590
591 std::string output;
592 AppendHeader(&output, refresh, "About Cryptohome");
593 AppendBody(&output);
594 AppendRefresh(&output, refresh, "cryptohome");
595
596 output.append("<h3>CryptohomeLibrary:</h3>");
597 output.append("<table>");
598 output.append(AddBoolRow("IsMounted", is_mounted_));
599 output.append(AddBoolRow("TpmIsReady", tpm_is_ready_));
600 output.append(AddBoolRow("TpmIsEnabled", tpm_is_enabled_));
601 output.append(AddBoolRow("TpmIsOwned", tpm_is_owned_));
602 output.append(AddBoolRow("TpmIsBeingOwned", tpm_is_being_owned_));
603 output.append(AddBoolRow("Pkcs11IsTpmTokenReady", is_tpm_token_ready_));
604 output.append("</table>");
605
606 output.append("<h3>crypto:</h3>");
607 output.append("<table>");
608 output.append(AddBoolRow("IsTPMTokenReady", crypto::IsTPMTokenReady()));
609 std::string token_name, user_pin;
610 if (crypto::IsTPMTokenReady())
611 crypto::GetTPMTokenInfo(&token_name, &user_pin);
612 output.append(AddStringRow("token_name", token_name));
613 output.append(
614 AddStringRow("user_pin", std::string(user_pin.length(), '*')));
615 output.append("</table>");
616 AppendFooter(&output);
617
618 source_->FinishDataRequest(output, request_id_);
619 }
620
621 // Data request parameters.
622 scoped_refptr<AboutUIHTMLSource> source_;
623 std::string query_;
624 int request_id_;
625
626 // Number of pending values to be received.
627 int num_pending_values_;
628
629 // Bool values to be appended to the output.
630 bool is_mounted_;
631 bool tpm_is_ready_;
632 bool tpm_is_enabled_;
633 bool tpm_is_owned_;
634 bool tpm_is_being_owned_;
635 bool is_tpm_token_ready_;
636
637 friend class base::RefCounted<CryptohomeDataRequest>;
638 };
576 639
577 std::string AboutDiscardsRun() { 640 std::string AboutDiscardsRun() {
578 std::string output; 641 std::string output;
579 AppendHeader(&output, 0, "About discards"); 642 AppendHeader(&output, 0, "About discards");
580 output.append(StringPrintf("<meta http-equiv=\"refresh\" content=\"2;%s\">", 643 output.append(StringPrintf("<meta http-equiv=\"refresh\" content=\"2;%s\">",
581 chrome::kChromeUIDiscardsURL)); 644 chrome::kChromeUIDiscardsURL));
582 output.append(WrapWithTag("p", "Discarding a tab...")); 645 output.append(WrapWithTag("p", "Discarding a tab..."));
583 g_browser_process->oom_priority_manager()->LogMemoryAndDiscardTab(); 646 g_browser_process->oom_priority_manager()->LogMemoryAndDiscardTab();
584 AppendFooter(&output); 647 AppendFooter(&output);
585 return output; 648 return output;
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 std::string host = source_name(); 1450 std::string host = source_name();
1388 // Add your data source here, in alphabetical order. 1451 // Add your data source here, in alphabetical order.
1389 if (host == chrome::kChromeUIChromeURLsHost) { 1452 if (host == chrome::kChromeUIChromeURLsHost) {
1390 response = ChromeURLs(); 1453 response = ChromeURLs();
1391 } else if (host == chrome::kChromeUICreditsHost) { 1454 } else if (host == chrome::kChromeUICreditsHost) {
1392 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; 1455 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML;
1393 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1456 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1394 idr, ui::SCALE_FACTOR_NONE).as_string(); 1457 idr, ui::SCALE_FACTOR_NONE).as_string();
1395 #if defined(OS_CHROMEOS) 1458 #if defined(OS_CHROMEOS)
1396 } else if (host == chrome::kChromeUICryptohomeHost) { 1459 } else if (host == chrome::kChromeUICryptohomeHost) {
1397 FinishCryptohomeDataRequest(this, path, request_id); 1460 scoped_refptr<CryptohomeDataRequest> request(
1461 new CryptohomeDataRequest(this, path, request_id));
1462 request->Start();
1398 return; 1463 return;
1399 } else if (host == chrome::kChromeUIDiscardsHost) { 1464 } else if (host == chrome::kChromeUIDiscardsHost) {
1400 response = AboutDiscards(path); 1465 response = AboutDiscards(path);
1401 #endif 1466 #endif
1402 #if defined(USE_ASH) 1467 #if defined(USE_ASH)
1403 } else if (host == chrome::kChromeUITransparencyHost) { 1468 } else if (host == chrome::kChromeUITransparencyHost) {
1404 response = AboutTransparency(path); 1469 response = AboutTransparency(path);
1405 #endif 1470 #endif
1406 } else if (host == chrome::kChromeUIDNSHost) { 1471 } else if (host == chrome::kChromeUIDNSHost) {
1407 AboutDnsHandler::Start(this, request_id); 1472 AboutDnsHandler::Start(this, request_id);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 1537
1473 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) 1538 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name)
1474 : WebUIController(web_ui) { 1539 : WebUIController(web_ui) {
1475 Profile* profile = Profile::FromWebUI(web_ui); 1540 Profile* profile = Profile::FromWebUI(web_ui);
1476 ChromeURLDataManager::DataSource* source = 1541 ChromeURLDataManager::DataSource* source =
1477 new AboutUIHTMLSource(name, profile); 1542 new AboutUIHTMLSource(name, profile);
1478 if (source) { 1543 if (source) {
1479 ChromeURLDataManager::AddDataSource(profile, source); 1544 ChromeURLDataManager::AddDataSource(profile, source);
1480 } 1545 }
1481 } 1546 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/tpm_password_fetcher.cc ('k') | chromeos/dbus/cryptohome_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698