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

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: 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 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 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.
3092 reasons->AppendString(kDriveConnectionReasonNoNetwork);
3093 if (!ready)
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 } 3108 }
3102 3109
3103 value->SetString("type", type_string); 3110 value->SetString("type", type_string);
3104 value->Set("reasons", reasons.release()); 3111 value->Set("reasons", reasons.release());
3105 SetResult(value.release()); 3112 SetResult(value.release());
3106 3113
3107 return true; 3114 return true;
3108 } 3115 }
3109 3116
3110 bool RequestDirectoryRefreshFunction::RunImpl() { 3117 bool RequestDirectoryRefreshFunction::RunImpl() {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 this, name.size())); 3259 this, name.size()));
3253 return true; 3260 return true;
3254 } 3261 }
3255 3262
3256 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved( 3263 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved(
3257 size_t current_length, 3264 size_t current_length,
3258 size_t max_length) { 3265 size_t max_length) {
3259 SetResult(new base::FundamentalValue(current_length <= max_length)); 3266 SetResult(new base::FundamentalValue(current_length <= max_length));
3260 SendResponse(true); 3267 SendResponse(true);
3261 } 3268 }
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