Commit 9cb0ff30 authored by kinaba@chromium.org's avatar kinaba@chromium.org

Add Drive connection status info to chrome:drive-internals.

BUG=237427

Review URL: https://codereview.chromium.org/98583002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238365 0039d316-1c4b-4281-b951-d872f2087c98
parent dfa24b4c
...@@ -11,8 +11,11 @@ ...@@ -11,8 +11,11 @@
<h1>Drive Internals</h1> <h1>Drive Internals</h1>
<ul id='toc'></ul> <ul id='toc'></ul>
<h2 id='authentication-status-section'>Authentication Status</h2> <h2 id='connection-status-section'>Connection Status</h2>
<ul> <ul>
<li>
Status: <span id='connection-status'></span>
</li>
<li> <li>
Has refresh token: <span id='has-refresh-token'></span> Has refresh token: <span id='has-refresh-token'></span>
<button id='button-clear-refresh-token'>clear</button> <button id='button-clear-refresh-token'>clear</button>
......
...@@ -35,12 +35,13 @@ function updateDriveRelatedPreferences(preferences) { ...@@ -35,12 +35,13 @@ function updateDriveRelatedPreferences(preferences) {
} }
/** /**
* Updates the Authentication Status section. * Updates the Connection Status section.
* @param {Object} authStatus Dictionary containing auth status. * @param {Object} connStatus Dictionary containing connection status.
*/ */
function updateAuthStatus(authStatus) { function updateConnectionStatus(connStatus) {
$('has-refresh-token').textContent = authStatus['has-refresh-token']; $('connection-status').textContent = connStatus['status'];
$('has-access-token').textContent = authStatus['has-access-token']; $('has-refresh-token').textContent = connStatus['has-refresh-token'];
$('has-access-token').textContent = connStatus['has-access-token'];
} }
/** /**
......
...@@ -226,7 +226,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -226,7 +226,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
// Updates respective sections. // Updates respective sections.
void UpdateDriveRelatedFlagsSection(); void UpdateDriveRelatedFlagsSection();
void UpdateDriveRelatedPreferencesSection(); void UpdateDriveRelatedPreferencesSection();
void UpdateAuthStatusSection( void UpdateConnectionStatusSection(
drive::DriveServiceInterface* drive_service); drive::DriveServiceInterface* drive_service);
void UpdateAboutResourceSection( void UpdateAboutResourceSection(
drive::DriveServiceInterface* drive_service); drive::DriveServiceInterface* drive_service);
...@@ -427,7 +427,7 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { ...@@ -427,7 +427,7 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
UpdateDriveRelatedFlagsSection(); UpdateDriveRelatedFlagsSection();
UpdateDriveRelatedPreferencesSection(); UpdateDriveRelatedPreferencesSection();
UpdateAuthStatusSection(drive_service); UpdateConnectionStatusSection(drive_service);
UpdateAboutResourceSection(drive_service); UpdateAboutResourceSection(drive_service);
UpdateAppListSection(drive_service); UpdateAppListSection(drive_service);
UpdateLocalMetadataSection(debug_info_collector); UpdateLocalMetadataSection(debug_info_collector);
...@@ -496,17 +496,37 @@ void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() { ...@@ -496,17 +496,37 @@ void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() {
preferences); preferences);
} }
void DriveInternalsWebUIHandler::UpdateAuthStatusSection( void DriveInternalsWebUIHandler::UpdateConnectionStatusSection(
drive::DriveServiceInterface* drive_service) { drive::DriveServiceInterface* drive_service) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(drive_service); DCHECK(drive_service);
base::DictionaryValue auth_status; std::string status;
auth_status.SetBoolean("has-refresh-token", switch (drive::util::GetDriveConnectionStatus(Profile::FromWebUI(web_ui()))) {
case drive::util::DRIVE_DISCONNECTED_NOSERVICE:
status = "no service";
break;
case drive::util::DRIVE_DISCONNECTED_NONETWORK:
status = "no network";
break;
case drive::util::DRIVE_DISCONNECTED_NOTREADY:
status = "not ready";
break;
case drive::util::DRIVE_CONNECTED_METERED:
status = "metered";
break;
case drive::util::DRIVE_CONNECTED:
status = "connected";
break;
}
base::DictionaryValue connection_status;
connection_status.SetString("status", status);
connection_status.SetBoolean("has-refresh-token",
drive_service->HasRefreshToken()); drive_service->HasRefreshToken());
auth_status.SetBoolean("has-access-token", connection_status.SetBoolean("has-access-token",
drive_service->HasAccessToken()); drive_service->HasAccessToken());
web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status); web_ui()->CallJavascriptFunction("updateConnectionStatus", connection_status);
} }
void DriveInternalsWebUIHandler::UpdateAboutResourceSection( void DriveInternalsWebUIHandler::UpdateAboutResourceSection(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment