| 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_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" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 void FileBrowserEventRouter::OnDiskAdded( | 407 void FileBrowserEventRouter::OnDiskAdded( |
| 408 const DiskMountManager::Disk* disk) { | 408 const DiskMountManager::Disk* disk) { |
| 409 VLOG(1) << "Disk added: " << disk->device_path(); | 409 VLOG(1) << "Disk added: " << disk->device_path(); |
| 410 if (disk->device_path().empty()) { | 410 if (disk->device_path().empty()) { |
| 411 VLOG(1) << "Empty system path for " << disk->device_path(); | 411 VLOG(1) << "Empty system path for " << disk->device_path(); |
| 412 return; | 412 return; |
| 413 } | 413 } |
| 414 | 414 |
| 415 // If disk is not mounted yet and it has media, give it a try. | 415 // If disk is not mounted yet and it has media, give it a try. |
| 416 if (disk->mount_path().empty() && disk->has_media()) { | 416 if (disk->mount_path().empty() && disk->has_media()) { |
| 417 // Initiate disk mount operation. | 417 // Initiate disk mount operation. Here MountPath auto-detects the |
| 418 // filesystem format if the second argument is empty. |
| 418 DiskMountManager::GetInstance()->MountPath( | 419 DiskMountManager::GetInstance()->MountPath( |
| 419 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE); | 420 disk->device_path(), std::string(), chromeos::MOUNT_TYPE_DEVICE); |
| 420 } else { | 421 } else { |
| 421 // Either the disk was mounted or it has no media. In both cases we don't | 422 // Either the disk was mounted or it has no media. In both cases we don't |
| 422 // want the Scanning notification to persist. | 423 // want the Scanning notification to persist. |
| 423 notifications_->HideNotification(FileBrowserNotifications::DEVICE, | 424 notifications_->HideNotification(FileBrowserNotifications::DEVICE, |
| 424 disk->system_path_prefix()); | 425 disk->system_path_prefix()); |
| 425 } | 426 } |
| 426 DispatchDiskEvent(disk, true); | 427 DispatchDiskEvent(disk, true); |
| 427 } | 428 } |
| 428 | 429 |
| 429 void FileBrowserEventRouter::OnDiskRemoved( | 430 void FileBrowserEventRouter::OnDiskRemoved( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 void FileBrowserEventRouter::OnFormattingFinished( | 476 void FileBrowserEventRouter::OnFormattingFinished( |
| 476 const std::string& device_path, bool success) { | 477 const std::string& device_path, bool success) { |
| 477 if (success) { | 478 if (success) { |
| 478 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 479 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
| 479 device_path); | 480 device_path); |
| 480 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, | 481 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, |
| 481 device_path); | 482 device_path); |
| 482 // Hide it after a couple of seconds. | 483 // Hide it after a couple of seconds. |
| 483 notifications_->HideNotificationDelayed( | 484 notifications_->HideNotificationDelayed( |
| 484 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); | 485 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); |
| 485 | 486 // MountPath auto-detects filesystem format if second argument is empty. |
| 486 DiskMountManager::GetInstance()->MountPath(device_path, | 487 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), |
| 487 chromeos::MOUNT_TYPE_DEVICE); | 488 chromeos::MOUNT_TYPE_DEVICE); |
| 488 } else { | 489 } else { |
| 489 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 490 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
| 490 device_path); | 491 device_path); |
| 491 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, | 492 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, |
| 492 device_path); | 493 device_path); |
| 493 } | 494 } |
| 494 } | 495 } |
| 495 | 496 |
| 496 // FileBrowserEventRouter::WatcherDelegate methods. | 497 // FileBrowserEventRouter::WatcherDelegate methods. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return scoped_refptr<RefcountedProfileKeyedService>( | 618 return scoped_refptr<RefcountedProfileKeyedService>( |
| 618 new FileBrowserEventRouter(profile)); | 619 new FileBrowserEventRouter(profile)); |
| 619 } | 620 } |
| 620 | 621 |
| 621 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { | 622 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { |
| 622 // Explicitly and always allow this router in guest login mode. see | 623 // Explicitly and always allow this router in guest login mode. see |
| 623 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 624 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
| 624 // for the details. | 625 // for the details. |
| 625 return true; | 626 return true; |
| 626 } | 627 } |
| OLD | NEW |