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

Side by Side 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: refactor the if-clause 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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
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 }
OLDNEW
« 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