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

Add 'Clear local data and reload' button in chrome:drive-internals.

BUG=298789
R=satorux@chromium.org, yoshiki@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233445 0039d316-1c4b-4281-b951-d872f2087c98
parent 5d78fe6a
...@@ -33,6 +33,12 @@ ...@@ -33,6 +33,12 @@
</ul> </ul>
<h2 id='local-metadata-section'>Local Metadata</h2> <h2 id='local-metadata-section'>Local Metadata</h2>
<div>
<button id='button-reload-drive-filesystem'>
Clear local data and reload
</button>
<span id='reload-status-text'></span>
</div>
<ul> <ul>
<li>Local Changestamp: <li>Local Changestamp:
<span id='account-largest-changestamp-local'></span> <span id='account-largest-changestamp-local'></span>
......
...@@ -251,6 +251,14 @@ function updateKeyValueList(ul, list) { ...@@ -251,6 +251,14 @@ function updateKeyValueList(ul, list) {
} }
} }
/**
* Updates the text next to the 'reload' button to update the status.
* @param {boolean} success whether or not reloading has succeeded.
*/
function updateReloadStatus(success) {
$('reload-status-text').textContent = (success ? 'success' : 'failed');
}
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
chrome.send('pageLoaded'); chrome.send('pageLoaded');
...@@ -274,6 +282,11 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -274,6 +282,11 @@ document.addEventListener('DOMContentLoaded', function() {
chrome.send('clearRefreshToken'); chrome.send('clearRefreshToken');
}); });
$('button-reload-drive-filesystem').addEventListener('click', function() {
$('reload-status-text').textContent = 'reloading...';
chrome.send('reloadDriveFileSystem');
});
$('button-show-file-entries').addEventListener('click', function() { $('button-show-file-entries').addEventListener('click', function() {
var button = $('button-show-file-entries'); var button = $('button-show-file-entries');
button.parentNode.removeChild(button); button.parentNode.removeChild(button);
......
...@@ -286,11 +286,15 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -286,11 +286,15 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
// Called when the page requests periodic update. // Called when the page requests periodic update.
void OnPeriodicUpdate(const base::ListValue* args); void OnPeriodicUpdate(const base::ListValue* args);
// Called when the corresponding button on the page is pressed.
void ClearAccessToken(const base::ListValue* args); void ClearAccessToken(const base::ListValue* args);
void ClearRefreshToken(const base::ListValue* args); void ClearRefreshToken(const base::ListValue* args);
void ReloadDriveFileSystem(const base::ListValue* args);
void ListFileEntries(const base::ListValue* args); void ListFileEntries(const base::ListValue* args);
// Called after file system reload for ReloadDriveFileSystem is done.
void ReloadFinished(bool success);
// The last event sent to the JavaScript side. // The last event sent to the JavaScript side.
int last_sent_event_id_; int last_sent_event_id_;
...@@ -369,6 +373,10 @@ void DriveInternalsWebUIHandler::RegisterMessages() { ...@@ -369,6 +373,10 @@ void DriveInternalsWebUIHandler::RegisterMessages() {
"clearRefreshToken", "clearRefreshToken",
base::Bind(&DriveInternalsWebUIHandler::ClearRefreshToken, base::Bind(&DriveInternalsWebUIHandler::ClearRefreshToken,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
"reloadDriveFileSystem",
base::Bind(&DriveInternalsWebUIHandler::ReloadDriveFileSystem,
weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"listFileEntries", "listFileEntries",
base::Bind(&DriveInternalsWebUIHandler::ListFileEntries, base::Bind(&DriveInternalsWebUIHandler::ListFileEntries,
...@@ -559,6 +567,26 @@ void DriveInternalsWebUIHandler::ClearRefreshToken( ...@@ -559,6 +567,26 @@ void DriveInternalsWebUIHandler::ClearRefreshToken(
drive_service->ClearRefreshToken(); drive_service->ClearRefreshToken();
} }
void DriveInternalsWebUIHandler::ReloadDriveFileSystem(
const base::ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
drive::DriveIntegrationService* integration_service =
GetIntegrationService();
if (integration_service) {
integration_service->ClearCacheAndRemountFileSystem(
base::Bind(&DriveInternalsWebUIHandler::ReloadFinished,
weak_ptr_factory_.GetWeakPtr()));
}
}
void DriveInternalsWebUIHandler::ReloadFinished(bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
web_ui()->CallJavascriptFunction("updateReloadStatus",
base::FundamentalValue(success));
}
void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) { void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......
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