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

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

Issue 171843003: Remove --disable-drive flag and flags section in drive-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months 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') | chromeos/chromeos_switches.h » ('j') | 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"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/sys_info.h" 17 #include "base/sys_info.h"
18 #include "chrome/browser/chromeos/drive/debug_info_collector.h" 18 #include "chrome/browser/chromeos/drive/debug_info_collector.h"
19 #include "chrome/browser/chromeos/drive/drive.pb.h" 19 #include "chrome/browser/chromeos/drive/drive.pb.h"
20 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 20 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
21 #include "chrome/browser/chromeos/drive/file_system_util.h" 21 #include "chrome/browser/chromeos/drive/file_system_util.h"
22 #include "chrome/browser/chromeos/drive/job_list.h" 22 #include "chrome/browser/chromeos/drive/job_list.h"
23 #include "chrome/browser/chromeos/file_manager/path_util.h" 23 #include "chrome/browser/chromeos/file_manager/path_util.h"
24 #include "chrome/browser/drive/drive_api_util.h" 24 #include "chrome/browser/drive/drive_api_util.h"
25 #include "chrome/browser/drive/drive_notification_manager.h" 25 #include "chrome/browser/drive/drive_notification_manager.h"
26 #include "chrome/browser/drive/drive_notification_manager_factory.h" 26 #include "chrome/browser/drive/drive_notification_manager_factory.h"
27 #include "chrome/browser/drive/drive_service_interface.h" 27 #include "chrome/browser/drive/drive_service_interface.h"
28 #include "chrome/browser/drive/drive_switches.h"
29 #include "chrome/browser/drive/event_logger.h" 28 #include "chrome/browser/drive/event_logger.h"
30 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
33 #include "chromeos/chromeos_switches.h"
34 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/web_ui.h" 33 #include "content/public/browser/web_ui.h"
36 #include "content/public/browser/web_ui_data_source.h" 34 #include "content/public/browser/web_ui_data_source.h"
37 #include "content/public/browser/web_ui_message_handler.h" 35 #include "content/public/browser/web_ui_message_handler.h"
38 #include "google_apis/drive/auth_service.h" 36 #include "google_apis/drive/auth_service.h"
39 #include "google_apis/drive/drive_api_parser.h" 37 #include "google_apis/drive/drive_api_parser.h"
40 #include "google_apis/drive/gdata_errorcode.h" 38 #include "google_apis/drive/gdata_errorcode.h"
41 #include "google_apis/drive/gdata_wapi_parser.h" 39 #include "google_apis/drive/gdata_wapi_parser.h"
42 #include "google_apis/drive/time_util.h" 40 #include "google_apis/drive/time_util.h"
43 #include "grit/browser_resources.h" 41 #include "grit/browser_resources.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Returns a DriveService instance. 225 // Returns a DriveService instance.
228 drive::DriveServiceInterface* GetDriveService(); 226 drive::DriveServiceInterface* GetDriveService();
229 227
230 // Returns a DebugInfoCollector instance. 228 // Returns a DebugInfoCollector instance.
231 drive::DebugInfoCollector* GetDebugInfoCollector(); 229 drive::DebugInfoCollector* GetDebugInfoCollector();
232 230
233 // Called when the page is first loaded. 231 // Called when the page is first loaded.
234 void OnPageLoaded(const base::ListValue* args); 232 void OnPageLoaded(const base::ListValue* args);
235 233
236 // Updates respective sections. 234 // Updates respective sections.
237 void UpdateDriveRelatedFlagsSection();
238 void UpdateDriveRelatedPreferencesSection(); 235 void UpdateDriveRelatedPreferencesSection();
239 void UpdateConnectionStatusSection( 236 void UpdateConnectionStatusSection(
240 drive::DriveServiceInterface* drive_service); 237 drive::DriveServiceInterface* drive_service);
241 void UpdateAboutResourceSection( 238 void UpdateAboutResourceSection(
242 drive::DriveServiceInterface* drive_service); 239 drive::DriveServiceInterface* drive_service);
243 void UpdateAppListSection( 240 void UpdateAppListSection(
244 drive::DriveServiceInterface* drive_service); 241 drive::DriveServiceInterface* drive_service);
245 void UpdateLocalMetadataSection( 242 void UpdateLocalMetadataSection(
246 drive::DebugInfoCollector* debug_info_collector); 243 drive::DebugInfoCollector* debug_info_collector);
247 void UpdateDeltaUpdateStatusSection( 244 void UpdateDeltaUpdateStatusSection(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (!integration_service) 427 if (!integration_service)
431 return; 428 return;
432 429
433 drive::DriveServiceInterface* drive_service = 430 drive::DriveServiceInterface* drive_service =
434 integration_service->drive_service(); 431 integration_service->drive_service();
435 DCHECK(drive_service); 432 DCHECK(drive_service);
436 drive::DebugInfoCollector* debug_info_collector = 433 drive::DebugInfoCollector* debug_info_collector =
437 integration_service->debug_info_collector(); 434 integration_service->debug_info_collector();
438 DCHECK(debug_info_collector); 435 DCHECK(debug_info_collector);
439 436
440 UpdateDriveRelatedFlagsSection();
441 UpdateDriveRelatedPreferencesSection(); 437 UpdateDriveRelatedPreferencesSection();
442 UpdateConnectionStatusSection(drive_service); 438 UpdateConnectionStatusSection(drive_service);
443 UpdateAboutResourceSection(drive_service); 439 UpdateAboutResourceSection(drive_service);
444 UpdateAppListSection(drive_service); 440 UpdateAppListSection(drive_service);
445 UpdateLocalMetadataSection(debug_info_collector); 441 UpdateLocalMetadataSection(debug_info_collector);
446 UpdateDeltaUpdateStatusSection(debug_info_collector); 442 UpdateDeltaUpdateStatusSection(debug_info_collector);
447 UpdateInFlightOperationsSection(integration_service->job_list()); 443 UpdateInFlightOperationsSection(integration_service->job_list());
448 UpdateGCacheContentsSection(); 444 UpdateGCacheContentsSection();
449 UpdateCacheContentsSection(debug_info_collector); 445 UpdateCacheContentsSection(debug_info_collector);
450 UpdateLocalStorageUsageSection(); 446 UpdateLocalStorageUsageSection();
451 UpdatePathConfigurationsSection(); 447 UpdatePathConfigurationsSection();
452 448
453 // When the drive-internals page is reloaded by the reload key, the page 449 // When the drive-internals page is reloaded by the reload key, the page
454 // content is recreated, but this WebUI object is not (instead, OnPageLoaded 450 // content is recreated, but this WebUI object is not (instead, OnPageLoaded
455 // is called again). In that case, we have to forget the last sent ID here, 451 // is called again). In that case, we have to forget the last sent ID here,
456 // and resent whole the logs to the page. 452 // and resent whole the logs to the page.
457 last_sent_event_id_ = -1; 453 last_sent_event_id_ = -1;
458 UpdateEventLogSection(); 454 UpdateEventLogSection();
459 } 455 }
460 456
461 void DriveInternalsWebUIHandler::UpdateDriveRelatedFlagsSection() {
462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
463
464 const char* kDriveRelatedFlags[] = {
465 drive::switches::kEnableDriveV2Api,
466 chromeos::switches::kDisableDrive,
467 };
468
469 base::ListValue flags;
470 for (size_t i = 0; i < arraysize(kDriveRelatedFlags); ++i) {
471 const std::string key = kDriveRelatedFlags[i];
472 std::string value = "(not set)";
473 if (CommandLine::ForCurrentProcess()->HasSwitch(key))
474 value = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(key);
475 AppendKeyValue(&flags, key, value.empty() ? "(set)" : value);
476 }
477
478 web_ui()->CallJavascriptFunction("updateDriveRelatedFlags", flags);
479 }
480
481 void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() { 457 void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() {
482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
483 459
484 const char* kDriveRelatedPreferences[] = { 460 const char* kDriveRelatedPreferences[] = {
485 prefs::kDisableDrive, 461 prefs::kDisableDrive,
486 prefs::kDisableDriveOverCellular, 462 prefs::kDisableDriveOverCellular,
487 prefs::kDisableDriveHostedFiles, 463 prefs::kDisableDriveHostedFiles,
488 }; 464 };
489 465
490 Profile* profile = Profile::FromWebUI(web_ui()); 466 Profile* profile = Profile::FromWebUI(web_ui());
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); 896 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost);
921 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); 897 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS);
922 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); 898 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
923 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); 899 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML);
924 900
925 Profile* profile = Profile::FromWebUI(web_ui); 901 Profile* profile = Profile::FromWebUI(web_ui);
926 content::WebUIDataSource::Add(profile, source); 902 content::WebUIDataSource::Add(profile, source);
927 } 903 }
928 904
929 } // namespace chromeos 905 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698