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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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/chromeos/drive/file_system_util.h" 5 #include "chrome/browser/chromeos/drive/file_system_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return false; 382 return false;
383 383
384 // Disable Drive if preference is set. This can happen with commandline flag 384 // Disable Drive if preference is set. This can happen with commandline flag
385 // --disable-drive or enterprise policy, or with user settings. 385 // --disable-drive or enterprise policy, or with user settings.
386 if (profile->GetPrefs()->GetBoolean(prefs::kDisableDrive)) 386 if (profile->GetPrefs()->GetBoolean(prefs::kDisableDrive))
387 return false; 387 return false;
388 388
389 return true; 389 return true;
390 } 390 }
391 391
392 ConnectionStatusType GetDriveConnectionStatus(Profile* profile) {
393 drive::DriveServiceInterface* const drive_service =
394 drive::util::GetDriveServiceByProfile(profile);
395
396 if (!drive_service)
397 return DRIVE_DISCONNECTED_NOSERVICE;
398 if (net::NetworkChangeNotifier::IsOffline())
399 return DRIVE_DISCONNECTED_NONETWORK;
400 if (!drive_service->CanSendRequest())
401 return DRIVE_DISCONNECTED_NOTREADY;
402
403 const bool is_connection_cellular =
404 net::NetworkChangeNotifier::IsConnectionCellular(
405 net::NetworkChangeNotifier::GetConnectionType());
406 const bool disable_sync_over_celluar =
407 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular);
408
409 if (is_connection_cellular && disable_sync_over_celluar)
410 return DRIVE_CONNECTED_METERED;
411 return DRIVE_CONNECTED;
412 }
413
392 } // namespace util 414 } // namespace util
393 } // namespace drive 415 } // namespace drive
OLDNEW
« 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