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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 573 |
574 void FileBrowserEventRouter::OnDeviceAdded( | 574 void FileBrowserEventRouter::OnDeviceAdded( |
575 const std::string& device_path) { | 575 const std::string& device_path) { |
576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
577 | 577 |
578 VLOG(1) << "Device added : " << device_path; | 578 VLOG(1) << "Device added : " << device_path; |
579 | 579 |
580 notifications_->RegisterDevice(device_path); | 580 notifications_->RegisterDevice(device_path); |
581 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, | 581 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, |
582 device_path, | 582 device_path, |
583 5000); | 583 base::TimeDelta::FromSeconds(5)); |
584 } | 584 } |
585 | 585 |
586 void FileBrowserEventRouter::OnDeviceRemoved( | 586 void FileBrowserEventRouter::OnDeviceRemoved( |
587 const std::string& device_path) { | 587 const std::string& device_path) { |
588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
589 | 589 |
590 VLOG(1) << "Device removed : " << device_path; | 590 VLOG(1) << "Device removed : " << device_path; |
591 notifications_->HideNotification(FileBrowserNotifications::DEVICE, | 591 notifications_->HideNotification(FileBrowserNotifications::DEVICE, |
592 device_path); | 592 device_path); |
593 notifications_->HideNotification(FileBrowserNotifications::DEVICE_FAIL, | 593 notifications_->HideNotification(FileBrowserNotifications::DEVICE_FAIL, |
(...skipping 24 matching lines...) Expand all Loading... |
618 const std::string& device_path, bool success) { | 618 const std::string& device_path, bool success) { |
619 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 619 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
620 | 620 |
621 if (success) { | 621 if (success) { |
622 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 622 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
623 device_path); | 623 device_path); |
624 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, | 624 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, |
625 device_path); | 625 device_path); |
626 // Hide it after a couple of seconds. | 626 // Hide it after a couple of seconds. |
627 notifications_->HideNotificationDelayed( | 627 notifications_->HideNotificationDelayed( |
628 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); | 628 FileBrowserNotifications::FORMAT_SUCCESS, |
| 629 device_path, |
| 630 base::TimeDelta::FromSeconds(4)); |
629 // MountPath auto-detects filesystem format if second argument is empty. | 631 // MountPath auto-detects filesystem format if second argument is empty. |
630 // The third argument (mount label) is not used in a disk mount operation. | 632 // The third argument (mount label) is not used in a disk mount operation. |
631 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), | 633 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), |
632 std::string(), | 634 std::string(), |
633 chromeos::MOUNT_TYPE_DEVICE); | 635 chromeos::MOUNT_TYPE_DEVICE); |
634 } else { | 636 } else { |
635 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 637 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
636 device_path); | 638 device_path); |
637 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, | 639 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, |
638 device_path); | 640 device_path); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 return scoped_refptr<RefcountedProfileKeyedService>( | 772 return scoped_refptr<RefcountedProfileKeyedService>( |
771 new FileBrowserEventRouter(profile)); | 773 new FileBrowserEventRouter(profile)); |
772 } | 774 } |
773 | 775 |
774 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { | 776 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { |
775 // Explicitly and always allow this router in guest login mode. see | 777 // Explicitly and always allow this router in guest login mode. see |
776 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 778 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
777 // for the details. | 779 // for the details. |
778 return true; | 780 return true; |
779 } | 781 } |
OLD | NEW |