OLD | NEW |
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/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 const char kDriveConnectionTypeMetered[] = "metered"; | 115 const char kDriveConnectionTypeMetered[] = "metered"; |
116 const char kDriveConnectionTypeOnline[] = "online"; | 116 const char kDriveConnectionTypeOnline[] = "online"; |
117 | 117 |
118 /** | 118 /** |
119 * List of reasons of kDriveConnectionType*. | 119 * List of reasons of kDriveConnectionType*. |
120 * | 120 * |
121 * Keep this in sync with the DriveConnectionReason in file_manager.js. | 121 * Keep this in sync with the DriveConnectionReason in file_manager.js. |
122 */ | 122 */ |
123 const char kDriveConnectionReasonNotReady[] = "not_ready"; | 123 const char kDriveConnectionReasonNotReady[] = "not_ready"; |
124 const char kDriveConnectionReasonNoNetwork[] = "no_network"; | 124 const char kDriveConnectionReasonNoNetwork[] = "no_network"; |
| 125 const char kDriveConnectionReasonNoService[] = "no_service"; |
125 | 126 |
126 // Unescape rules used for parsing query parameters. | 127 // Unescape rules used for parsing query parameters. |
127 const net::UnescapeRule::Type kUnescapeRuleForQueryParameters = | 128 const net::UnescapeRule::Type kUnescapeRuleForQueryParameters = |
128 net::UnescapeRule::SPACES | | 129 net::UnescapeRule::SPACES | |
129 net::UnescapeRule::URL_SPECIAL_CHARS | | 130 net::UnescapeRule::URL_SPECIAL_CHARS | |
130 net::UnescapeRule::REPLACE_PLUS_WITH_SPACE; | 131 net::UnescapeRule::REPLACE_PLUS_WITH_SPACE; |
131 | 132 |
132 const DiskMountManager::Disk* GetVolumeAsDisk(const std::string& mount_path) { | 133 const DiskMountManager::Disk* GetVolumeAsDisk(const std::string& mount_path) { |
133 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 134 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
134 | 135 |
(...skipping 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 } | 3076 } |
3076 | 3077 |
3077 bool GetDriveConnectionStateFunction::RunImpl() { | 3078 bool GetDriveConnectionStateFunction::RunImpl() { |
3078 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 3079 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
3079 scoped_ptr<ListValue> reasons(new ListValue()); | 3080 scoped_ptr<ListValue> reasons(new ListValue()); |
3080 | 3081 |
3081 std::string type_string; | 3082 std::string type_string; |
3082 drive::DriveSystemService* system_service = | 3083 drive::DriveSystemService* system_service = |
3083 drive::DriveSystemServiceFactory::GetForProfile(profile_); | 3084 drive::DriveSystemServiceFactory::GetForProfile(profile_); |
3084 | 3085 |
3085 bool ready = system_service->drive_service()->CanStartOperation(); | 3086 bool ready = system_service && |
| 3087 system_service->drive_service()->CanStartOperation(); |
3086 bool is_connection_cellular = | 3088 bool is_connection_cellular = |
3087 net::NetworkChangeNotifier::IsConnectionCellular( | 3089 net::NetworkChangeNotifier::IsConnectionCellular( |
3088 net::NetworkChangeNotifier::GetConnectionType()); | 3090 net::NetworkChangeNotifier::GetConnectionType()); |
| 3091 |
3089 if (net::NetworkChangeNotifier::IsOffline() || !ready) { | 3092 if (net::NetworkChangeNotifier::IsOffline() || !ready) { |
3090 type_string = kDriveConnectionTypeOffline; | 3093 type_string = kDriveConnectionTypeOffline; |
3091 if (net::NetworkChangeNotifier::IsOffline()) | 3094 if (net::NetworkChangeNotifier::IsOffline()) |
3092 reasons->AppendString(kDriveConnectionReasonNoNetwork); | 3095 reasons->AppendString(kDriveConnectionReasonNoNetwork); |
3093 if (!ready) | 3096 if (!ready) |
3094 reasons->AppendString(kDriveConnectionReasonNotReady); | 3097 reasons->AppendString(kDriveConnectionReasonNotReady); |
| 3098 if (!system_service) |
| 3099 reasons->AppendString(kDriveConnectionReasonNoService); |
3095 } else if ( | 3100 } else if ( |
3096 is_connection_cellular && | 3101 is_connection_cellular && |
3097 profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular)) { | 3102 profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular)) { |
3098 type_string = kDriveConnectionTypeMetered; | 3103 type_string = kDriveConnectionTypeMetered; |
3099 } else { | 3104 } else { |
3100 type_string = kDriveConnectionTypeOnline; | 3105 type_string = kDriveConnectionTypeOnline; |
3101 } | 3106 } |
3102 | 3107 |
3103 value->SetString("type", type_string); | 3108 value->SetString("type", type_string); |
3104 value->Set("reasons", reasons.release()); | 3109 value->Set("reasons", reasons.release()); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3252 this, name.size())); | 3257 this, name.size())); |
3253 return true; | 3258 return true; |
3254 } | 3259 } |
3255 | 3260 |
3256 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved( | 3261 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved( |
3257 size_t current_length, | 3262 size_t current_length, |
3258 size_t max_length) { | 3263 size_t max_length) { |
3259 SetResult(new base::FundamentalValue(current_length <= max_length)); | 3264 SetResult(new base::FundamentalValue(current_length <= max_length)); |
3260 SendResponse(true); | 3265 SendResponse(true); |
3261 } | 3266 } |
OLD | NEW |