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 @@
<h1>Drive Internals</h1>
<ul id='toc'></ul>
<h2 id='authentication-status-section'>Authentication Status</h2>
<h2 id='connection-status-section'>Connection Status</h2>
<ul>
<li>
Status: <span id='connection-status'></span>
</li>
<li>
Has refresh token: <span id='has-refresh-token'></span>
<button id='button-clear-refresh-token'>clear</button>
......
......@@ -35,12 +35,13 @@ function updateDriveRelatedPreferences(preferences) {
}
/**
* Updates the Authentication Status section.
* @param {Object} authStatus Dictionary containing auth status.
* Updates the Connection Status section.
* @param {Object} connStatus Dictionary containing connection status.
*/
function updateAuthStatus(authStatus) {
$('has-refresh-token').textContent = authStatus['has-refresh-token'];
$('has-access-token').textContent = authStatus['has-access-token'];
function updateConnectionStatus(connStatus) {
$('connection-status').textContent = connStatus['status'];
$('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 {
// Updates respective sections.
void UpdateDriveRelatedFlagsSection();
void UpdateDriveRelatedPreferencesSection();
void UpdateAuthStatusSection(
void UpdateConnectionStatusSection(
drive::DriveServiceInterface* drive_service);
void UpdateAboutResourceSection(
drive::DriveServiceInterface* drive_service);
......@@ -427,7 +427,7 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
UpdateDriveRelatedFlagsSection();
UpdateDriveRelatedPreferencesSection();
UpdateAuthStatusSection(drive_service);
UpdateConnectionStatusSection(drive_service);
UpdateAboutResourceSection(drive_service);
UpdateAppListSection(drive_service);
UpdateLocalMetadataSection(debug_info_collector);
......@@ -496,17 +496,37 @@ void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() {
preferences);
}
void DriveInternalsWebUIHandler::UpdateAuthStatusSection(
void DriveInternalsWebUIHandler::UpdateConnectionStatusSection(
drive::DriveServiceInterface* drive_service) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(drive_service);
base::DictionaryValue auth_status;
auth_status.SetBoolean("has-refresh-token",
drive_service->HasRefreshToken());
auth_status.SetBoolean("has-access-token",
drive_service->HasAccessToken());
web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status);
std::string status;
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());
connection_status.SetBoolean("has-access-token",
drive_service->HasAccessToken());
web_ui()->CallJavascriptFunction("updateConnectionStatus", connection_status);
}
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