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..bc44c9034110e918d6b3b8fede973262462d2e4f 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,28 @@ 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) { |
- 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; |
+ 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()) |
+ 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 { |
- type_string = kDriveConnectionTypeOnline; |
+ // No Drive service. Disabled by user or in Incognito/Guest mode. |
+ type_string = kDriveConnectionTypeOffline; |
+ reasons->AppendString(kDriveConnectionReasonNoService); |
hashimoto
2013/02/12 06:12:29
nit: Shouldn't we include "no_network" in |reasons
Haruki Sato
2013/02/12 06:34:07
That would be more consistent. We can and I added.
|
} |
value->SetString("type", type_string); |