OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // stats computations across runs. | 414 // stats computations across runs. |
415 static DictionaryValue root; | 415 static DictionaryValue root; |
416 | 416 |
417 StatsTable* table = StatsTable::current(); | 417 StatsTable* table = StatsTable::current(); |
418 if (!table) | 418 if (!table) |
419 return std::string(); | 419 return std::string(); |
420 | 420 |
421 // We maintain two lists - one for counters and one for timers. | 421 // We maintain two lists - one for counters and one for timers. |
422 // Timers actually get stored on both lists. | 422 // Timers actually get stored on both lists. |
423 ListValue* counters; | 423 ListValue* counters; |
424 if (!root.GetList(L"counters", &counters)) { | 424 if (!root.GetList("counters", &counters)) { |
425 counters = new ListValue(); | 425 counters = new ListValue(); |
426 root.Set(L"counters", counters); | 426 root.Set("counters", counters); |
427 } | 427 } |
428 | 428 |
429 ListValue* timers; | 429 ListValue* timers; |
430 if (!root.GetList(L"timers", &timers)) { | 430 if (!root.GetList("timers", &timers)) { |
431 timers = new ListValue(); | 431 timers = new ListValue(); |
432 root.Set(L"timers", timers); | 432 root.Set("timers", timers); |
433 } | 433 } |
434 | 434 |
435 // NOTE: Counters start at index 1. | 435 // NOTE: Counters start at index 1. |
436 for (int index = 1; index <= table->GetMaxCounters(); index++) { | 436 for (int index = 1; index <= table->GetMaxCounters(); index++) { |
437 // Get the counter's full name | 437 // Get the counter's full name |
438 std::string full_name = table->GetRowName(index); | 438 std::string full_name = table->GetRowName(index); |
439 if (full_name.length() == 0) | 439 if (full_name.length() == 0) |
440 break; | 440 break; |
441 DCHECK_EQ(':', full_name[1]); | 441 DCHECK_EQ(':', full_name[1]); |
442 char counter_type = full_name[0]; | 442 char counter_type = full_name[0]; |
443 std::string name = full_name.substr(2); | 443 std::string name = full_name.substr(2); |
444 | 444 |
445 // JSON doesn't allow '.' in names. | 445 // JSON doesn't allow '.' in names. |
446 size_t pos; | 446 size_t pos; |
447 while ((pos = name.find(".")) != std::string::npos) | 447 while ((pos = name.find(".")) != std::string::npos) |
448 name.replace(pos, 1, ":"); | 448 name.replace(pos, 1, ":"); |
449 | 449 |
450 // Try to see if this name already exists. | 450 // Try to see if this name already exists. |
451 DictionaryValue* counter = NULL; | 451 DictionaryValue* counter = NULL; |
452 for (size_t scan_index = 0; | 452 for (size_t scan_index = 0; |
453 scan_index < counters->GetSize(); scan_index++) { | 453 scan_index < counters->GetSize(); scan_index++) { |
454 DictionaryValue* dictionary; | 454 DictionaryValue* dictionary; |
455 if (counters->GetDictionary(scan_index, &dictionary)) { | 455 if (counters->GetDictionary(scan_index, &dictionary)) { |
456 std::wstring scan_name; | 456 std::string scan_name; |
457 if (dictionary->GetString(L"name", &scan_name) && | 457 if (dictionary->GetString("name", &scan_name) && scan_name == name) { |
458 WideToASCII(scan_name) == name) { | |
459 counter = dictionary; | 458 counter = dictionary; |
460 } | 459 } |
461 } else { | 460 } else { |
462 NOTREACHED(); // Should always be there | 461 NOTREACHED(); // Should always be there |
463 } | 462 } |
464 } | 463 } |
465 | 464 |
466 if (counter == NULL) { | 465 if (counter == NULL) { |
467 counter = new DictionaryValue(); | 466 counter = new DictionaryValue(); |
468 counter->SetString(L"name", ASCIIToWide(name)); | 467 counter->SetString("name", name); |
469 counters->Append(counter); | 468 counters->Append(counter); |
470 } | 469 } |
471 | 470 |
472 switch (counter_type) { | 471 switch (counter_type) { |
473 case 'c': | 472 case 'c': |
474 { | 473 { |
475 int new_value = table->GetRowValue(index); | 474 int new_value = table->GetRowValue(index); |
476 int prior_value = 0; | 475 int prior_value = 0; |
477 int delta = 0; | 476 int delta = 0; |
478 if (counter->GetInteger(L"value", &prior_value)) { | 477 if (counter->GetInteger("value", &prior_value)) { |
479 delta = new_value - prior_value; | 478 delta = new_value - prior_value; |
480 } | 479 } |
481 counter->SetInteger(L"value", new_value); | 480 counter->SetInteger("value", new_value); |
482 counter->SetInteger(L"delta", delta); | 481 counter->SetInteger("delta", delta); |
483 } | 482 } |
484 break; | 483 break; |
485 case 'm': | 484 case 'm': |
486 { | 485 { |
487 // TODO(mbelshe): implement me. | 486 // TODO(mbelshe): implement me. |
488 } | 487 } |
489 break; | 488 break; |
490 case 't': | 489 case 't': |
491 { | 490 { |
492 int time = table->GetRowValue(index); | 491 int time = table->GetRowValue(index); |
493 counter->SetInteger(L"time", time); | 492 counter->SetInteger("time", time); |
494 | 493 |
495 // Store this on the timers list as well. | 494 // Store this on the timers list as well. |
496 timers->Append(counter); | 495 timers->Append(counter); |
497 } | 496 } |
498 break; | 497 break; |
499 default: | 498 default: |
500 NOTREACHED(); | 499 NOTREACHED(); |
501 } | 500 } |
502 } | 501 } |
503 | 502 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD)); | 595 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD)); |
597 } | 596 } |
598 data.append("</p>"); | 597 data.append("</p>"); |
599 | 598 |
600 data.append("</body></html>\n"); | 599 data.append("</body></html>\n"); |
601 return data; | 600 return data; |
602 } | 601 } |
603 #endif | 602 #endif |
604 | 603 |
605 std::string AboutVersion(DictionaryValue* localized_strings) { | 604 std::string AboutVersion(DictionaryValue* localized_strings) { |
606 localized_strings->SetString(L"title", | 605 localized_strings->SetString("title", |
607 l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)); | 606 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); |
608 scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); | 607 scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); |
609 if (version_info == NULL) { | 608 if (version_info == NULL) { |
610 DLOG(ERROR) << "Unable to create FileVersionInfo object"; | 609 DLOG(ERROR) << "Unable to create FileVersionInfo object"; |
611 return std::string(); | 610 return std::string(); |
612 } | 611 } |
613 | 612 |
614 std::string webkit_version = webkit_glue::GetWebKitVersion(); | 613 std::string webkit_version = webkit_glue::GetWebKitVersion(); |
615 #ifdef CHROME_V8 | 614 #ifdef CHROME_V8 |
616 std::string js_version(v8::V8::GetVersion()); | 615 std::string js_version(v8::V8::GetVersion()); |
617 std::string js_engine = "V8"; | 616 std::string js_engine = "V8"; |
618 #else | 617 #else |
619 std::string js_version = webkit_version; | 618 std::string js_version = webkit_version; |
620 std::string js_engine = "JavaScriptCore"; | 619 std::string js_engine = "JavaScriptCore"; |
621 #endif | 620 #endif |
622 | 621 |
623 localized_strings->SetString(L"name", | 622 localized_strings->SetString("name", |
624 l10n_util::GetString(IDS_PRODUCT_NAME)); | 623 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
625 localized_strings->SetString(L"version", version_info->file_version()); | 624 localized_strings->SetString("version", |
626 std::wstring mod = UTF16ToWide(platform_util::GetVersionStringModifier()); | 625 WideToUTF16Hack(version_info->file_version())); |
627 localized_strings->SetString(L"version_modifier", mod); | 626 localized_strings->SetString("version_modifier", |
628 localized_strings->SetString(L"js_engine", js_engine); | 627 platform_util::GetVersionStringModifier()); |
629 localized_strings->SetString(L"js_version", js_version); | 628 localized_strings->SetString("js_engine", js_engine); |
630 localized_strings->SetString(L"webkit_version", webkit_version); | 629 localized_strings->SetString("js_version", js_version); |
631 localized_strings->SetString(L"company", | 630 localized_strings->SetString("webkit_version", webkit_version); |
632 l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME)); | 631 localized_strings->SetString("company", |
633 localized_strings->SetString(L"copyright", | 632 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COMPANY_NAME)); |
634 l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); | 633 localized_strings->SetString("copyright", |
635 localized_strings->SetString(L"cl", version_info->last_change()); | 634 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT)); |
| 635 localized_strings->SetString("cl", |
| 636 WideToUTF16Hack(version_info->last_change())); |
636 if (version_info->is_official_build()) { | 637 if (version_info->is_official_build()) { |
637 localized_strings->SetString(L"official", | 638 localized_strings->SetString("official", |
638 l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)); | 639 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_OFFICIAL)); |
639 } else { | 640 } else { |
640 localized_strings->SetString(L"official", | 641 localized_strings->SetString("official", |
641 l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)); | 642 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_UNOFFICIAL)); |
642 } | 643 } |
643 localized_strings->SetString(L"user_agent_name", | 644 localized_strings->SetString("user_agent_name", |
644 l10n_util::GetString(IDS_ABOUT_VERSION_USER_AGENT)); | 645 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_USER_AGENT)); |
645 localized_strings->SetString(L"useragent", webkit_glue::GetUserAgent(GURL())); | 646 localized_strings->SetString("useragent", webkit_glue::GetUserAgent(GURL())); |
646 localized_strings->SetString(L"command_line_name", | 647 localized_strings->SetString("command_line_name", |
647 l10n_util::GetString(IDS_ABOUT_VERSION_COMMAND_LINE)); | 648 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COMMAND_LINE)); |
648 | 649 |
649 #if defined(OS_WIN) | 650 #if defined(OS_WIN) |
650 localized_strings->SetString(L"command_line", | 651 localized_strings->SetString("command_line", |
651 CommandLine::ForCurrentProcess()->command_line_string()); | 652 WideToUTF16(CommandLine::ForCurrentProcess()->command_line_string())); |
652 #elif defined(OS_POSIX) | 653 #elif defined(OS_POSIX) |
653 std::string command_line = ""; | 654 std::string command_line = ""; |
654 typedef std::vector<std::string> ArgvList; | 655 typedef std::vector<std::string> ArgvList; |
655 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv(); | 656 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv(); |
656 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) | 657 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) |
657 command_line += " " + *iter; | 658 command_line += " " + *iter; |
658 localized_strings->SetString(L"command_line", command_line); | 659 // TODO(viettrungluu): |command_line| could really have any encoding, whereas |
| 660 // below we assumes it's UTF-8. |
| 661 localized_strings->SetString("command_line", command_line); |
659 #endif | 662 #endif |
660 | 663 |
661 base::StringPiece version_html( | 664 base::StringPiece version_html( |
662 ResourceBundle::GetSharedInstance().GetRawDataResource( | 665 ResourceBundle::GetSharedInstance().GetRawDataResource( |
663 IDR_ABOUT_VERSION_HTML)); | 666 IDR_ABOUT_VERSION_HTML)); |
664 | 667 |
665 return jstemplate_builder::GetTemplatesHtml( | 668 return jstemplate_builder::GetTemplatesHtml( |
666 version_html, localized_strings, "t" /* template root node id */); | 669 version_html, localized_strings, "t" /* template root node id */); |
667 } | 670 } |
668 | 671 |
669 static void AddBoolSyncDetail(ListValue* details, const std::wstring& stat_name, | 672 static void AddBoolSyncDetail(ListValue* details, const std::string& stat_name, |
670 bool stat_value) { | 673 bool stat_value) { |
671 DictionaryValue* val = new DictionaryValue; | 674 DictionaryValue* val = new DictionaryValue; |
672 val->SetString(L"stat_name", stat_name); | 675 val->SetString("stat_name", stat_name); |
673 val->SetBoolean(L"stat_value", stat_value); | 676 val->SetBoolean("stat_value", stat_value); |
674 details->Append(val); | 677 details->Append(val); |
675 } | 678 } |
676 | 679 |
677 static void AddIntSyncDetail(ListValue* details, const std::wstring& stat_name, | 680 static void AddIntSyncDetail(ListValue* details, const std::string& stat_name, |
678 int64 stat_value) { | 681 int64 stat_value) { |
679 DictionaryValue* val = new DictionaryValue; | 682 DictionaryValue* val = new DictionaryValue; |
680 val->SetString(L"stat_name", stat_name); | 683 val->SetString("stat_name", stat_name); |
681 val->SetString(L"stat_value", UTF16ToWide(base::FormatNumber(stat_value))); | 684 val->SetString("stat_value", base::FormatNumber(stat_value)); |
682 details->Append(val); | 685 details->Append(val); |
683 } | 686 } |
684 | 687 |
685 static std::wstring MakeSyncAuthErrorText( | 688 static std::string MakeSyncAuthErrorText( |
686 const GoogleServiceAuthError::State& state) { | 689 const GoogleServiceAuthError::State& state) { |
687 switch (state) { | 690 switch (state) { |
688 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 691 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
689 return L"INVALID_GAIA_CREDENTIALS"; | 692 return "INVALID_GAIA_CREDENTIALS"; |
690 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: | 693 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: |
691 return L"USER_NOT_SIGNED_UP"; | 694 return "USER_NOT_SIGNED_UP"; |
692 case GoogleServiceAuthError::CONNECTION_FAILED: | 695 case GoogleServiceAuthError::CONNECTION_FAILED: |
693 return L"CONNECTION_FAILED"; | 696 return "CONNECTION_FAILED"; |
694 default: | 697 default: |
695 return std::wstring(); | 698 return std::string(); |
696 } | 699 } |
697 } | 700 } |
698 | 701 |
699 std::string AboutSync() { | 702 std::string AboutSync() { |
700 FilePath user_data_dir; | 703 FilePath user_data_dir; |
701 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 704 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) |
702 return std::string(); | 705 return std::string(); |
703 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 706 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
704 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); | 707 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); |
705 ProfileSyncService* service = profile->GetProfileSyncService(); | 708 ProfileSyncService* service = profile->GetProfileSyncService(); |
706 | 709 |
707 DictionaryValue strings; | 710 DictionaryValue strings; |
708 if (!service || !service->HasSyncSetupCompleted()) { | 711 if (!service || !service->HasSyncSetupCompleted()) { |
709 strings.SetString(L"summary", L"SYNC DISABLED"); | 712 strings.SetString("summary", "SYNC DISABLED"); |
710 } else { | 713 } else { |
711 SyncManager::Status full_status(service->QueryDetailedSyncStatus()); | 714 SyncManager::Status full_status(service->QueryDetailedSyncStatus()); |
712 | 715 |
713 strings.SetString(L"summary", | 716 strings.SetString("summary", |
714 ProfileSyncService::BuildSyncStatusSummaryText( | 717 ProfileSyncService::BuildSyncStatusSummaryText( |
715 full_status.summary)); | 718 full_status.summary)); |
716 | 719 |
717 strings.Set(L"authenticated", | 720 strings.Set("authenticated", |
718 new FundamentalValue(full_status.authenticated)); | 721 new FundamentalValue(full_status.authenticated)); |
719 strings.SetString(L"auth_problem", | 722 strings.SetString("auth_problem", |
720 MakeSyncAuthErrorText(service->GetAuthError().state())); | 723 MakeSyncAuthErrorText(service->GetAuthError().state())); |
721 | 724 |
722 strings.SetString(L"time_since_sync", service->GetLastSyncedTimeString()); | 725 strings.SetString("time_since_sync", service->GetLastSyncedTimeString()); |
723 | 726 |
724 ListValue* details = new ListValue(); | 727 ListValue* details = new ListValue(); |
725 strings.Set(L"details", details); | 728 strings.Set("details", details); |
726 AddBoolSyncDetail(details, L"Server Up", full_status.server_up); | 729 AddBoolSyncDetail(details, "Server Up", full_status.server_up); |
727 AddBoolSyncDetail(details, L"Server Reachable", | 730 AddBoolSyncDetail(details, "Server Reachable", |
728 full_status.server_reachable); | 731 full_status.server_reachable); |
729 AddBoolSyncDetail(details, L"Server Broken", full_status.server_broken); | 732 AddBoolSyncDetail(details, "Server Broken", full_status.server_broken); |
730 AddBoolSyncDetail(details, L"Notifications Enabled", | 733 AddBoolSyncDetail(details, "Notifications Enabled", |
731 full_status.notifications_enabled); | 734 full_status.notifications_enabled); |
732 AddIntSyncDetail(details, L"Notifications Received", | 735 AddIntSyncDetail(details, "Notifications Received", |
733 full_status.notifications_received); | 736 full_status.notifications_received); |
734 AddIntSyncDetail(details, L"Notifications Sent", | 737 AddIntSyncDetail(details, "Notifications Sent", |
735 full_status.notifications_sent); | 738 full_status.notifications_sent); |
736 AddIntSyncDetail(details, L"Unsynced Count", full_status.unsynced_count); | 739 AddIntSyncDetail(details, "Unsynced Count", full_status.unsynced_count); |
737 AddIntSyncDetail(details, L"Conflicting Count", | 740 AddIntSyncDetail(details, "Conflicting Count", |
738 full_status.conflicting_count); | 741 full_status.conflicting_count); |
739 AddBoolSyncDetail(details, L"Syncing", full_status.syncing); | 742 AddBoolSyncDetail(details, "Syncing", full_status.syncing); |
740 AddBoolSyncDetail(details, L"Initial Sync Ended", | 743 AddBoolSyncDetail(details, "Initial Sync Ended", |
741 full_status.initial_sync_ended); | 744 full_status.initial_sync_ended); |
742 AddBoolSyncDetail(details, L"Syncer Stuck", full_status.syncer_stuck); | 745 AddBoolSyncDetail(details, "Syncer Stuck", full_status.syncer_stuck); |
743 AddIntSyncDetail(details, L"Updates Available", | 746 AddIntSyncDetail(details, "Updates Available", |
744 full_status.updates_available); | 747 full_status.updates_available); |
745 AddIntSyncDetail(details, L"Updates Received", | 748 AddIntSyncDetail(details, "Updates Received", full_status.updates_received); |
746 full_status.updates_received); | 749 AddBoolSyncDetail(details, "Disk Full", full_status.disk_full); |
747 AddBoolSyncDetail(details, L"Disk Full", full_status.disk_full); | 750 AddBoolSyncDetail(details, "Invalid Store", full_status.invalid_store); |
748 AddBoolSyncDetail(details, L"Invalid Store", full_status.invalid_store); | 751 AddIntSyncDetail(details, "Max Consecutive Errors", |
749 AddIntSyncDetail(details, L"Max Consecutive Errors", | |
750 full_status.max_consecutive_errors); | 752 full_status.max_consecutive_errors); |
751 | 753 |
752 if (service->unrecoverable_error_detected()) { | 754 if (service->unrecoverable_error_detected()) { |
753 strings.Set(L"unrecoverable_error_detected", new FundamentalValue(true)); | 755 strings.Set("unrecoverable_error_detected", new FundamentalValue(true)); |
754 strings.SetString(L"unrecoverable_error_message", | 756 strings.SetString("unrecoverable_error_message", |
755 service->unrecoverable_error_message()); | 757 service->unrecoverable_error_message()); |
756 tracked_objects::Location loc(service->unrecoverable_error_location()); | 758 tracked_objects::Location loc(service->unrecoverable_error_location()); |
757 std::string location_str; | 759 std::string location_str; |
758 loc.Write(true, true, &location_str); | 760 loc.Write(true, true, &location_str); |
759 strings.SetString(L"unrecoverable_error_location", location_str); | 761 strings.SetString("unrecoverable_error_location", location_str); |
760 } | 762 } |
761 | 763 |
762 browser_sync::ModelSafeRoutingInfo routes; | 764 browser_sync::ModelSafeRoutingInfo routes; |
763 service->backend()->GetModelSafeRoutingInfo(&routes); | 765 service->backend()->GetModelSafeRoutingInfo(&routes); |
764 ListValue* routing_info = new ListValue(); | 766 ListValue* routing_info = new ListValue(); |
765 strings.Set(L"routing_info", routing_info); | 767 strings.Set("routing_info", routing_info); |
766 browser_sync::ModelSafeRoutingInfo::const_iterator it = routes.begin(); | 768 browser_sync::ModelSafeRoutingInfo::const_iterator it = routes.begin(); |
767 for (; it != routes.end(); ++it) { | 769 for (; it != routes.end(); ++it) { |
768 DictionaryValue* val = new DictionaryValue; | 770 DictionaryValue* val = new DictionaryValue; |
769 val->SetString(L"model_type", ModelTypeToString(it->first)); | 771 val->SetString(L"model_type", ModelTypeToString(it->first)); |
770 val->SetString(L"group", ModelSafeGroupToString(it->second)); | 772 val->SetString(L"group", ModelSafeGroupToString(it->second)); |
771 routing_info->Append(val); | 773 routing_info->Append(val); |
772 } | 774 } |
773 } | 775 } |
774 | 776 |
775 static const base::StringPiece sync_html( | 777 static const base::StringPiece sync_html( |
776 ResourceBundle::GetSharedInstance().GetRawDataResource( | 778 ResourceBundle::GetSharedInstance().GetRawDataResource( |
777 IDR_ABOUT_SYNC_HTML)); | 779 IDR_ABOUT_SYNC_HTML)); |
778 | 780 |
779 return jstemplate_builder::GetTemplateHtml( | 781 return jstemplate_builder::GetTemplateHtml( |
780 sync_html, &strings , "t" /* template root node id */); | 782 sync_html, &strings , "t" /* template root node id */); |
781 } | 783 } |
782 | 784 |
783 #if defined(OS_CHROMEOS) | 785 #if defined(OS_CHROMEOS) |
784 std::string AboutSys() { | 786 std::string AboutSys() { |
785 DictionaryValue strings; | 787 DictionaryValue strings; |
786 chromeos::SyslogsLibrary* syslogs_lib = | 788 chromeos::SyslogsLibrary* syslogs_lib = |
787 chromeos::CrosLibrary::Get()->GetSyslogsLibrary(); | 789 chromeos::CrosLibrary::Get()->GetSyslogsLibrary(); |
788 scoped_ptr<chromeos::LogDictionaryType> sys_info_; | 790 scoped_ptr<chromeos::LogDictionaryType> sys_info_; |
789 if (syslogs_lib) | 791 if (syslogs_lib) |
790 sys_info_.reset(syslogs_lib->GetSyslogs(new FilePath())); | 792 sys_info_.reset(syslogs_lib->GetSyslogs(new FilePath())); |
791 if (sys_info_.get()) { | 793 if (sys_info_.get()) { |
792 ListValue* details = new ListValue(); | 794 ListValue* details = new ListValue(); |
793 strings.Set(L"details", details); | 795 strings.Set("details", details); |
794 chromeos::LogDictionaryType::iterator it; | 796 chromeos::LogDictionaryType::iterator it; |
795 | 797 |
796 for (it = sys_info_.get()->begin(); it != sys_info_.get()->end(); ++it) { | 798 for (it = sys_info_.get()->begin(); it != sys_info_.get()->end(); ++it) { |
797 DictionaryValue* val = new DictionaryValue; | 799 DictionaryValue* val = new DictionaryValue; |
798 val->SetString(L"stat_name", (*it).first); | 800 val->SetString(L"stat_name", (*it).first); |
799 val->SetString(L"stat_value", (*it).second); | 801 val->SetString(L"stat_value", (*it).second); |
800 details->Append(val); | 802 details->Append(val); |
801 } | 803 } |
802 } | 804 } |
803 static const base::StringPiece sys_html( | 805 static const base::StringPiece sys_html( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 // AboutMemoryHandler ---------------------------------------------------------- | 915 // AboutMemoryHandler ---------------------------------------------------------- |
914 | 916 |
915 // Helper for AboutMemory to bind results from a ProcessMetrics object | 917 // Helper for AboutMemory to bind results from a ProcessMetrics object |
916 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects | 918 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects |
917 // can be used in caller's scope (e.g for appending to a net total). | 919 // can be used in caller's scope (e.g for appending to a net total). |
918 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, | 920 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, |
919 ProcessMemoryInformation* info) { | 921 ProcessMemoryInformation* info) { |
920 DCHECK(data && info); | 922 DCHECK(data && info); |
921 | 923 |
922 // Bind metrics to dictionary. | 924 // Bind metrics to dictionary. |
923 data->SetInteger(L"ws_priv", static_cast<int>(info->working_set.priv)); | 925 data->SetInteger("ws_priv", static_cast<int>(info->working_set.priv)); |
924 data->SetInteger(L"ws_shareable", | 926 data->SetInteger("ws_shareable", |
925 static_cast<int>(info->working_set.shareable)); | 927 static_cast<int>(info->working_set.shareable)); |
926 data->SetInteger(L"ws_shared", static_cast<int>(info->working_set.shared)); | 928 data->SetInteger("ws_shared", static_cast<int>(info->working_set.shared)); |
927 data->SetInteger(L"comm_priv", static_cast<int>(info->committed.priv)); | 929 data->SetInteger("comm_priv", static_cast<int>(info->committed.priv)); |
928 data->SetInteger(L"comm_map", static_cast<int>(info->committed.mapped)); | 930 data->SetInteger("comm_map", static_cast<int>(info->committed.mapped)); |
929 data->SetInteger(L"comm_image", static_cast<int>(info->committed.image)); | 931 data->SetInteger("comm_image", static_cast<int>(info->committed.image)); |
930 data->SetInteger(L"pid", info->pid); | 932 data->SetInteger("pid", info->pid); |
931 data->SetString(L"version", info->version); | 933 data->SetString("version", WideToUTF16Hack(info->version)); |
932 data->SetInteger(L"processes", info->num_processes); | 934 data->SetInteger("processes", info->num_processes); |
933 } | 935 } |
934 | 936 |
935 // Helper for AboutMemory to append memory usage information for all | 937 // Helper for AboutMemory to append memory usage information for all |
936 // sub-processes (i.e. renderers, plugins) used by Chrome. | 938 // sub-processes (i.e. renderers, plugins) used by Chrome. |
937 void AboutMemoryHandler::AppendProcess(ListValue* child_data, | 939 void AboutMemoryHandler::AppendProcess(ListValue* child_data, |
938 ProcessMemoryInformation* info) { | 940 ProcessMemoryInformation* info) { |
939 DCHECK(child_data && info); | 941 DCHECK(child_data && info); |
940 | 942 |
941 // Append a new DictionaryValue for this renderer to our list. | 943 // Append a new DictionaryValue for this renderer to our list. |
942 DictionaryValue* child = new DictionaryValue(); | 944 DictionaryValue* child = new DictionaryValue(); |
943 child_data->Append(child); | 945 child_data->Append(child); |
944 BindProcessMetrics(child, info); | 946 BindProcessMetrics(child, info); |
945 | 947 |
946 std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type)); | 948 std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type)); |
947 if (info->is_diagnostics) | 949 if (info->is_diagnostics) |
948 child_label.append(L" (diagnostics)"); | 950 child_label.append(L" (diagnostics)"); |
949 child->SetString(L"child_name", child_label); | 951 child->SetString("child_name", WideToUTF16Hack(child_label)); |
950 ListValue* titles = new ListValue(); | 952 ListValue* titles = new ListValue(); |
951 child->Set(L"titles", titles); | 953 child->Set("titles", titles); |
952 for (size_t i = 0; i < info->titles.size(); ++i) | 954 for (size_t i = 0; i < info->titles.size(); ++i) |
953 titles->Append(new StringValue(info->titles[i])); | 955 titles->Append(new StringValue(info->titles[i])); |
954 } | 956 } |
955 | 957 |
956 | 958 |
957 void AboutMemoryHandler::OnDetailsAvailable() { | 959 void AboutMemoryHandler::OnDetailsAvailable() { |
958 // the root of the JSON hierarchy for about:memory jstemplate | 960 // the root of the JSON hierarchy for about:memory jstemplate |
959 DictionaryValue root; | 961 DictionaryValue root; |
960 ListValue* browsers = new ListValue(); | 962 ListValue* browsers = new ListValue(); |
961 root.Set(L"browsers", browsers); | 963 root.Set("browsers", browsers); |
962 | 964 |
963 const std::vector<ProcessData>& browser_processes = processes(); | 965 const std::vector<ProcessData>& browser_processes = processes(); |
964 | 966 |
965 // Aggregate per-process data into browser summary data. | 967 // Aggregate per-process data into browser summary data. |
966 std::wstring log_string; | 968 std::wstring log_string; |
967 for (size_t index = 0; index < browser_processes.size(); index++) { | 969 for (size_t index = 0; index < browser_processes.size(); index++) { |
968 if (browser_processes[index].processes.size() == 0) | 970 if (browser_processes[index].processes.size() == 0) |
969 continue; | 971 continue; |
970 | 972 |
971 // Sum the information for the processes within this browser. | 973 // Sum the information for the processes within this browser. |
(...skipping 10 matching lines...) Expand all Loading... |
982 aggregate.working_set.shareable += iterator->working_set.shareable; | 984 aggregate.working_set.shareable += iterator->working_set.shareable; |
983 aggregate.committed.priv += iterator->committed.priv; | 985 aggregate.committed.priv += iterator->committed.priv; |
984 aggregate.committed.mapped += iterator->committed.mapped; | 986 aggregate.committed.mapped += iterator->committed.mapped; |
985 aggregate.committed.image += iterator->committed.image; | 987 aggregate.committed.image += iterator->committed.image; |
986 aggregate.num_processes++; | 988 aggregate.num_processes++; |
987 } | 989 } |
988 ++iterator; | 990 ++iterator; |
989 } | 991 } |
990 DictionaryValue* browser_data = new DictionaryValue(); | 992 DictionaryValue* browser_data = new DictionaryValue(); |
991 browsers->Append(browser_data); | 993 browsers->Append(browser_data); |
992 browser_data->SetString(L"name", browser_processes[index].name); | 994 browser_data->SetString("name", |
| 995 WideToUTF16Hack(browser_processes[index].name)); |
993 | 996 |
994 BindProcessMetrics(browser_data, &aggregate); | 997 BindProcessMetrics(browser_data, &aggregate); |
995 | 998 |
996 // We log memory info as we record it. | 999 // We log memory info as we record it. |
997 if (log_string.length() > 0) | 1000 if (log_string.length() > 0) |
998 log_string.append(L", "); | 1001 log_string.append(L", "); |
999 log_string.append(browser_processes[index].name); | 1002 log_string.append(browser_processes[index].name); |
1000 log_string.append(L", "); | 1003 log_string.append(L", "); |
1001 log_string.append(UTF8ToWide( | 1004 log_string.append(UTF8ToWide( |
1002 base::Int64ToString(aggregate.working_set.priv))); | 1005 base::Int64ToString(aggregate.working_set.priv))); |
1003 log_string.append(L", "); | 1006 log_string.append(L", "); |
1004 log_string.append(UTF8ToWide( | 1007 log_string.append(UTF8ToWide( |
1005 base::Int64ToString(aggregate.working_set.shared))); | 1008 base::Int64ToString(aggregate.working_set.shared))); |
1006 log_string.append(L", "); | 1009 log_string.append(L", "); |
1007 log_string.append(UTF8ToWide( | 1010 log_string.append(UTF8ToWide( |
1008 base::Int64ToString(aggregate.working_set.shareable))); | 1011 base::Int64ToString(aggregate.working_set.shareable))); |
1009 } | 1012 } |
1010 if (log_string.length() > 0) | 1013 if (log_string.length() > 0) |
1011 LOG(INFO) << "memory: " << log_string; | 1014 LOG(INFO) << "memory: " << log_string; |
1012 | 1015 |
1013 // Set the browser & renderer detailed process data. | 1016 // Set the browser & renderer detailed process data. |
1014 DictionaryValue* browser_data = new DictionaryValue(); | 1017 DictionaryValue* browser_data = new DictionaryValue(); |
1015 root.Set(L"browzr_data", browser_data); | 1018 root.Set("browzr_data", browser_data); |
1016 ListValue* child_data = new ListValue(); | 1019 ListValue* child_data = new ListValue(); |
1017 root.Set(L"child_data", child_data); | 1020 root.Set("child_data", child_data); |
1018 | 1021 |
1019 ProcessData process = browser_processes[0]; // Chrome is the first browser. | 1022 ProcessData process = browser_processes[0]; // Chrome is the first browser. |
1020 root.SetString(L"current_browser_name", process.name); | 1023 root.SetString("current_browser_name", WideToUTF16Hack(process.name)); |
1021 | 1024 |
1022 for (size_t index = 0; index < process.processes.size(); index++) { | 1025 for (size_t index = 0; index < process.processes.size(); index++) { |
1023 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) | 1026 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) |
1024 BindProcessMetrics(browser_data, &process.processes[index]); | 1027 BindProcessMetrics(browser_data, &process.processes[index]); |
1025 else | 1028 else |
1026 AppendProcess(child_data, &process.processes[index]); | 1029 AppendProcess(child_data, &process.processes[index]); |
1027 } | 1030 } |
1028 | 1031 |
1029 root.SetBoolean(L"show_other_browsers", | 1032 root.SetBoolean("show_other_browsers", |
1030 browser_defaults::kShowOtherBrowsersInAboutMemory); | 1033 browser_defaults::kShowOtherBrowsersInAboutMemory); |
1031 | 1034 |
1032 // Get about_memory.html | 1035 // Get about_memory.html |
1033 static const base::StringPiece memory_html( | 1036 static const base::StringPiece memory_html( |
1034 ResourceBundle::GetSharedInstance().GetRawDataResource( | 1037 ResourceBundle::GetSharedInstance().GetRawDataResource( |
1035 IDR_ABOUT_MEMORY_HTML)); | 1038 IDR_ABOUT_MEMORY_HTML)); |
1036 | 1039 |
1037 // Create jstemplate and return. | 1040 // Create jstemplate and return. |
1038 std::string template_html = jstemplate_builder::GetTemplateHtml( | 1041 std::string template_html = jstemplate_builder::GetTemplateHtml( |
1039 memory_html, &root, "t" /* template root node id */); | 1042 memory_html, &root, "t" /* template root node id */); |
1040 | 1043 |
1041 source_->FinishDataRequest(template_html, request_id_); | 1044 source_->FinishDataRequest(template_html, request_id_); |
1042 } | 1045 } |
1043 | 1046 |
1044 #if defined(OS_CHROMEOS) | 1047 #if defined(OS_CHROMEOS) |
1045 // ChromeOSAboutVersionHandler ----------------------------------------------- | 1048 // ChromeOSAboutVersionHandler ----------------------------------------------- |
1046 | 1049 |
1047 ChromeOSAboutVersionHandler::ChromeOSAboutVersionHandler(AboutSource* source, | 1050 ChromeOSAboutVersionHandler::ChromeOSAboutVersionHandler(AboutSource* source, |
1048 int request_id) | 1051 int request_id) |
1049 : source_(source), | 1052 : source_(source), |
1050 request_id_(request_id) { | 1053 request_id_(request_id) { |
1051 loader_.GetVersion(&consumer_, | 1054 loader_.GetVersion(&consumer_, |
1052 NewCallback(this, &ChromeOSAboutVersionHandler::OnVersion)); | 1055 NewCallback(this, &ChromeOSAboutVersionHandler::OnVersion)); |
1053 } | 1056 } |
1054 | 1057 |
1055 void ChromeOSAboutVersionHandler::OnVersion( | 1058 void ChromeOSAboutVersionHandler::OnVersion( |
1056 chromeos::VersionLoader::Handle handle, | 1059 chromeos::VersionLoader::Handle handle, |
1057 std::string version) { | 1060 std::string version) { |
1058 DictionaryValue localized_strings; | 1061 DictionaryValue localized_strings; |
1059 localized_strings.SetString(L"os_name", | 1062 localized_strings.SetString("os_name", |
1060 l10n_util::GetString(IDS_PRODUCT_OS_NAME)); | 1063 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)); |
1061 localized_strings.SetString(L"os_version", UTF8ToWide(version)); | 1064 localized_strings.SetString("os_version", version); |
1062 localized_strings.SetBoolean(L"is_chrome_os", true); | 1065 localized_strings.SetBoolean("is_chrome_os", true); |
1063 source_->FinishDataRequest(AboutVersion(&localized_strings), request_id_); | 1066 source_->FinishDataRequest(AboutVersion(&localized_strings), request_id_); |
1064 | 1067 |
1065 // CancelableRequestProvider isn't happy when it's deleted and servicing a | 1068 // CancelableRequestProvider isn't happy when it's deleted and servicing a |
1066 // task, so we delay the deletion. | 1069 // task, so we delay the deletion. |
1067 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1070 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1068 } | 1071 } |
1069 | 1072 |
1070 #endif | 1073 #endif |
1071 | 1074 |
1072 // Returns true if |url|'s spec starts with |about_specifier|, and is | 1075 // Returns true if |url|'s spec starts with |about_specifier|, and is |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 // Run the dialog. This will re-use the existing one if it's already up. | 1177 // Run the dialog. This will re-use the existing one if it's already up. |
1175 AboutIPCDialog::RunDialog(); | 1178 AboutIPCDialog::RunDialog(); |
1176 return true; | 1179 return true; |
1177 } | 1180 } |
1178 #endif | 1181 #endif |
1179 | 1182 |
1180 #endif // OFFICIAL_BUILD | 1183 #endif // OFFICIAL_BUILD |
1181 | 1184 |
1182 return false; | 1185 return false; |
1183 } | 1186 } |
OLD | NEW |