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

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

Issue 59083013: Add 'Clear local data and reload' button in chrome:drive-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments (#2). Created 7 years, 1 month 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 void OnGetFilesystemMetadataForLocal( 279 void OnGetFilesystemMetadataForLocal(
280 const drive::FileSystemMetadata& metadata); 280 const drive::FileSystemMetadata& metadata);
281 281
282 // Callback for DebugInfoCollector::GetMetadata for delta update. 282 // Callback for DebugInfoCollector::GetMetadata for delta update.
283 void OnGetFilesystemMetadataForDeltaUpdate( 283 void OnGetFilesystemMetadataForDeltaUpdate(
284 const drive::FileSystemMetadata& metadata); 284 const drive::FileSystemMetadata& metadata);
285 285
286 // Called when the page requests periodic update. 286 // Called when the page requests periodic update.
287 void OnPeriodicUpdate(const base::ListValue* args); 287 void OnPeriodicUpdate(const base::ListValue* args);
288 288
289 // Called when the corresponding button on the page is pressed.
289 void ClearAccessToken(const base::ListValue* args); 290 void ClearAccessToken(const base::ListValue* args);
290 void ClearRefreshToken(const base::ListValue* args); 291 void ClearRefreshToken(const base::ListValue* args);
292 void ReloadDriveFileSystem(const base::ListValue* args);
293 void ListFileEntries(const base::ListValue* args);
291 294
292 void ListFileEntries(const base::ListValue* args); 295 // Called after file system reload for ReloadDriveFileSystem is done.
296 void ReloadFinished(bool success);
293 297
294 // The last event sent to the JavaScript side. 298 // The last event sent to the JavaScript side.
295 int last_sent_event_id_; 299 int last_sent_event_id_;
296 300
297 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; 301 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_;
298 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); 302 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler);
299 }; 303 };
300 304
301 void DriveInternalsWebUIHandler::OnGetAboutResource( 305 void DriveInternalsWebUIHandler::OnGetAboutResource(
302 google_apis::GDataErrorCode status, 306 google_apis::GDataErrorCode status,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 weak_ptr_factory_.GetWeakPtr())); 367 weak_ptr_factory_.GetWeakPtr()));
364 web_ui()->RegisterMessageCallback( 368 web_ui()->RegisterMessageCallback(
365 "clearAccessToken", 369 "clearAccessToken",
366 base::Bind(&DriveInternalsWebUIHandler::ClearAccessToken, 370 base::Bind(&DriveInternalsWebUIHandler::ClearAccessToken,
367 weak_ptr_factory_.GetWeakPtr())); 371 weak_ptr_factory_.GetWeakPtr()));
368 web_ui()->RegisterMessageCallback( 372 web_ui()->RegisterMessageCallback(
369 "clearRefreshToken", 373 "clearRefreshToken",
370 base::Bind(&DriveInternalsWebUIHandler::ClearRefreshToken, 374 base::Bind(&DriveInternalsWebUIHandler::ClearRefreshToken,
371 weak_ptr_factory_.GetWeakPtr())); 375 weak_ptr_factory_.GetWeakPtr()));
372 web_ui()->RegisterMessageCallback( 376 web_ui()->RegisterMessageCallback(
377 "reloadDriveFileSystem",
378 base::Bind(&DriveInternalsWebUIHandler::ReloadDriveFileSystem,
379 weak_ptr_factory_.GetWeakPtr()));
380 web_ui()->RegisterMessageCallback(
373 "listFileEntries", 381 "listFileEntries",
374 base::Bind(&DriveInternalsWebUIHandler::ListFileEntries, 382 base::Bind(&DriveInternalsWebUIHandler::ListFileEntries,
375 weak_ptr_factory_.GetWeakPtr())); 383 weak_ptr_factory_.GetWeakPtr()));
376 } 384 }
377 385
378 drive::DriveIntegrationService* 386 drive::DriveIntegrationService*
379 DriveInternalsWebUIHandler::GetIntegrationService() { 387 DriveInternalsWebUIHandler::GetIntegrationService() {
380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
381 389
382 Profile* profile = Profile::FromWebUI(web_ui()); 390 Profile* profile = Profile::FromWebUI(web_ui());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 560
553 void DriveInternalsWebUIHandler::ClearRefreshToken( 561 void DriveInternalsWebUIHandler::ClearRefreshToken(
554 const base::ListValue* args) { 562 const base::ListValue* args) {
555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
556 564
557 drive::DriveServiceInterface* drive_service = GetDriveService(); 565 drive::DriveServiceInterface* drive_service = GetDriveService();
558 if (drive_service) 566 if (drive_service)
559 drive_service->ClearRefreshToken(); 567 drive_service->ClearRefreshToken();
560 } 568 }
561 569
570 void DriveInternalsWebUIHandler::ReloadDriveFileSystem(
571 const base::ListValue* args) {
572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
573
574 drive::DriveIntegrationService* integration_service =
575 GetIntegrationService();
576 if (integration_service) {
577 integration_service->ClearCacheAndRemountFileSystem(
578 base::Bind(&DriveInternalsWebUIHandler::ReloadFinished,
579 weak_ptr_factory_.GetWeakPtr()));
580 }
581 }
582
583 void DriveInternalsWebUIHandler::ReloadFinished(bool success) {
584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
585
586 web_ui()->CallJavascriptFunction("updateReloadStatus",
587 base::FundamentalValue(success));
588 }
589
562 void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) { 590 void DriveInternalsWebUIHandler::ListFileEntries(const base::ListValue* args) {
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 591 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
564 592
565 UpdateFileSystemContentsSection(); 593 UpdateFileSystemContentsSection();
566 } 594 }
567 595
568 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection( 596 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection(
569 drive::DebugInfoCollector* debug_info_collector) { 597 drive::DebugInfoCollector* debug_info_collector) {
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
571 DCHECK(debug_info_collector); 599 DCHECK(debug_info_collector);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); 865 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost);
838 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); 866 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS);
839 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); 867 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
840 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); 868 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML);
841 869
842 Profile* profile = Profile::FromWebUI(web_ui); 870 Profile* profile = Profile::FromWebUI(web_ui);
843 content::WebUIDataSource::Add(profile, source); 871 content::WebUIDataSource::Add(profile, source);
844 } 872 }
845 873
846 } // namespace chromeos 874 } // 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