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

Unified Diff: chrome/browser/chromeos/extensions/file_browser_private_api.cc

Issue 12221132: filemanager: Fix GetDriveConnectionStateFunctionChange to return "offline" when DriveSystemService … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix JS style. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/file_browser_private_api.cc
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index 85c4c2c851be68267af29ae07046b488d97ee8c7..06d1e0dc7b3088101688f9cf6a0b82b8fd84ffdc 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -122,6 +122,7 @@ const char kDriveConnectionTypeOnline[] = "online";
*/
const char kDriveConnectionReasonNotReady[] = "not_ready";
const char kDriveConnectionReasonNoNetwork[] = "no_network";
+const char kDriveConnectionReasonNoService[] = "no_service";
// Unescape rules used for parsing query parameters.
const net::UnescapeRule::Type kUnescapeRuleForQueryParameters =
@@ -3082,22 +3083,30 @@ bool GetDriveConnectionStateFunction::RunImpl() {
drive::DriveSystemService* system_service =
drive::DriveSystemServiceFactory::GetForProfile(profile_);
- bool ready = system_service->drive_service()->CanStartOperation();
- bool is_connection_cellular =
- net::NetworkChangeNotifier::IsConnectionCellular(
- net::NetworkChangeNotifier::GetConnectionType());
- if (net::NetworkChangeNotifier::IsOffline() || !ready) {
+ if (system_service) {
+ bool ready = system_service->drive_service()->CanStartOperation();
+ bool is_connection_cellular =
+ net::NetworkChangeNotifier::IsConnectionCellular(
+ net::NetworkChangeNotifier::GetConnectionType());
+ if (net::NetworkChangeNotifier::IsOffline() || !ready) {
+ type_string = kDriveConnectionTypeOffline;
+ if (net::NetworkChangeNotifier::IsOffline())
hashimoto 2013/02/12 06:42:05 nit: It seems redundant to have two IsOffline() ch
Haruki Sato 2013/02/12 07:28:49 Good point! Refactored as suggested. and it's now
+ reasons->AppendString(kDriveConnectionReasonNoNetwork);
+ if (!ready)
+ reasons->AppendString(kDriveConnectionReasonNotReady);
+ } else if (
+ is_connection_cellular &&
+ profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular)) {
+ type_string = kDriveConnectionTypeMetered;
+ } else {
+ type_string = kDriveConnectionTypeOnline;
+ }
+ } else {
+ // No Drive service. Disabled by user or in Incognito/Guest mode.
type_string = kDriveConnectionTypeOffline;
if (net::NetworkChangeNotifier::IsOffline())
reasons->AppendString(kDriveConnectionReasonNoNetwork);
- if (!ready)
- reasons->AppendString(kDriveConnectionReasonNotReady);
- } else if (
- is_connection_cellular &&
- profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular)) {
- type_string = kDriveConnectionTypeMetered;
- } else {
- type_string = kDriveConnectionTypeOnline;
+ reasons->AppendString(kDriveConnectionReasonNoService);
}
value->SetString("type", type_string);
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698