| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" | 12 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chrome/browser/extensions/extension_event_names.h" | 14 #include "chrome/browser/extensions/extension_event_names.h" |
| 15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/file_manager_util.h" | 17 #include "chrome/browser/extensions/file_manager_util.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 20 #include "webkit/fileapi/file_system_types.h" | 20 #include "webkit/fileapi/file_system_types.h" |
| 21 #include "webkit/fileapi/file_system_util.h" | 21 #include "webkit/fileapi/file_system_util.h" |
| 22 | 22 |
| 23 using chromeos::disks::DiskMountManager; |
| 24 using chromeos::disks::DiskMountManagerEventType; |
| 23 using content::BrowserThread; | 25 using content::BrowserThread; |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 const char kDiskAddedEventType[] = "added"; | 28 const char kDiskAddedEventType[] = "added"; |
| 27 const char kDiskRemovedEventType[] = "removed"; | 29 const char kDiskRemovedEventType[] = "removed"; |
| 28 | 30 |
| 29 const char kPathChanged[] = "changed"; | 31 const char kPathChanged[] = "changed"; |
| 30 const char kPathWatchError[] = "error"; | 32 const char kPathWatchError[] = "error"; |
| 31 | 33 |
| 32 const char* DeviceTypeToString(chromeos::DeviceType type) { | |
| 33 switch (type) { | |
| 34 case chromeos::FLASH: | |
| 35 return "flash"; | |
| 36 case chromeos::HDD: | |
| 37 return "hdd"; | |
| 38 case chromeos::OPTICAL: | |
| 39 return "optical"; | |
| 40 default: | |
| 41 break; | |
| 42 } | |
| 43 return "undefined"; | |
| 44 } | |
| 45 | |
| 46 DictionaryValue* DiskToDictionaryValue( | 34 DictionaryValue* DiskToDictionaryValue( |
| 47 const chromeos::disks::DiskMountManager::Disk* disk) { | 35 const DiskMountManager::Disk* disk) { |
| 48 DictionaryValue* result = new DictionaryValue(); | 36 DictionaryValue* result = new DictionaryValue(); |
| 49 result->SetString("mountPath", disk->mount_path()); | 37 result->SetString("mountPath", disk->mount_path()); |
| 50 result->SetString("devicePath", disk->device_path()); | 38 result->SetString("devicePath", disk->device_path()); |
| 51 result->SetString("label", disk->device_label()); | 39 result->SetString("label", disk->device_label()); |
| 52 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); | 40 result->SetString("deviceType", |
| 41 DiskMountManager::DeviceTypeToString(disk->device_type())); |
| 53 result->SetInteger("totalSizeKB", disk->total_size_in_bytes() / 1024); | 42 result->SetInteger("totalSizeKB", disk->total_size_in_bytes() / 1024); |
| 54 result->SetBoolean("readOnly", disk->is_read_only()); | 43 result->SetBoolean("readOnly", disk->is_read_only()); |
| 55 return result; | 44 return result; |
| 56 } | 45 } |
| 57 } | 46 } |
| 58 | 47 |
| 59 const char* MountErrorToString(chromeos::MountError error) { | 48 const char* MountErrorToString(chromeos::MountError error) { |
| 60 switch (error) { | 49 switch (error) { |
| 61 case chromeos::MOUNT_ERROR_NONE: | 50 case chromeos::MOUNT_ERROR_NONE: |
| 62 return "success"; | 51 return "success"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 87 | 76 |
| 88 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 77 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
| 89 DCHECK(file_watchers_.empty()); | 78 DCHECK(file_watchers_.empty()); |
| 90 STLDeleteValues(&file_watchers_); | 79 STLDeleteValues(&file_watchers_); |
| 91 | 80 |
| 92 if (!profile_) { | 81 if (!profile_) { |
| 93 NOTREACHED(); | 82 NOTREACHED(); |
| 94 return; | 83 return; |
| 95 } | 84 } |
| 96 profile_ = NULL; | 85 profile_ = NULL; |
| 97 chromeos::disks::DiskMountManager::GetInstance()->RemoveObserver(this); | 86 DiskMountManager::GetInstance()->RemoveObserver(this); |
| 98 } | 87 } |
| 99 | 88 |
| 100 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { | 89 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { |
| 101 if (!profile_) { | 90 if (!profile_) { |
| 102 NOTREACHED(); | 91 NOTREACHED(); |
| 103 return; | 92 return; |
| 104 } | 93 } |
| 105 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 94 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
| 106 chromeos::disks::DiskMountManager* disk_mount_manager = | 95 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
| 107 chromeos::disks::DiskMountManager::GetInstance(); | |
| 108 disk_mount_manager->RemoveObserver(this); | 96 disk_mount_manager->RemoveObserver(this); |
| 109 disk_mount_manager->AddObserver(this); | 97 disk_mount_manager->AddObserver(this); |
| 110 disk_mount_manager->RequestMountInfoRefresh(); | 98 disk_mount_manager->RequestMountInfoRefresh(); |
| 111 } | 99 } |
| 112 } | 100 } |
| 113 | 101 |
| 114 // File watch setup routines. | 102 // File watch setup routines. |
| 115 bool ExtensionFileBrowserEventRouter::AddFileWatch( | 103 bool ExtensionFileBrowserEventRouter::AddFileWatch( |
| 116 const FilePath& local_path, | 104 const FilePath& local_path, |
| 117 const FilePath& virtual_path, | 105 const FilePath& virtual_path, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 141 return; | 129 return; |
| 142 // Remove the renderer process for this watch. | 130 // Remove the renderer process for this watch. |
| 143 iter->second->RemoveExtension(extension_id); | 131 iter->second->RemoveExtension(extension_id); |
| 144 if (iter->second->GetRefCount() == 0) { | 132 if (iter->second->GetRefCount() == 0) { |
| 145 delete iter->second; | 133 delete iter->second; |
| 146 file_watchers_.erase(iter); | 134 file_watchers_.erase(iter); |
| 147 } | 135 } |
| 148 } | 136 } |
| 149 | 137 |
| 150 void ExtensionFileBrowserEventRouter::DiskChanged( | 138 void ExtensionFileBrowserEventRouter::DiskChanged( |
| 151 chromeos::disks::DiskMountManagerEventType event, | 139 DiskMountManagerEventType event, |
| 152 const chromeos::disks::DiskMountManager::Disk* disk) { | 140 const DiskMountManager::Disk* disk) { |
| 153 // Disregard hidden devices. | 141 // Disregard hidden devices. |
| 154 if (disk->is_hidden()) | 142 if (disk->is_hidden()) |
| 155 return; | 143 return; |
| 156 if (event == chromeos::disks::MOUNT_DISK_ADDED) { | 144 if (event == chromeos::disks::MOUNT_DISK_ADDED) { |
| 157 OnDiskAdded(disk); | 145 OnDiskAdded(disk); |
| 158 } else if (event == chromeos::disks::MOUNT_DISK_REMOVED) { | 146 } else if (event == chromeos::disks::MOUNT_DISK_REMOVED) { |
| 159 OnDiskRemoved(disk); | 147 OnDiskRemoved(disk); |
| 160 } | 148 } |
| 161 } | 149 } |
| 162 | 150 |
| 163 void ExtensionFileBrowserEventRouter::DeviceChanged( | 151 void ExtensionFileBrowserEventRouter::DeviceChanged( |
| 164 chromeos::disks::DiskMountManagerEventType event, | 152 DiskMountManagerEventType event, |
| 165 const std::string& device_path) { | 153 const std::string& device_path) { |
| 166 if (event == chromeos::disks::MOUNT_DEVICE_ADDED) { | 154 if (event == chromeos::disks::MOUNT_DEVICE_ADDED) { |
| 167 OnDeviceAdded(device_path); | 155 OnDeviceAdded(device_path); |
| 168 } else if (event == chromeos::disks::MOUNT_DEVICE_REMOVED) { | 156 } else if (event == chromeos::disks::MOUNT_DEVICE_REMOVED) { |
| 169 OnDeviceRemoved(device_path); | 157 OnDeviceRemoved(device_path); |
| 170 } else if (event == chromeos::disks::MOUNT_DEVICE_SCANNED) { | 158 } else if (event == chromeos::disks::MOUNT_DEVICE_SCANNED) { |
| 171 OnDeviceScanned(device_path); | 159 OnDeviceScanned(device_path); |
| 172 } else if (event == chromeos::disks::MOUNT_FORMATTING_STARTED) { | 160 } else if (event == chromeos::disks::MOUNT_FORMATTING_STARTED) { |
| 173 // TODO(tbarzic): get rid of '!'. | 161 // TODO(tbarzic): get rid of '!'. |
| 174 if (device_path[0] == '!') { | 162 if (device_path[0] == '!') { |
| 175 OnFormattingStarted(device_path.substr(1), false); | 163 OnFormattingStarted(device_path.substr(1), false); |
| 176 } else { | 164 } else { |
| 177 OnFormattingStarted(device_path, true); | 165 OnFormattingStarted(device_path, true); |
| 178 } | 166 } |
| 179 } else if (event == chromeos::disks::MOUNT_FORMATTING_FINISHED) { | 167 } else if (event == chromeos::disks::MOUNT_FORMATTING_FINISHED) { |
| 180 if (device_path[0] == '!') { | 168 if (device_path[0] == '!') { |
| 181 OnFormattingFinished(device_path.substr(1), false); | 169 OnFormattingFinished(device_path.substr(1), false); |
| 182 } else { | 170 } else { |
| 183 OnFormattingFinished(device_path, true); | 171 OnFormattingFinished(device_path, true); |
| 184 } | 172 } |
| 185 } | 173 } |
| 186 } | 174 } |
| 187 | 175 |
| 188 void ExtensionFileBrowserEventRouter::MountCompleted( | 176 void ExtensionFileBrowserEventRouter::MountCompleted( |
| 189 chromeos::disks::DiskMountManager::MountEvent event_type, | 177 DiskMountManager::MountEvent event_type, |
| 190 chromeos::MountError error_code, | 178 chromeos::MountError error_code, |
| 191 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { | 179 const DiskMountManager::MountPointInfo& mount_info) { |
| 192 DispatchMountCompletedEvent(event_type, error_code, mount_info); | 180 DispatchMountCompletedEvent(event_type, error_code, mount_info); |
| 193 | 181 |
| 194 if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 182 if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
| 195 event_type == chromeos::disks::DiskMountManager::MOUNTING) { | 183 event_type == DiskMountManager::MOUNTING) { |
| 196 chromeos::disks::DiskMountManager* disk_mount_manager = | 184 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
| 197 chromeos::disks::DiskMountManager::GetInstance(); | 185 DiskMountManager::DiskMap::const_iterator disk_it = |
| 198 chromeos::disks::DiskMountManager::DiskMap::const_iterator disk_it = | |
| 199 disk_mount_manager->disks().find(mount_info.source_path); | 186 disk_mount_manager->disks().find(mount_info.source_path); |
| 200 if (disk_it == disk_mount_manager->disks().end()) { | 187 if (disk_it == disk_mount_manager->disks().end()) { |
| 201 return; | 188 return; |
| 202 } | 189 } |
| 203 chromeos::disks::DiskMountManager::Disk* disk = disk_it->second; | 190 DiskMountManager::Disk* disk = disk_it->second; |
| 204 | 191 |
| 205 notifications_->ManageNotificationsOnMountCompleted( | 192 notifications_->ManageNotificationsOnMountCompleted( |
| 206 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), | 193 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), |
| 207 error_code == chromeos::MOUNT_ERROR_NONE, | 194 error_code == chromeos::MOUNT_ERROR_NONE, |
| 208 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); | 195 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); |
| 209 } | 196 } |
| 210 } | 197 } |
| 211 | 198 |
| 212 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( | 199 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( |
| 213 const FilePath& local_path, bool got_error) { | 200 const FilePath& local_path, bool got_error) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 std::string args_json; | 233 std::string args_json; |
| 247 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 234 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
| 248 | 235 |
| 249 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 236 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
| 250 iter->first, extension_event_names::kOnFileChanged, args_json, | 237 iter->first, extension_event_names::kOnFileChanged, args_json, |
| 251 NULL, GURL()); | 238 NULL, GURL()); |
| 252 } | 239 } |
| 253 } | 240 } |
| 254 | 241 |
| 255 void ExtensionFileBrowserEventRouter::DispatchDiskEvent( | 242 void ExtensionFileBrowserEventRouter::DispatchDiskEvent( |
| 256 const chromeos::disks::DiskMountManager::Disk* disk, bool added) { | 243 const DiskMountManager::Disk* disk, bool added) { |
| 257 if (!profile_) { | 244 if (!profile_) { |
| 258 NOTREACHED(); | 245 NOTREACHED(); |
| 259 return; | 246 return; |
| 260 } | 247 } |
| 261 | 248 |
| 262 ListValue args; | 249 ListValue args; |
| 263 DictionaryValue* mount_info = new DictionaryValue(); | 250 DictionaryValue* mount_info = new DictionaryValue(); |
| 264 args.Append(mount_info); | 251 args.Append(mount_info); |
| 265 mount_info->SetString("eventType", | 252 mount_info->SetString("eventType", |
| 266 added ? kDiskAddedEventType : kDiskRemovedEventType); | 253 added ? kDiskAddedEventType : kDiskRemovedEventType); |
| 267 DictionaryValue* disk_info = DiskToDictionaryValue(disk); | 254 DictionaryValue* disk_info = DiskToDictionaryValue(disk); |
| 268 mount_info->Set("volumeInfo", disk_info); | 255 mount_info->Set("volumeInfo", disk_info); |
| 269 | 256 |
| 270 std::string args_json; | 257 std::string args_json; |
| 271 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 258 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
| 272 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 259 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 273 extension_event_names::kOnFileBrowserDiskChanged, args_json, NULL, | 260 extension_event_names::kOnFileBrowserDiskChanged, args_json, NULL, |
| 274 GURL()); | 261 GURL()); |
| 275 } | 262 } |
| 276 | 263 |
| 277 void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( | 264 void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( |
| 278 chromeos::disks::DiskMountManager::MountEvent event, | 265 DiskMountManager::MountEvent event, |
| 279 chromeos::MountError error_code, | 266 chromeos::MountError error_code, |
| 280 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { | 267 const DiskMountManager::MountPointInfo& mount_info) { |
| 281 if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { | 268 if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { |
| 282 NOTREACHED(); | 269 NOTREACHED(); |
| 283 return; | 270 return; |
| 284 } | 271 } |
| 285 | 272 |
| 286 ListValue args; | 273 ListValue args; |
| 287 DictionaryValue* mount_info_value = new DictionaryValue(); | 274 DictionaryValue* mount_info_value = new DictionaryValue(); |
| 288 args.Append(mount_info_value); | 275 args.Append(mount_info_value); |
| 289 if (event == chromeos::disks::DiskMountManager::MOUNTING) { | 276 if (event == DiskMountManager::MOUNTING) { |
| 290 mount_info_value->SetString("eventType", "mount"); | 277 mount_info_value->SetString("eventType", "mount"); |
| 291 } else { | 278 } else { |
| 292 mount_info_value->SetString("eventType", "unmount"); | 279 mount_info_value->SetString("eventType", "unmount"); |
| 293 } | 280 } |
| 294 mount_info_value->SetString("status", MountErrorToString(error_code)); | 281 mount_info_value->SetString("status", MountErrorToString(error_code)); |
| 295 mount_info_value->SetString( | 282 mount_info_value->SetString( |
| 296 "mountType", | 283 "mountType", |
| 297 chromeos::disks::DiskMountManager::MountTypeToString( | 284 DiskMountManager::MountTypeToString(mount_info.mount_type)); |
| 298 mount_info.mount_type)); | |
| 299 | 285 |
| 300 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { | 286 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
| 301 GURL source_url; | 287 GURL source_url; |
| 302 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, | 288 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, |
| 303 FilePath(mount_info.source_path), | 289 FilePath(mount_info.source_path), |
| 304 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), | 290 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), |
| 305 &source_url)) { | 291 &source_url)) { |
| 306 mount_info_value->SetString("sourceUrl", source_url.spec()); | 292 mount_info_value->SetString("sourceUrl", source_url.spec()); |
| 307 } | 293 } |
| 308 } else { | 294 } else { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 329 | 315 |
| 330 std::string args_json; | 316 std::string args_json; |
| 331 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 317 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
| 332 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 318 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 333 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, | 319 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, |
| 334 GURL()); | 320 GURL()); |
| 335 | 321 |
| 336 if (relative_mount_path_set && | 322 if (relative_mount_path_set && |
| 337 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 323 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
| 338 !mount_info.mount_condition && | 324 !mount_info.mount_condition && |
| 339 event == chromeos::disks::DiskMountManager::MOUNTING) { | 325 event == DiskMountManager::MOUNTING) { |
| 340 file_manager_util::ViewFolder(FilePath(mount_info.mount_path)); | 326 file_manager_util::ViewFolder(FilePath(mount_info.mount_path)); |
| 341 } | 327 } |
| 342 } | 328 } |
| 343 | 329 |
| 344 void ExtensionFileBrowserEventRouter::OnDiskAdded( | 330 void ExtensionFileBrowserEventRouter::OnDiskAdded( |
| 345 const chromeos::disks::DiskMountManager::Disk* disk) { | 331 const DiskMountManager::Disk* disk) { |
| 346 VLOG(1) << "Disk added: " << disk->device_path(); | 332 VLOG(1) << "Disk added: " << disk->device_path(); |
| 347 if (disk->device_path().empty()) { | 333 if (disk->device_path().empty()) { |
| 348 VLOG(1) << "Empty system path for " << disk->device_path(); | 334 VLOG(1) << "Empty system path for " << disk->device_path(); |
| 349 return; | 335 return; |
| 350 } | 336 } |
| 351 | 337 |
| 352 // If disk is not mounted yet, give it a try. | 338 // If disk is not mounted yet, give it a try. |
| 353 if (disk->mount_path().empty()) { | 339 if (disk->mount_path().empty()) { |
| 354 // Initiate disk mount operation. | 340 // Initiate disk mount operation. |
| 355 chromeos::disks::DiskMountManager::GetInstance()->MountPath( | 341 DiskMountManager::GetInstance()->MountPath( |
| 356 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE); | 342 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE); |
| 357 } | 343 } |
| 358 DispatchDiskEvent(disk, true); | 344 DispatchDiskEvent(disk, true); |
| 359 } | 345 } |
| 360 | 346 |
| 361 void ExtensionFileBrowserEventRouter::OnDiskRemoved( | 347 void ExtensionFileBrowserEventRouter::OnDiskRemoved( |
| 362 const chromeos::disks::DiskMountManager::Disk* disk) { | 348 const DiskMountManager::Disk* disk) { |
| 363 VLOG(1) << "Disk removed: " << disk->device_path(); | 349 VLOG(1) << "Disk removed: " << disk->device_path(); |
| 364 | 350 |
| 365 if (!disk->mount_path().empty()) { | 351 if (!disk->mount_path().empty()) { |
| 366 chromeos::disks::DiskMountManager::GetInstance()->UnmountPath( | 352 DiskMountManager::GetInstance()->UnmountPath(disk->mount_path()); |
| 367 disk->mount_path()); | |
| 368 } | 353 } |
| 369 DispatchDiskEvent(disk, false); | 354 DispatchDiskEvent(disk, false); |
| 370 } | 355 } |
| 371 | 356 |
| 372 void ExtensionFileBrowserEventRouter::OnDeviceAdded( | 357 void ExtensionFileBrowserEventRouter::OnDeviceAdded( |
| 373 const std::string& device_path) { | 358 const std::string& device_path) { |
| 374 VLOG(1) << "Device added : " << device_path; | 359 VLOG(1) << "Device added : " << device_path; |
| 375 | 360 |
| 376 notifications_->RegisterDevice(device_path); | 361 notifications_->RegisterDevice(device_path); |
| 377 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, | 362 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 const std::string& device_path, bool success) { | 394 const std::string& device_path, bool success) { |
| 410 if (success) { | 395 if (success) { |
| 411 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 396 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
| 412 device_path); | 397 device_path); |
| 413 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, | 398 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, |
| 414 device_path); | 399 device_path); |
| 415 // Hide it after a couple of seconds. | 400 // Hide it after a couple of seconds. |
| 416 notifications_->HideNotificationDelayed( | 401 notifications_->HideNotificationDelayed( |
| 417 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); | 402 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); |
| 418 | 403 |
| 419 chromeos::disks::DiskMountManager::GetInstance()->MountPath( | 404 DiskMountManager::GetInstance()->MountPath(device_path, |
| 420 device_path, chromeos::MOUNT_TYPE_DEVICE); | 405 chromeos::MOUNT_TYPE_DEVICE); |
| 421 } else { | 406 } else { |
| 422 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 407 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
| 423 device_path); | 408 device_path); |
| 424 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, | 409 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, |
| 425 device_path); | 410 device_path); |
| 426 } | 411 } |
| 427 } | 412 } |
| 428 | 413 |
| 429 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. | 414 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. |
| 430 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( | 415 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 493 |
| 509 const FilePath& | 494 const FilePath& |
| 510 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { | 495 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { |
| 511 return virtual_path; | 496 return virtual_path; |
| 512 } | 497 } |
| 513 | 498 |
| 514 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch | 499 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch |
| 515 (const FilePath& path, FileWatcherDelegate* delegate) { | 500 (const FilePath& path, FileWatcherDelegate* delegate) { |
| 516 return file_watcher->Watch(path, delegate); | 501 return file_watcher->Watch(path, delegate); |
| 517 } | 502 } |
| OLD | NEW |