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

Side by Side Diff: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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/chromeos/drive_internals_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 base::DictionaryValue about_resource; 325 base::DictionaryValue about_resource;
326 about_resource.SetDouble("account-quota-total", 326 about_resource.SetDouble("account-quota-total",
327 parsed_about_resource->quota_bytes_total()); 327 parsed_about_resource->quota_bytes_total());
328 about_resource.SetDouble("account-quota-used", 328 about_resource.SetDouble("account-quota-used",
329 parsed_about_resource->quota_bytes_used_aggregate()); 329 parsed_about_resource->quota_bytes_used_aggregate());
330 about_resource.SetDouble("account-largest-changestamp-remote", 330 about_resource.SetDouble("account-largest-changestamp-remote",
331 parsed_about_resource->largest_change_id()); 331 parsed_about_resource->largest_change_id());
332 about_resource.SetString("root-resource-id", 332 about_resource.SetString("root-resource-id",
333 parsed_about_resource->root_folder_id()); 333 parsed_about_resource->root_folder_id());
334 334
335 web_ui()->CallJavascriptFunction("updateAboutResource", about_resource); 335 web_ui()->CallJavascriptFunctionUnsafe("updateAboutResource", about_resource);
336 } 336 }
337 337
338 void DriveInternalsWebUIHandler::OnGetAppList( 338 void DriveInternalsWebUIHandler::OnGetAppList(
339 google_apis::DriveApiErrorCode status, 339 google_apis::DriveApiErrorCode status,
340 std::unique_ptr<google_apis::AppList> parsed_app_list) { 340 std::unique_ptr<google_apis::AppList> parsed_app_list) {
341 DCHECK_CURRENTLY_ON(BrowserThread::UI); 341 DCHECK_CURRENTLY_ON(BrowserThread::UI);
342 342
343 if (status != google_apis::HTTP_SUCCESS) { 343 if (status != google_apis::HTTP_SUCCESS) {
344 LOG(ERROR) << "Failed to get app list"; 344 LOG(ERROR) << "Failed to get app list";
345 return; 345 return;
346 } 346 }
347 DCHECK(parsed_app_list); 347 DCHECK(parsed_app_list);
348 348
349 base::DictionaryValue app_list; 349 base::DictionaryValue app_list;
350 app_list.SetString("etag", parsed_app_list->etag()); 350 app_list.SetString("etag", parsed_app_list->etag());
351 351
352 base::ListValue* items = new base::ListValue(); 352 base::ListValue* items = new base::ListValue();
353 for (size_t i = 0; i < parsed_app_list->items().size(); ++i) { 353 for (size_t i = 0; i < parsed_app_list->items().size(); ++i) {
354 const google_apis::AppResource* app = parsed_app_list->items()[i]; 354 const google_apis::AppResource* app = parsed_app_list->items()[i];
355 base::DictionaryValue* app_data = new base::DictionaryValue(); 355 base::DictionaryValue* app_data = new base::DictionaryValue();
356 app_data->SetString("name", app->name()); 356 app_data->SetString("name", app->name());
357 app_data->SetString("application_id", app->application_id()); 357 app_data->SetString("application_id", app->application_id());
358 app_data->SetString("object_type", app->object_type()); 358 app_data->SetString("object_type", app->object_type());
359 app_data->SetBoolean("supports_create", app->supports_create()); 359 app_data->SetBoolean("supports_create", app->supports_create());
360 360
361 items->Append(app_data); 361 items->Append(app_data);
362 } 362 }
363 app_list.Set("items", items); 363 app_list.Set("items", items);
364 364
365 web_ui()->CallJavascriptFunction("updateAppList", app_list); 365 web_ui()->CallJavascriptFunctionUnsafe("updateAppList", app_list);
366 } 366 }
367 367
368 void DriveInternalsWebUIHandler::RegisterMessages() { 368 void DriveInternalsWebUIHandler::RegisterMessages() {
369 web_ui()->RegisterMessageCallback( 369 web_ui()->RegisterMessageCallback(
370 "pageLoaded", 370 "pageLoaded",
371 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, 371 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded,
372 weak_ptr_factory_.GetWeakPtr())); 372 weak_ptr_factory_.GetWeakPtr()));
373 web_ui()->RegisterMessageCallback( 373 web_ui()->RegisterMessageCallback(
374 "periodicUpdate", 374 "periodicUpdate",
375 base::Bind(&DriveInternalsWebUIHandler::OnPeriodicUpdate, 375 base::Bind(&DriveInternalsWebUIHandler::OnPeriodicUpdate,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 base::ListValue preferences; 470 base::ListValue preferences;
471 for (size_t i = 0; i < arraysize(kDriveRelatedPreferences); ++i) { 471 for (size_t i = 0; i < arraysize(kDriveRelatedPreferences); ++i) {
472 const std::string key = kDriveRelatedPreferences[i]; 472 const std::string key = kDriveRelatedPreferences[i];
473 // As of now, all preferences are boolean. 473 // As of now, all preferences are boolean.
474 const std::string value = 474 const std::string value =
475 (pref_service->GetBoolean(key.c_str()) ? "true" : "false"); 475 (pref_service->GetBoolean(key.c_str()) ? "true" : "false");
476 AppendKeyValue(&preferences, key, value); 476 AppendKeyValue(&preferences, key, value);
477 } 477 }
478 478
479 web_ui()->CallJavascriptFunction("updateDriveRelatedPreferences", 479 web_ui()->CallJavascriptFunctionUnsafe("updateDriveRelatedPreferences",
480 preferences); 480 preferences);
481 } 481 }
482 482
483 void DriveInternalsWebUIHandler::UpdateConnectionStatusSection( 483 void DriveInternalsWebUIHandler::UpdateConnectionStatusSection(
484 drive::DriveServiceInterface* drive_service) { 484 drive::DriveServiceInterface* drive_service) {
485 DCHECK_CURRENTLY_ON(BrowserThread::UI); 485 DCHECK_CURRENTLY_ON(BrowserThread::UI);
486 DCHECK(drive_service); 486 DCHECK(drive_service);
487 487
488 std::string status; 488 std::string status;
489 switch (drive::util::GetDriveConnectionStatus(Profile::FromWebUI(web_ui()))) { 489 switch (drive::util::GetDriveConnectionStatus(Profile::FromWebUI(web_ui()))) {
490 case drive::util::DRIVE_DISCONNECTED_NOSERVICE: 490 case drive::util::DRIVE_DISCONNECTED_NOSERVICE:
(...skipping 12 matching lines...) Expand all
503 status = "connected"; 503 status = "connected";
504 break; 504 break;
505 } 505 }
506 506
507 base::DictionaryValue connection_status; 507 base::DictionaryValue connection_status;
508 connection_status.SetString("status", status); 508 connection_status.SetString("status", status);
509 connection_status.SetBoolean("has-refresh-token", 509 connection_status.SetBoolean("has-refresh-token",
510 drive_service->HasRefreshToken()); 510 drive_service->HasRefreshToken());
511 connection_status.SetBoolean("has-access-token", 511 connection_status.SetBoolean("has-access-token",
512 drive_service->HasAccessToken()); 512 drive_service->HasAccessToken());
513 web_ui()->CallJavascriptFunction("updateConnectionStatus", connection_status); 513 web_ui()->CallJavascriptFunctionUnsafe("updateConnectionStatus",
514 connection_status);
514 } 515 }
515 516
516 void DriveInternalsWebUIHandler::UpdateAboutResourceSection( 517 void DriveInternalsWebUIHandler::UpdateAboutResourceSection(
517 drive::DriveServiceInterface* drive_service) { 518 drive::DriveServiceInterface* drive_service) {
518 DCHECK_CURRENTLY_ON(BrowserThread::UI); 519 DCHECK_CURRENTLY_ON(BrowserThread::UI);
519 DCHECK(drive_service); 520 DCHECK(drive_service);
520 521
521 drive_service->GetAboutResource( 522 drive_service->GetAboutResource(
522 base::Bind(&DriveInternalsWebUIHandler::OnGetAboutResource, 523 base::Bind(&DriveInternalsWebUIHandler::OnGetAboutResource,
523 weak_ptr_factory_.GetWeakPtr())); 524 weak_ptr_factory_.GetWeakPtr()));
(...skipping 20 matching lines...) Expand all
544 } 545 }
545 546
546 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal( 547 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal(
547 const drive::FileSystemMetadata& metadata) { 548 const drive::FileSystemMetadata& metadata) {
548 DCHECK_CURRENTLY_ON(BrowserThread::UI); 549 DCHECK_CURRENTLY_ON(BrowserThread::UI);
549 550
550 base::DictionaryValue local_metadata; 551 base::DictionaryValue local_metadata;
551 local_metadata.SetDouble("account-largest-changestamp-local", 552 local_metadata.SetDouble("account-largest-changestamp-local",
552 metadata.largest_changestamp); 553 metadata.largest_changestamp);
553 local_metadata.SetBoolean("account-metadata-refreshing", metadata.refreshing); 554 local_metadata.SetBoolean("account-metadata-refreshing", metadata.refreshing);
554 web_ui()->CallJavascriptFunction("updateLocalMetadata", local_metadata); 555 web_ui()->CallJavascriptFunctionUnsafe("updateLocalMetadata", local_metadata);
555 } 556 }
556 557
557 void DriveInternalsWebUIHandler::ClearAccessToken(const base::ListValue* args) { 558 void DriveInternalsWebUIHandler::ClearAccessToken(const base::ListValue* args) {
558 DCHECK_CURRENTLY_ON(BrowserThread::UI); 559 DCHECK_CURRENTLY_ON(BrowserThread::UI);
559 560
560 drive::DriveServiceInterface* drive_service = GetDriveService(); 561 drive::DriveServiceInterface* drive_service = GetDriveService();
561 if (drive_service) 562 if (drive_service)
562 drive_service->ClearAccessToken(); 563 drive_service->ClearAccessToken();
563 } 564 }
564 565
(...skipping 15 matching lines...) Expand all
580 if (integration_service) { 581 if (integration_service) {
581 integration_service->ClearCacheAndRemountFileSystem( 582 integration_service->ClearCacheAndRemountFileSystem(
582 base::Bind(&DriveInternalsWebUIHandler::ResetFinished, 583 base::Bind(&DriveInternalsWebUIHandler::ResetFinished,
583 weak_ptr_factory_.GetWeakPtr())); 584 weak_ptr_factory_.GetWeakPtr()));
584 } 585 }
585 } 586 }
586 587
587 void DriveInternalsWebUIHandler::ResetFinished(bool success) { 588 void DriveInternalsWebUIHandler::ResetFinished(bool success) {
588 DCHECK_CURRENTLY_ON(BrowserThread::UI); 589 DCHECK_CURRENTLY_ON(BrowserThread::UI);
589 590
590 web_ui()->CallJavascriptFunction("updateResetStatus", 591 web_ui()->CallJavascriptFunctionUnsafe("updateResetStatus",
591 base::FundamentalValue(success)); 592 base::FundamentalValue(success));
592 } 593 }
593 594
594 void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) { 595 void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) {
595 DCHECK_CURRENTLY_ON(BrowserThread::UI); 596 DCHECK_CURRENTLY_ON(BrowserThread::UI);
596 597
597 UpdateFileSystemContentsSection(); 598 UpdateFileSystemContentsSection();
598 } 599 }
599 600
600 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection( 601 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection(
601 drive::DebugInfoCollector* debug_info_collector) { 602 drive::DebugInfoCollector* debug_info_collector) {
(...skipping 21 matching lines...) Expand all
623 "push-notification-enabled", 624 "push-notification-enabled",
624 drive_notification_manager->push_notification_enabled()); 625 drive_notification_manager->push_notification_enabled());
625 delta_update_status.SetString( 626 delta_update_status.SetString(
626 "last-update-check-time", 627 "last-update-check-time",
627 google_apis::util::FormatTimeAsStringLocaltime( 628 google_apis::util::FormatTimeAsStringLocaltime(
628 metadata.last_update_check_time)); 629 metadata.last_update_check_time));
629 delta_update_status.SetString( 630 delta_update_status.SetString(
630 "last-update-check-error", 631 "last-update-check-error",
631 drive::FileErrorToString(metadata.last_update_check_error)); 632 drive::FileErrorToString(metadata.last_update_check_error));
632 633
633 web_ui()->CallJavascriptFunction("updateDeltaUpdateStatus", 634 web_ui()->CallJavascriptFunctionUnsafe("updateDeltaUpdateStatus",
634 delta_update_status); 635 delta_update_status);
635 } 636 }
636 637
637 void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection( 638 void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection(
638 drive::JobListInterface* job_list) { 639 drive::JobListInterface* job_list) {
639 DCHECK_CURRENTLY_ON(BrowserThread::UI); 640 DCHECK_CURRENTLY_ON(BrowserThread::UI);
640 DCHECK(job_list); 641 DCHECK(job_list);
641 642
642 std::vector<drive::JobInfo> info_list = job_list->GetJobInfoList(); 643 std::vector<drive::JobInfo> info_list = job_list->GetJobInfoList();
643 644
644 base::ListValue in_flight_operations; 645 base::ListValue in_flight_operations;
645 for (size_t i = 0; i < info_list.size(); ++i) { 646 for (size_t i = 0; i < info_list.size(); ++i) {
646 const drive::JobInfo& info = info_list[i]; 647 const drive::JobInfo& info = info_list[i];
647 648
648 base::DictionaryValue* dict = new base::DictionaryValue; 649 base::DictionaryValue* dict = new base::DictionaryValue;
649 dict->SetInteger("id", info.job_id); 650 dict->SetInteger("id", info.job_id);
650 dict->SetString("type", drive::JobTypeToString(info.job_type)); 651 dict->SetString("type", drive::JobTypeToString(info.job_type));
651 dict->SetString("file_path", info.file_path.AsUTF8Unsafe()); 652 dict->SetString("file_path", info.file_path.AsUTF8Unsafe());
652 dict->SetString("state", drive::JobStateToString(info.state)); 653 dict->SetString("state", drive::JobStateToString(info.state));
653 dict->SetDouble("progress_current", info.num_completed_bytes); 654 dict->SetDouble("progress_current", info.num_completed_bytes);
654 dict->SetDouble("progress_total", info.num_total_bytes); 655 dict->SetDouble("progress_total", info.num_total_bytes);
655 in_flight_operations.Append(dict); 656 in_flight_operations.Append(dict);
656 } 657 }
657 web_ui()->CallJavascriptFunction("updateInFlightOperations", 658 web_ui()->CallJavascriptFunctionUnsafe("updateInFlightOperations",
658 in_flight_operations); 659 in_flight_operations);
659 } 660 }
660 661
661 void DriveInternalsWebUIHandler::UpdateGCacheContentsSection() { 662 void DriveInternalsWebUIHandler::UpdateGCacheContentsSection() {
662 DCHECK_CURRENTLY_ON(BrowserThread::UI); 663 DCHECK_CURRENTLY_ON(BrowserThread::UI);
663 664
664 // Start updating the GCache contents section. 665 // Start updating the GCache contents section.
665 Profile* profile = Profile::FromWebUI(web_ui()); 666 Profile* profile = Profile::FromWebUI(web_ui());
666 const base::FilePath root_path = drive::util::GetCacheRootPath(profile); 667 const base::FilePath root_path = drive::util::GetCacheRootPath(profile);
667 base::ListValue* gcache_contents = new base::ListValue; 668 base::ListValue* gcache_contents = new base::ListValue;
668 base::DictionaryValue* gcache_summary = new base::DictionaryValue; 669 base::DictionaryValue* gcache_summary = new base::DictionaryValue;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 752
752 base::DictionaryValue* dict = new base::DictionaryValue; 753 base::DictionaryValue* dict = new base::DictionaryValue;
753 dict->SetString("key", 754 dict->SetString("key",
754 google_apis::util::FormatTimeAsStringLocaltime(log[i].when)); 755 google_apis::util::FormatTimeAsStringLocaltime(log[i].when));
755 dict->SetString("value", "[" + severity + "] " + log[i].what); 756 dict->SetString("value", "[" + severity + "] " + log[i].what);
756 dict->SetString("class", "log-" + severity); 757 dict->SetString("class", "log-" + severity);
757 list.Append(dict); 758 list.Append(dict);
758 last_sent_event_id_ = log[i].id; 759 last_sent_event_id_ = log[i].id;
759 } 760 }
760 if (!list.empty()) 761 if (!list.empty())
761 web_ui()->CallJavascriptFunction("updateEventLog", list); 762 web_ui()->CallJavascriptFunctionUnsafe("updateEventLog", list);
762 } 763 }
763 764
764 void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() { 765 void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() {
765 DCHECK_CURRENTLY_ON(BrowserThread::UI); 766 DCHECK_CURRENTLY_ON(BrowserThread::UI);
766 767
767 Profile* const profile = Profile::FromWebUI(web_ui()); 768 Profile* const profile = Profile::FromWebUI(web_ui());
768 769
769 base::ListValue paths; 770 base::ListValue paths;
770 771
771 AppendKeyValue( 772 AppendKeyValue(
772 &paths, "Downloads", 773 &paths, "Downloads",
773 file_manager::util::GetDownloadsFolderForProfile(profile).AsUTF8Unsafe()); 774 file_manager::util::GetDownloadsFolderForProfile(profile).AsUTF8Unsafe());
774 AppendKeyValue( 775 AppendKeyValue(
775 &paths, "Drive", 776 &paths, "Drive",
776 drive::util::GetDriveMountPointPath(profile).AsUTF8Unsafe()); 777 drive::util::GetDriveMountPointPath(profile).AsUTF8Unsafe());
777 778
778 const char* kPathPreferences[] = { 779 const char* kPathPreferences[] = {
779 prefs::kSelectFileLastDirectory, 780 prefs::kSelectFileLastDirectory,
780 prefs::kSaveFileDefaultDirectory, 781 prefs::kSaveFileDefaultDirectory,
781 prefs::kDownloadDefaultDirectory, 782 prefs::kDownloadDefaultDirectory,
782 }; 783 };
783 for (size_t i = 0; i < arraysize(kPathPreferences); ++i) { 784 for (size_t i = 0; i < arraysize(kPathPreferences); ++i) {
784 const char* const key = kPathPreferences[i]; 785 const char* const key = kPathPreferences[i];
785 AppendKeyValue(&paths, key, 786 AppendKeyValue(&paths, key,
786 profile->GetPrefs()->GetFilePath(key).AsUTF8Unsafe()); 787 profile->GetPrefs()->GetFilePath(key).AsUTF8Unsafe());
787 } 788 }
788 789
789 web_ui()->CallJavascriptFunction("updatePathConfigurations", paths); 790 web_ui()->CallJavascriptFunctionUnsafe("updatePathConfigurations", paths);
790 } 791 }
791 792
792 void DriveInternalsWebUIHandler::OnGetGCacheContents( 793 void DriveInternalsWebUIHandler::OnGetGCacheContents(
793 base::ListValue* gcache_contents, 794 base::ListValue* gcache_contents,
794 base::DictionaryValue* gcache_summary) { 795 base::DictionaryValue* gcache_summary) {
795 DCHECK_CURRENTLY_ON(BrowserThread::UI); 796 DCHECK_CURRENTLY_ON(BrowserThread::UI);
796 DCHECK(gcache_contents); 797 DCHECK(gcache_contents);
797 DCHECK(gcache_summary); 798 DCHECK(gcache_summary);
798 799
799 web_ui()->CallJavascriptFunction("updateGCacheContents", 800 web_ui()->CallJavascriptFunctionUnsafe("updateGCacheContents",
800 *gcache_contents, 801 *gcache_contents, *gcache_summary);
801 *gcache_summary);
802 } 802 }
803 803
804 void DriveInternalsWebUIHandler::OnGetResourceEntryByPath( 804 void DriveInternalsWebUIHandler::OnGetResourceEntryByPath(
805 const base::FilePath& path, 805 const base::FilePath& path,
806 drive::FileError error, 806 drive::FileError error,
807 std::unique_ptr<drive::ResourceEntry> entry) { 807 std::unique_ptr<drive::ResourceEntry> entry) {
808 DCHECK_CURRENTLY_ON(BrowserThread::UI); 808 DCHECK_CURRENTLY_ON(BrowserThread::UI);
809 809
810 if (error == drive::FILE_ERROR_OK) { 810 if (error == drive::FILE_ERROR_OK) {
811 DCHECK(entry.get()); 811 DCHECK(entry.get());
812 const base::StringValue value(FormatEntry(path, *entry) + "\n"); 812 const base::StringValue value(FormatEntry(path, *entry) + "\n");
813 web_ui()->CallJavascriptFunction("updateFileSystemContents", value); 813 web_ui()->CallJavascriptFunctionUnsafe("updateFileSystemContents", value);
814 } 814 }
815 } 815 }
816 816
817 void DriveInternalsWebUIHandler::OnReadDirectoryByPath( 817 void DriveInternalsWebUIHandler::OnReadDirectoryByPath(
818 const base::FilePath& parent_path, 818 const base::FilePath& parent_path,
819 drive::FileError error, 819 drive::FileError error,
820 std::unique_ptr<drive::ResourceEntryVector> entries) { 820 std::unique_ptr<drive::ResourceEntryVector> entries) {
821 DCHECK_CURRENTLY_ON(BrowserThread::UI); 821 DCHECK_CURRENTLY_ON(BrowserThread::UI);
822 822
823 if (error == drive::FILE_ERROR_OK) { 823 if (error == drive::FILE_ERROR_OK) {
(...skipping 14 matching lines...) Expand all
838 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, 838 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath,
839 weak_ptr_factory_.GetWeakPtr(), 839 weak_ptr_factory_.GetWeakPtr(),
840 current_path)); 840 current_path));
841 } 841 }
842 } 842 }
843 843
844 // There may be pending ReadDirectoryByPath() calls, but we can update 844 // There may be pending ReadDirectoryByPath() calls, but we can update
845 // the page with what we have now. This results in progressive 845 // the page with what we have now. This results in progressive
846 // updates, which is good for a large file system. 846 // updates, which is good for a large file system.
847 const base::StringValue value(file_system_as_text); 847 const base::StringValue value(file_system_as_text);
848 web_ui()->CallJavascriptFunction("updateFileSystemContents", value); 848 web_ui()->CallJavascriptFunctionUnsafe("updateFileSystemContents", value);
849 } 849 }
850 } 850 }
851 851
852 void DriveInternalsWebUIHandler::UpdateCacheEntry( 852 void DriveInternalsWebUIHandler::UpdateCacheEntry(
853 const std::string& local_id, 853 const std::string& local_id,
854 const drive::FileCacheEntry& cache_entry) { 854 const drive::FileCacheEntry& cache_entry) {
855 DCHECK_CURRENTLY_ON(BrowserThread::UI); 855 DCHECK_CURRENTLY_ON(BrowserThread::UI);
856 856
857 // Convert |cache_entry| into a dictionary. 857 // Convert |cache_entry| into a dictionary.
858 base::DictionaryValue value; 858 base::DictionaryValue value;
859 value.SetString("local_id", local_id); 859 value.SetString("local_id", local_id);
860 value.SetString("md5", cache_entry.md5()); 860 value.SetString("md5", cache_entry.md5());
861 value.SetBoolean("is_present", cache_entry.is_present()); 861 value.SetBoolean("is_present", cache_entry.is_present());
862 value.SetBoolean("is_pinned", cache_entry.is_pinned()); 862 value.SetBoolean("is_pinned", cache_entry.is_pinned());
863 value.SetBoolean("is_dirty", cache_entry.is_dirty()); 863 value.SetBoolean("is_dirty", cache_entry.is_dirty());
864 864
865 web_ui()->CallJavascriptFunction("updateCacheContents", value); 865 web_ui()->CallJavascriptFunctionUnsafe("updateCacheContents", value);
866 } 866 }
867 867
868 void DriveInternalsWebUIHandler::OnGetFreeDiskSpace( 868 void DriveInternalsWebUIHandler::OnGetFreeDiskSpace(
869 base::DictionaryValue* local_storage_summary) { 869 base::DictionaryValue* local_storage_summary) {
870 DCHECK_CURRENTLY_ON(BrowserThread::UI); 870 DCHECK_CURRENTLY_ON(BrowserThread::UI);
871 DCHECK(local_storage_summary); 871 DCHECK(local_storage_summary);
872 872
873 web_ui()->CallJavascriptFunction( 873 web_ui()->CallJavascriptFunctionUnsafe("updateLocalStorageUsage",
874 "updateLocalStorageUsage", *local_storage_summary); 874 *local_storage_summary);
875 } 875 }
876 876
877 void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) { 877 void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) {
878 DCHECK_CURRENTLY_ON(BrowserThread::UI); 878 DCHECK_CURRENTLY_ON(BrowserThread::UI);
879 879
880 drive::DriveIntegrationService* integration_service = 880 drive::DriveIntegrationService* integration_service =
881 GetIntegrationService(); 881 GetIntegrationService();
882 // |integration_service| may be NULL in the guest/incognito mode. 882 // |integration_service| may be NULL in the guest/incognito mode.
883 if (!integration_service) 883 if (!integration_service)
884 return; 884 return;
(...skipping 12 matching lines...) Expand all
897 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); 897 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost);
898 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); 898 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS);
899 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); 899 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
900 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); 900 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML);
901 901
902 Profile* profile = Profile::FromWebUI(web_ui); 902 Profile* profile = Profile::FromWebUI(web_ui);
903 content::WebUIDataSource::Add(profile, source); 903 content::WebUIDataSource::Add(profile, source);
904 } 904 }
905 905
906 } // namespace chromeos 906 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698