| 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 if (system_service) { |
| 3086 bool is_connection_cellular = | 3087 bool ready = system_service->drive_service()->CanStartOperation(); |
| 3087 net::NetworkChangeNotifier::IsConnectionCellular( | 3088 bool is_connection_cellular = |
| 3088 net::NetworkChangeNotifier::GetConnectionType()); | 3089 net::NetworkChangeNotifier::IsConnectionCellular( |
| 3089 if (net::NetworkChangeNotifier::IsOffline() || !ready) { | 3090 net::NetworkChangeNotifier::GetConnectionType()); |
| 3091 if (net::NetworkChangeNotifier::IsOffline() || !ready) { |
| 3092 type_string = kDriveConnectionTypeOffline; |
| 3093 if (net::NetworkChangeNotifier::IsOffline()) |
| 3094 reasons->AppendString(kDriveConnectionReasonNoNetwork); |
| 3095 if (!ready) |
| 3096 reasons->AppendString(kDriveConnectionReasonNotReady); |
| 3097 } else if ( |
| 3098 is_connection_cellular && |
| 3099 profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular)) { |
| 3100 type_string = kDriveConnectionTypeMetered; |
| 3101 } else { |
| 3102 type_string = kDriveConnectionTypeOnline; |
| 3103 } |
| 3104 } else { |
| 3105 // No Drive service. Disabled by user or in Incognito/Guest mode. |
| 3090 type_string = kDriveConnectionTypeOffline; | 3106 type_string = kDriveConnectionTypeOffline; |
| 3091 if (net::NetworkChangeNotifier::IsOffline()) | 3107 if (net::NetworkChangeNotifier::IsOffline()) |
| 3092 reasons->AppendString(kDriveConnectionReasonNoNetwork); | 3108 reasons->AppendString(kDriveConnectionReasonNoNetwork); |
| 3093 if (!ready) | 3109 reasons->AppendString(kDriveConnectionReasonNoService); |
| 3094 reasons->AppendString(kDriveConnectionReasonNotReady); | |
| 3095 } else if ( | |
| 3096 is_connection_cellular && | |
| 3097 profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular)) { | |
| 3098 type_string = kDriveConnectionTypeMetered; | |
| 3099 } else { | |
| 3100 type_string = kDriveConnectionTypeOnline; | |
| 3101 } | 3110 } |
| 3102 | 3111 |
| 3103 value->SetString("type", type_string); | 3112 value->SetString("type", type_string); |
| 3104 value->Set("reasons", reasons.release()); | 3113 value->Set("reasons", reasons.release()); |
| 3105 SetResult(value.release()); | 3114 SetResult(value.release()); |
| 3106 | 3115 |
| 3107 return true; | 3116 return true; |
| 3108 } | 3117 } |
| 3109 | 3118 |
| 3110 bool RequestDirectoryRefreshFunction::RunImpl() { | 3119 bool RequestDirectoryRefreshFunction::RunImpl() { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3252 this, name.size())); | 3261 this, name.size())); |
| 3253 return true; | 3262 return true; |
| 3254 } | 3263 } |
| 3255 | 3264 |
| 3256 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved( | 3265 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved( |
| 3257 size_t current_length, | 3266 size_t current_length, |
| 3258 size_t max_length) { | 3267 size_t max_length) { |
| 3259 SetResult(new base::FundamentalValue(current_length <= max_length)); | 3268 SetResult(new base::FundamentalValue(current_length <= max_length)); |
| 3260 SendResponse(true); | 3269 SendResponse(true); |
| 3261 } | 3270 } |
| OLD | NEW |