| 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" | |
| 8 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 9 #include "base/memory/singleton.h" | |
| 10 #include "base/message_loop.h" | |
| 11 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 12 #include "base/values.h" | 9 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | 11 #include "chrome/browser/chromeos/login/user_manager.h" |
| 15 #include "chrome/browser/chromeos/notifications/system_notification.h" | 12 #include "chrome/browser/chromeos/notifications/system_notification.h" |
| 16 #include "chrome/browser/extensions/extension_event_names.h" | 13 #include "chrome/browser/extensions/extension_event_names.h" |
| 17 #include "chrome/browser/extensions/extension_event_router.h" | 14 #include "chrome/browser/extensions/extension_event_router.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/file_manager_util.h" | 16 #include "chrome/browser/extensions/file_manager_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 21 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 22 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "webkit/fileapi/file_system_types.h" | 22 #include "webkit/fileapi/file_system_types.h" |
| 26 #include "webkit/fileapi/file_system_util.h" | 23 #include "webkit/fileapi/file_system_util.h" |
| 27 | 24 |
| 28 namespace { | 25 const char kDiskAddedEventType[] = "added"; |
| 29 const char kDiskAddedEventType[] = "added"; | 26 const char kDiskRemovedEventType[] = "removed"; |
| 30 const char kDiskRemovedEventType[] = "removed"; | |
| 31 | 27 |
| 32 const char kPathChanged[] = "changed"; | 28 const char kPathChanged[] = "changed"; |
| 33 const char kPathWatchError[] = "error"; | 29 const char kPathWatchError[] = "error"; |
| 34 | 30 |
| 35 const char* DeviceTypeToString(chromeos::DeviceType type) { | 31 const char* DeviceTypeToString(chromeos::DeviceType type) { |
| 36 switch (type) { | 32 switch (type) { |
| 37 case chromeos::FLASH: | 33 case chromeos::FLASH: |
| 38 return "flash"; | 34 return "flash"; |
| 39 case chromeos::HDD: | 35 case chromeos::HDD: |
| 40 return "hdd"; | 36 return "hdd"; |
| 41 case chromeos::OPTICAL: | 37 case chromeos::OPTICAL: |
| 42 return "optical"; | 38 return "optical"; |
| 43 default: | 39 default: |
| 44 break; | 40 break; |
| 45 } | |
| 46 return "undefined"; | |
| 47 } | 41 } |
| 48 | 42 return "undefined"; |
| 49 DictionaryValue* DiskToDictionaryValue( | |
| 50 const chromeos::MountLibrary::Disk* disk) { | |
| 51 DictionaryValue* result = new DictionaryValue(); | |
| 52 result->SetString("mountPath", disk->mount_path()); | |
| 53 result->SetString("devicePath", disk->device_path()); | |
| 54 result->SetString("label", disk->device_label()); | |
| 55 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); | |
| 56 result->SetInteger("totalSizeKB", disk->total_size() / 1024); | |
| 57 result->SetBoolean("readOnly", disk->is_read_only()); | |
| 58 return result; | |
| 59 } | |
| 60 } | 43 } |
| 61 | 44 |
| 62 const char* MountErrorToString(chromeos::MountError error) { | 45 const char* MountErrorToString(chromeos::MountError error) { |
| 63 switch (error) { | 46 switch (error) { |
| 64 case chromeos::MOUNT_ERROR_NONE: | 47 case chromeos::MOUNT_ERROR_NONE: |
| 65 return "success"; | 48 return "success"; |
| 66 case chromeos::MOUNT_ERROR_UNKNOWN: | 49 case chromeos::MOUNT_ERROR_UNKNOWN: |
| 67 return "error_unknown"; | 50 return "error_unknown"; |
| 68 case chromeos::MOUNT_ERROR_INTERNAL: | 51 case chromeos::MOUNT_ERROR_INTERNAL: |
| 69 return "error_internal"; | 52 return "error_internal"; |
| 70 case chromeos::MOUNT_ERROR_UNKNOWN_FILESYSTEM: | 53 case chromeos::MOUNT_ERROR_UNKNOWN_FILESYSTEM: |
| 71 return "error_unknown_filesystem"; | 54 return "error_unknown_filesystem"; |
| 72 case chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM: | 55 case chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM: |
| 73 return "error_unsuported_filesystem"; | 56 return "error_unsuported_filesystem"; |
| 74 case chromeos::MOUNT_ERROR_INVALID_ARCHIVE: | 57 case chromeos::MOUNT_ERROR_INVALID_ARCHIVE: |
| 75 return "error_invalid_archive"; | 58 return "error_invalid_archive"; |
| 76 case chromeos::MOUNT_ERROR_LIBRARY_NOT_LOADED: | 59 case chromeos::MOUNT_ERROR_LIBRARY_NOT_LOADED: |
| 77 return "error_libcros_missing"; | 60 return "error_libcros_missing"; |
| 78 default: | 61 default: |
| 79 NOTREACHED(); | 62 NOTREACHED(); |
| 80 } | 63 } |
| 81 return ""; | 64 return ""; |
| 82 } | 65 } |
| 83 | 66 |
| 84 void HideFileBrowserNotificationExternally(const std::string& category, | 67 DictionaryValue* DiskToDictionaryValue( |
| 85 const std::string& system_path, ExtensionFileBrowserEventRouter* that) { | 68 const chromeos::MountLibrary::Disk* disk) { |
| 86 that->HideFileBrowserNotification(category, system_path); | 69 DictionaryValue* result = new DictionaryValue(); |
| 70 result->SetString("mountPath", disk->mount_path()); |
| 71 result->SetString("devicePath", disk->device_path()); |
| 72 result->SetString("label", disk->device_label()); |
| 73 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); |
| 74 result->SetInteger("totalSizeKB", disk->total_size() / 1024); |
| 75 result->SetBoolean("readOnly", disk->is_read_only()); |
| 76 return result; |
| 87 } | 77 } |
| 88 | 78 |
| 89 ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter( | 79 ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter( |
| 90 Profile* profile) | 80 Profile* profile) |
| 91 : delegate_(new ExtensionFileBrowserEventRouter::FileWatcherDelegate(this)), | 81 : delegate_(new ExtensionFileBrowserEventRouter::FileWatcherDelegate(this)), |
| 92 profile_(profile) { | 82 profile_(profile) { |
| 93 } | 83 } |
| 94 | 84 |
| 95 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 85 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
| 96 DCHECK(file_watchers_.empty()); | 86 DCHECK(file_watchers_.empty()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 165 |
| 176 void ExtensionFileBrowserEventRouter::DeviceChanged( | 166 void ExtensionFileBrowserEventRouter::DeviceChanged( |
| 177 chromeos::MountLibraryEventType event, | 167 chromeos::MountLibraryEventType event, |
| 178 const std::string& device_path) { | 168 const std::string& device_path) { |
| 179 if (event == chromeos::MOUNT_DEVICE_ADDED) { | 169 if (event == chromeos::MOUNT_DEVICE_ADDED) { |
| 180 OnDeviceAdded(device_path); | 170 OnDeviceAdded(device_path); |
| 181 } else if (event == chromeos::MOUNT_DEVICE_REMOVED) { | 171 } else if (event == chromeos::MOUNT_DEVICE_REMOVED) { |
| 182 OnDeviceRemoved(device_path); | 172 OnDeviceRemoved(device_path); |
| 183 } else if (event == chromeos::MOUNT_DEVICE_SCANNED) { | 173 } else if (event == chromeos::MOUNT_DEVICE_SCANNED) { |
| 184 OnDeviceScanned(device_path); | 174 OnDeviceScanned(device_path); |
| 185 } else if (event == chromeos::MOUNT_FORMATTING_STARTED) { | |
| 186 OnFormattingStarted(device_path); | |
| 187 } else if (event == chromeos::MOUNT_FORMATTING_FINISHED) { | |
| 188 OnFormattingFinished(device_path); | |
| 189 } | 175 } |
| 190 } | 176 } |
| 191 void ExtensionFileBrowserEventRouter::MountCompleted( | 177 void ExtensionFileBrowserEventRouter::MountCompleted( |
| 192 chromeos::MountLibrary::MountEvent event_type, | 178 chromeos::MountLibrary::MountEvent event_type, |
| 193 chromeos::MountError error_code, | 179 chromeos::MountError error_code, |
| 194 const chromeos::MountLibrary::MountPointInfo& mount_info) { | 180 const chromeos::MountLibrary::MountPointInfo& mount_info) { |
| 195 DispatchMountCompletedEvent(event_type, error_code, mount_info); | 181 DispatchMountCompletedEvent(event_type, error_code, mount_info); |
| 196 } | 182 } |
| 197 | 183 |
| 198 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( | 184 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 300 |
| 315 void ExtensionFileBrowserEventRouter::OnDiskAdded( | 301 void ExtensionFileBrowserEventRouter::OnDiskAdded( |
| 316 const chromeos::MountLibrary::Disk* disk) { | 302 const chromeos::MountLibrary::Disk* disk) { |
| 317 VLOG(1) << "Disk added: " << disk->device_path(); | 303 VLOG(1) << "Disk added: " << disk->device_path(); |
| 318 if (disk->device_path().empty()) { | 304 if (disk->device_path().empty()) { |
| 319 VLOG(1) << "Empty system path for " << disk->device_path(); | 305 VLOG(1) << "Empty system path for " << disk->device_path(); |
| 320 return; | 306 return; |
| 321 } | 307 } |
| 322 if (disk->is_parent()) { | 308 if (disk->is_parent()) { |
| 323 if (!disk->has_media()) { | 309 if (!disk->has_media()) { |
| 324 HideFileBrowserNotification("MOUNT", disk->system_path()); | 310 HideDeviceNotification(disk->system_path()); |
| 325 return; | 311 return; |
| 326 } | 312 } |
| 327 } | 313 } |
| 328 | 314 |
| 329 // If disk is not mounted yet, give it a try. | 315 // If disk is not mounted yet, give it a try. |
| 330 if (disk->mount_path().empty()) { | 316 if (disk->mount_path().empty()) { |
| 331 // Initiate disk mount operation. | 317 // Initiate disk mount operation. |
| 332 chromeos::MountLibrary* lib = | 318 chromeos::MountLibrary* lib = |
| 333 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 319 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| 334 lib->MountPath(disk->device_path().c_str(), | 320 lib->MountPath(disk->device_path().c_str(), |
| 335 chromeos::MOUNT_TYPE_DEVICE, | 321 chromeos::MOUNT_TYPE_DEVICE, |
| 336 chromeos::MountPathOptions()); // Unused. | 322 chromeos::MountPathOptions()); // Unused. |
| 337 } | 323 } |
| 338 DispatchMountEvent(disk, true); | |
| 339 } | 324 } |
| 340 | 325 |
| 341 void ExtensionFileBrowserEventRouter::OnDiskRemoved( | 326 void ExtensionFileBrowserEventRouter::OnDiskRemoved( |
| 342 const chromeos::MountLibrary::Disk* disk) { | 327 const chromeos::MountLibrary::Disk* disk) { |
| 343 VLOG(1) << "Disk removed: " << disk->device_path(); | 328 VLOG(1) << "Disk removed: " << disk->device_path(); |
| 344 HideFileBrowserNotification("MOUNT", disk->system_path()); | 329 HideDeviceNotification(disk->system_path()); |
| 345 MountPointMap::iterator iter = mounted_devices_.find(disk->device_path()); | 330 MountPointMap::iterator iter = mounted_devices_.find(disk->device_path()); |
| 346 if (iter == mounted_devices_.end()) | 331 if (iter == mounted_devices_.end()) |
| 347 return; | 332 return; |
| 348 | 333 |
| 349 chromeos::MountLibrary* lib = | 334 chromeos::MountLibrary* lib = |
| 350 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 335 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| 351 // TODO(zelidrag): This for some reason does not work as advertized. | 336 // TODO(zelidrag): This for some reason does not work as advertized. |
| 352 // we might need to clean up mount directory on FILE thread here as well. | 337 // we might need to clean up mount directory on FILE thread here as well. |
| 353 lib->UnmountPath(disk->device_path().c_str()); | 338 lib->UnmountPath(disk->device_path().c_str()); |
| 339 |
| 354 DispatchMountEvent(disk, false); | 340 DispatchMountEvent(disk, false); |
| 355 mounted_devices_.erase(iter); | 341 mounted_devices_.erase(iter); |
| 356 } | 342 } |
| 357 | 343 |
| 358 void ExtensionFileBrowserEventRouter::OnDiskChanged( | 344 void ExtensionFileBrowserEventRouter::OnDiskChanged( |
| 359 const chromeos::MountLibrary::Disk* disk) { | 345 const chromeos::MountLibrary::Disk* disk) { |
| 360 VLOG(1) << "Disk changed : " << disk->device_path(); | 346 VLOG(1) << "Disk changed : " << disk->device_path(); |
| 361 if (!disk->mount_path().empty()) { | 347 if (!disk->mount_path().empty()) { |
| 362 HideFileBrowserNotification("MOUNT", disk->system_path()); | 348 HideDeviceNotification(disk->system_path()); |
| 363 // Remember this mount point. | 349 // Remember this mount point. |
| 364 if (mounted_devices_.find(disk->device_path()) == mounted_devices_.end()) { | 350 if (mounted_devices_.find(disk->device_path()) == mounted_devices_.end()) { |
| 365 mounted_devices_.insert( | 351 mounted_devices_.insert( |
| 366 std::pair<std::string, std::string>(disk->device_path(), | 352 std::pair<std::string, std::string>(disk->device_path(), |
| 367 disk->mount_path())); | 353 disk->mount_path())); |
| 368 DispatchMountEvent(disk, true); | 354 DispatchMountEvent(disk, true); |
| 369 HideFileBrowserNotification("MOUNT", disk->system_path()); | 355 HideDeviceNotification(disk->system_path()); |
| 370 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(disk->mount_path())); | 356 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(disk->mount_path())); |
| 371 } | 357 } |
| 372 } | 358 } |
| 373 } | 359 } |
| 374 | 360 |
| 375 void ExtensionFileBrowserEventRouter::OnDeviceAdded( | 361 void ExtensionFileBrowserEventRouter::OnDeviceAdded( |
| 376 const std::string& device_path) { | 362 const std::string& device_path) { |
| 377 VLOG(1) << "Device added : " << device_path; | 363 VLOG(1) << "Device added : " << device_path; |
| 378 // TODO(zelidrag): Find better icon here. | 364 // TODO(zelidrag): Find better icon here. |
| 379 ShowFileBrowserNotification("MOUNT", device_path, IDR_PAGEINFO_INFO, | 365 ShowDeviceNotification(device_path, IDR_PAGEINFO_INFO, |
| 380 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_DETECTION_TITLE), | |
| 381 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_SCANNING_MESSAGE)); | 366 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_SCANNING_MESSAGE)); |
| 367 |
| 382 } | 368 } |
| 383 | 369 |
| 384 void ExtensionFileBrowserEventRouter::OnDeviceRemoved( | 370 void ExtensionFileBrowserEventRouter::OnDeviceRemoved( |
| 385 const std::string& system_path) { | 371 const std::string& system_path) { |
| 386 HideFileBrowserNotification("MOUNT", system_path); | 372 HideDeviceNotification(system_path); |
| 387 } | 373 } |
| 388 | 374 |
| 389 void ExtensionFileBrowserEventRouter::OnDeviceScanned( | 375 void ExtensionFileBrowserEventRouter::OnDeviceScanned( |
| 390 const std::string& device_path) { | 376 const std::string& device_path) { |
| 391 VLOG(1) << "Device scanned : " << device_path; | 377 VLOG(1) << "Device scanned : " << device_path; |
| 392 } | 378 } |
| 393 | 379 |
| 394 void ExtensionFileBrowserEventRouter::OnFormattingStarted( | 380 void ExtensionFileBrowserEventRouter::ShowDeviceNotification( |
| 395 const std::string& device_path) { | 381 const std::string& system_path, int icon_resource_id, |
| 396 if (device_path[0] == '!') { | 382 const string16& message) { |
| 397 ShowFileBrowserNotification("FORMAT_FINISHED", device_path.substr(1), | 383 NotificationMap::iterator iter = FindNotificationForPath(system_path); |
| 398 IDR_PAGEINFO_WARNING_MAJOR, | 384 std::string mount_path; |
| 399 l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), | 385 if (iter != notifications_.end()) { |
| 400 l10n_util::GetStringUTF16(IDS_FORMATTING_STARTED_FAILURE_MESSAGE)); | 386 iter->second->Show(message, false, false); |
| 401 } else { | 387 } else { |
| 402 ShowFileBrowserNotification("FORMAT", device_path, IDR_PAGEINFO_INFO, | 388 if (!profile_) { |
| 403 l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_PENDING_TITLE), | 389 NOTREACHED(); |
| 404 l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_PENDING_MESSAGE)); | 390 return; |
| 391 } |
| 392 chromeos::SystemNotification* notification = |
| 393 new chromeos::SystemNotification( |
| 394 profile_, |
| 395 system_path, |
| 396 icon_resource_id, |
| 397 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_DETECTION_TITLE)); |
| 398 notifications_.insert(NotificationMap::value_type(system_path, |
| 399 linked_ptr<chromeos::SystemNotification>(notification))); |
| 400 notification->Show(message, false, false); |
| 405 } | 401 } |
| 406 } | 402 } |
| 407 | 403 |
| 408 void ExtensionFileBrowserEventRouter::OnFormattingFinished( | 404 void ExtensionFileBrowserEventRouter::HideDeviceNotification( |
| 409 const std::string& device_path) { | 405 const std::string& system_path) { |
| 410 if (device_path[0] == '!') { | 406 NotificationMap::iterator iter = FindNotificationForPath(system_path); |
| 411 HideFileBrowserNotification("FORMAT", device_path.substr(1)); | |
| 412 ShowFileBrowserNotification("FORMAT_FINISHED", device_path.substr(1), | |
| 413 IDR_PAGEINFO_WARNING_MAJOR, | |
| 414 l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), | |
| 415 l10n_util::GetStringUTF16(IDS_FORMATTING_FINISHED_FAILURE_MESSAGE)); | |
| 416 } else { | |
| 417 HideFileBrowserNotification("FORMAT", device_path); | |
| 418 ShowFileBrowserNotification("FORMAT_FINISHED", device_path, | |
| 419 IDR_PAGEINFO_INFO, | |
| 420 l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), | |
| 421 l10n_util::GetStringUTF16(IDS_FORMATTING_FINISHED_SUCCESS_MESSAGE)); | |
| 422 // Hide it after a couple of seconds | |
| 423 MessageLoop::current()->PostDelayedTask(FROM_HERE, | |
| 424 base::Bind(&HideFileBrowserNotificationExternally, "FORMAT_FINISHED", | |
| 425 device_path, this), | |
| 426 4000); | |
| 427 chromeos::MountLibrary* lib = | |
| 428 chromeos::CrosLibrary::Get()->GetMountLibrary(); | |
| 429 lib->MountPath(device_path.c_str(), | |
| 430 chromeos::MOUNT_TYPE_DEVICE, | |
| 431 chromeos::MountPathOptions()); | |
| 432 } | |
| 433 } | |
| 434 | |
| 435 void ExtensionFileBrowserEventRouter::ShowFileBrowserNotification( | |
| 436 const std::string& category, const std::string& system_path, | |
| 437 int icon_resource_id, const string16& title, const string16& message) { | |
| 438 std::string notification_id = category + system_path; | |
| 439 // New notification always created because, it might have been closed by now. | |
| 440 NotificationMap::iterator iter = FindNotificationForId(notification_id); | |
| 441 if (iter != notifications_.end()) | |
| 442 notifications_.erase(iter); | |
| 443 if (!profile_) { | |
| 444 NOTREACHED(); | |
| 445 return; | |
| 446 } | |
| 447 chromeos::SystemNotification* notification = | |
| 448 new chromeos::SystemNotification( | |
| 449 profile_, | |
| 450 notification_id, | |
| 451 icon_resource_id, | |
| 452 title); | |
| 453 notifications_.insert(NotificationMap::value_type(notification_id, | |
| 454 linked_ptr<chromeos::SystemNotification>(notification))); | |
| 455 notification->Show(message, false, false); | |
| 456 } | |
| 457 | |
| 458 void ExtensionFileBrowserEventRouter::HideFileBrowserNotification( | |
| 459 const std::string& category, const std::string& system_path) { | |
| 460 NotificationMap::iterator iter = FindNotificationForId( | |
| 461 category + system_path); | |
| 462 if (iter != notifications_.end()) { | 407 if (iter != notifications_.end()) { |
| 463 iter->second->Hide(); | 408 iter->second->Hide(); |
| 464 notifications_.erase(iter); | 409 notifications_.erase(iter); |
| 465 } | 410 } |
| 466 } | 411 } |
| 467 | 412 |
| 468 ExtensionFileBrowserEventRouter::NotificationMap::iterator | 413 ExtensionFileBrowserEventRouter::NotificationMap::iterator |
| 469 ExtensionFileBrowserEventRouter::FindNotificationForId( | 414 ExtensionFileBrowserEventRouter::FindNotificationForPath( |
| 470 const std::string& notification_id) { | 415 const std::string& system_path) { |
| 471 for (NotificationMap::iterator iter = notifications_.begin(); | 416 for (NotificationMap::iterator iter = notifications_.begin(); |
| 472 iter != notifications_.end(); | 417 iter != notifications_.end(); |
| 473 ++iter) { | 418 ++iter) { |
| 474 const std::string& notification_device_path = iter->first; | 419 const std::string& notification_device_path = iter->first; |
| 475 // Doing a sub string match so that we find if this new one is a subdevice | 420 // Doing a sub string match so that we find if this new one is a subdevice |
| 476 // of another already inserted device. | 421 // of another already inserted device. |
| 477 if (StartsWithASCII(notification_id, notification_device_path, true)) { | 422 if (StartsWithASCII(system_path, notification_device_path, true)) { |
| 478 return iter; | 423 return iter; |
| 479 } | 424 } |
| 480 } | 425 } |
| 481 return notifications_.end(); | 426 return notifications_.end(); |
| 482 } | 427 } |
| 483 | 428 |
| 484 | 429 |
| 485 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. | 430 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. |
| 486 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( | 431 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( |
| 487 ExtensionFileBrowserEventRouter* router) : router_(router) { | 432 ExtensionFileBrowserEventRouter* router) : router_(router) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 505 &FileWatcherDelegate::HandleFileWatchOnUIThread, | 450 &FileWatcherDelegate::HandleFileWatchOnUIThread, |
| 506 local_path, | 451 local_path, |
| 507 true)); // got_error | 452 true)); // got_error |
| 508 } | 453 } |
| 509 | 454 |
| 510 void | 455 void |
| 511 ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( | 456 ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( |
| 512 const FilePath& local_path, bool got_error) { | 457 const FilePath& local_path, bool got_error) { |
| 513 router_->HandleFileWatchNotification(local_path, got_error); | 458 router_->HandleFileWatchNotification(local_path, got_error); |
| 514 } | 459 } |
| OLD | NEW |