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

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

Issue 98583002: Add Drive connection status info to chrome:drive-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 // Returns a FileSystem instance. 220 // Returns a FileSystem instance.
221 drive::FileSystemInterface* GetFileSystem(); 221 drive::FileSystemInterface* GetFileSystem();
222 222
223 // Called when the page is first loaded. 223 // Called when the page is first loaded.
224 void OnPageLoaded(const base::ListValue* args); 224 void OnPageLoaded(const base::ListValue* args);
225 225
226 // Updates respective sections. 226 // Updates respective sections.
227 void UpdateDriveRelatedFlagsSection(); 227 void UpdateDriveRelatedFlagsSection();
228 void UpdateDriveRelatedPreferencesSection(); 228 void UpdateDriveRelatedPreferencesSection();
229 void UpdateAuthStatusSection( 229 void UpdateConnectionStatusSection(
230 drive::DriveServiceInterface* drive_service); 230 drive::DriveServiceInterface* drive_service);
231 void UpdateAboutResourceSection( 231 void UpdateAboutResourceSection(
232 drive::DriveServiceInterface* drive_service); 232 drive::DriveServiceInterface* drive_service);
233 void UpdateAppListSection( 233 void UpdateAppListSection(
234 drive::DriveServiceInterface* drive_service); 234 drive::DriveServiceInterface* drive_service);
235 void UpdateLocalMetadataSection( 235 void UpdateLocalMetadataSection(
236 drive::DebugInfoCollector* debug_info_collector); 236 drive::DebugInfoCollector* debug_info_collector);
237 void UpdateDeltaUpdateStatusSection( 237 void UpdateDeltaUpdateStatusSection(
238 drive::DebugInfoCollector* debug_info_collector); 238 drive::DebugInfoCollector* debug_info_collector);
239 void UpdateInFlightOperationsSection(drive::JobListInterface* job_list); 239 void UpdateInFlightOperationsSection(drive::JobListInterface* job_list);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 drive::DriveServiceInterface* drive_service = 421 drive::DriveServiceInterface* drive_service =
422 integration_service->drive_service(); 422 integration_service->drive_service();
423 DCHECK(drive_service); 423 DCHECK(drive_service);
424 drive::DebugInfoCollector* debug_info_collector = 424 drive::DebugInfoCollector* debug_info_collector =
425 integration_service->debug_info_collector(); 425 integration_service->debug_info_collector();
426 DCHECK(debug_info_collector); 426 DCHECK(debug_info_collector);
427 427
428 UpdateDriveRelatedFlagsSection(); 428 UpdateDriveRelatedFlagsSection();
429 UpdateDriveRelatedPreferencesSection(); 429 UpdateDriveRelatedPreferencesSection();
430 UpdateAuthStatusSection(drive_service); 430 UpdateConnectionStatusSection(drive_service);
431 UpdateAboutResourceSection(drive_service); 431 UpdateAboutResourceSection(drive_service);
432 UpdateAppListSection(drive_service); 432 UpdateAppListSection(drive_service);
433 UpdateLocalMetadataSection(debug_info_collector); 433 UpdateLocalMetadataSection(debug_info_collector);
434 UpdateDeltaUpdateStatusSection(debug_info_collector); 434 UpdateDeltaUpdateStatusSection(debug_info_collector);
435 UpdateInFlightOperationsSection(integration_service->job_list()); 435 UpdateInFlightOperationsSection(integration_service->job_list());
436 UpdateGCacheContentsSection(); 436 UpdateGCacheContentsSection();
437 UpdateCacheContentsSection(debug_info_collector); 437 UpdateCacheContentsSection(debug_info_collector);
438 UpdateLocalStorageUsageSection(); 438 UpdateLocalStorageUsageSection();
439 439
440 // When the drive-internals page is reloaded by the reload key, the page 440 // When the drive-internals page is reloaded by the reload key, the page
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 base::DictionaryValue* preference = new DictionaryValue; 489 base::DictionaryValue* preference = new DictionaryValue;
490 preference->SetString("key", key); 490 preference->SetString("key", key);
491 preference->SetString("value", value); 491 preference->SetString("value", value);
492 preferences.Append(preference); 492 preferences.Append(preference);
493 } 493 }
494 494
495 web_ui()->CallJavascriptFunction("updateDriveRelatedPreferences", 495 web_ui()->CallJavascriptFunction("updateDriveRelatedPreferences",
496 preferences); 496 preferences);
497 } 497 }
498 498
499 void DriveInternalsWebUIHandler::UpdateAuthStatusSection( 499 void DriveInternalsWebUIHandler::UpdateConnectionStatusSection(
500 drive::DriveServiceInterface* drive_service) { 500 drive::DriveServiceInterface* drive_service) {
501 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 501 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
502 DCHECK(drive_service); 502 DCHECK(drive_service);
503 503
504 base::DictionaryValue auth_status; 504 std::string status;
505 auth_status.SetBoolean("has-refresh-token", 505 switch (drive::util::GetDriveConnectionStatus(Profile::FromWebUI(web_ui()))) {
506 drive_service->HasRefreshToken()); 506 case drive::util::DRIVE_DISCONNECTED_NOSERVICE:
507 auth_status.SetBoolean("has-access-token", 507 status = "no service";
508 drive_service->HasAccessToken()); 508 break;
509 web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status); 509 case drive::util::DRIVE_DISCONNECTED_NONETWORK:
510 status = "no network";
511 break;
512 case drive::util::DRIVE_DISCONNECTED_NOTREADY:
513 status = "not ready";
514 break;
515 case drive::util::DRIVE_CONNECTED_METERED:
516 status = "metered";
517 break;
518 case drive::util::DRIVE_CONNECTED:
519 status = "connected";
520 break;
521 }
522
523 base::DictionaryValue connection_status;
524 connection_status.SetString("status", status);
525 connection_status.SetBoolean("has-refresh-token",
526 drive_service->HasRefreshToken());
527 connection_status.SetBoolean("has-access-token",
528 drive_service->HasAccessToken());
529 web_ui()->CallJavascriptFunction("updateConnectionStatus", connection_status);
510 } 530 }
511 531
512 void DriveInternalsWebUIHandler::UpdateAboutResourceSection( 532 void DriveInternalsWebUIHandler::UpdateAboutResourceSection(
513 drive::DriveServiceInterface* drive_service) { 533 drive::DriveServiceInterface* drive_service) {
514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
515 DCHECK(drive_service); 535 DCHECK(drive_service);
516 536
517 drive_service->GetAboutResource( 537 drive_service->GetAboutResource(
518 base::Bind(&DriveInternalsWebUIHandler::OnGetAboutResource, 538 base::Bind(&DriveInternalsWebUIHandler::OnGetAboutResource,
519 weak_ptr_factory_.GetWeakPtr())); 539 weak_ptr_factory_.GetWeakPtr()));
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); 885 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost);
866 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); 886 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS);
867 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); 887 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
868 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); 888 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML);
869 889
870 Profile* profile = Profile::FromWebUI(web_ui); 890 Profile* profile = Profile::FromWebUI(web_ui);
871 content::WebUIDataSource::Add(profile, source); 891 content::WebUIDataSource::Add(profile, source);
872 } 892 }
873 893
874 } // namespace chromeos 894 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698