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

Unified Diff: chrome/browser/chromeos/drive/file_system_util.cc

Issue 98493003: Simplify fileBrowserPrivate.getDriveConnectionStatus(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the util function name. Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/drive/file_system_util.cc
diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc
index f9b56fadc2e8ec9e731ae1f57bb66fb7c9ff9192..dfb867202b73a348f8a25c8d0964d99d8875a221 100644
--- a/chrome/browser/chromeos/drive/file_system_util.cc
+++ b/chrome/browser/chromeos/drive/file_system_util.cc
@@ -389,5 +389,27 @@ bool IsDriveEnabledForProfile(Profile* profile) {
return true;
}
+ConnectionStatusType GetDriveConnectionStatus(Profile* profile) {
+ drive::DriveServiceInterface* const drive_service =
+ drive::util::GetDriveServiceByProfile(profile);
+
+ if (!drive_service)
+ return DRIVE_DISCONNECTED_NOSERVICE;
+ if (net::NetworkChangeNotifier::IsOffline())
+ return DRIVE_DISCONNECTED_NONETWORK;
+ if (!drive_service->CanSendRequest())
+ return DRIVE_DISCONNECTED_NOTREADY;
+
+ const bool is_connection_cellular =
+ net::NetworkChangeNotifier::IsConnectionCellular(
+ net::NetworkChangeNotifier::GetConnectionType());
+ const bool disable_sync_over_celluar =
+ profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular);
+
+ if (is_connection_cellular && disable_sync_over_celluar)
+ return DRIVE_CONNECTED_METERED;
+ return DRIVE_CONNECTED;
+}
+
} // namespace util
} // namespace drive
« no previous file with comments | « chrome/browser/chromeos/drive/file_system_util.h ('k') | chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698