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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 490643005: Files.app: Start to use DeviceEventRouter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_manager/event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/app_mode/app_mode_utils.h" 15 #include "chrome/browser/app_mode/app_mode_utils.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 17 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
18 #include "chrome/browser/chromeos/drive/file_change.h" 18 #include "chrome/browser/chromeos/drive/file_change.h"
19 #include "chrome/browser/chromeos/drive/file_system_interface.h" 19 #include "chrome/browser/chromeos/drive/file_system_interface.h"
20 #include "chrome/browser/chromeos/drive/file_system_util.h" 20 #include "chrome/browser/chromeos/drive/file_system_util.h"
21 #include "chrome/browser/chromeos/extensions/file_manager/device_event_router.h"
21 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 22 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
22 #include "chrome/browser/chromeos/file_manager/app_id.h" 23 #include "chrome/browser/chromeos/file_manager/app_id.h"
23 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 24 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
24 #include "chrome/browser/chromeos/file_manager/open_util.h" 25 #include "chrome/browser/chromeos/file_manager/open_util.h"
25 #include "chrome/browser/chromeos/file_manager/volume_manager.h" 26 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
26 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 27 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
27 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 28 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
28 #include "chrome/browser/drive/drive_service_interface.h" 29 #include "chrome/browser/drive/drive_service_interface.h"
29 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
30 #include "chrome/browser/extensions/extension_util.h" 31 #include "chrome/browser/extensions/extension_util.h"
31 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/profiles/profile_manager.h" 33 #include "chrome/browser/profiles/profile_manager.h"
33 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
36 #include "chromeos/dbus/dbus_thread_manager.h"
35 #include "chromeos/login/login_state.h" 37 #include "chromeos/login/login_state.h"
36 #include "chromeos/network/network_handler.h" 38 #include "chromeos/network/network_handler.h"
37 #include "chromeos/network/network_state_handler.h" 39 #include "chromeos/network/network_state_handler.h"
38 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/notification_source.h" 41 #include "content/public/browser/notification_source.h"
40 #include "content/public/browser/render_process_host.h" 42 #include "content/public/browser/render_process_host.h"
41 #include "content/public/browser/storage_partition.h" 43 #include "content/public/browser/storage_partition.h"
42 #include "extensions/browser/event_router.h" 44 #include "extensions/browser/event_router.h"
43 #include "extensions/browser/extension_host.h" 45 #include "extensions/browser/extension_host.h"
44 #include "extensions/browser/extension_prefs.h" 46 #include "extensions/browser/extension_prefs.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return false; 280 return false;
279 } else { 281 } else {
280 *last_time = now; 282 *last_time = now;
281 return true; 283 return true;
282 } 284 }
283 } 285 }
284 286
285 // Obtains whether the Files.app should handle the volume or not. 287 // Obtains whether the Files.app should handle the volume or not.
286 bool ShouldShowNotificationForVolume( 288 bool ShouldShowNotificationForVolume(
287 Profile* profile, 289 Profile* profile,
288 file_browser_private::MountCompletedEventType event_type, 290 const DeviceEventRouter& device_event_router,
289 chromeos::MountError error, 291 const VolumeInfo& volume_info) {
290 const VolumeInfo& volume_info,
291 bool is_remounting) {
292 if (event_type != file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_MOUNT)
293 return false;
294
295 if (volume_info.type != VOLUME_TYPE_MTP && 292 if (volume_info.type != VOLUME_TYPE_MTP &&
296 volume_info.type != VOLUME_TYPE_REMOVABLE_DISK_PARTITION) { 293 volume_info.type != VOLUME_TYPE_REMOVABLE_DISK_PARTITION) {
297 return false; 294 return false;
298 } 295 }
299 296
300 if (error != chromeos::MOUNT_ERROR_NONE) 297 if (device_event_router.is_resuming() || device_event_router.is_starting_up())
301 return false;
302
303 if (is_remounting)
304 return false; 298 return false;
305 299
306 // Do not attempt to open File Manager while the login is in progress or 300 // Do not attempt to open File Manager while the login is in progress or
307 // the screen is locked or running in kiosk app mode and make sure the file 301 // the screen is locked or running in kiosk app mode and make sure the file
308 // manager is opened only for the active user. 302 // manager is opened only for the active user.
309 if (chromeos::LoginDisplayHostImpl::default_host() || 303 if (chromeos::LoginDisplayHostImpl::default_host() ||
310 chromeos::ScreenLocker::default_screen_locker() || 304 chromeos::ScreenLocker::default_screen_locker() ||
311 chrome::IsRunningInForcedAppMode() || 305 chrome::IsRunningInForcedAppMode() ||
312 profile != ProfileManager::GetActiveUserProfile()) { 306 profile != ProfileManager::GetActiveUserProfile()) {
313 return false; 307 return false;
314 } 308 }
315 309
316 // Do not pop-up the File Manager, if the recovery tool is running. 310 // Do not pop-up the File Manager, if the recovery tool is running.
317 if (IsRecoveryToolRunning(profile)) 311 if (IsRecoveryToolRunning(profile))
318 return false; 312 return false;
319 313
320 // If the disable-default-apps flag is on, Files.app is not opened 314 // If the disable-default-apps flag is on, Files.app is not opened
321 // automatically on device mount not to obstruct the manual test. 315 // automatically on device mount not to obstruct the manual test.
322 if (CommandLine::ForCurrentProcess()->HasSwitch( 316 if (CommandLine::ForCurrentProcess()->HasSwitch(
323 switches::kDisableDefaultApps)) { 317 switches::kDisableDefaultApps)) {
324 return false; 318 return false;
325 } 319 }
326 320
327 return true; 321 return true;
328 } 322 }
329 323
324 // Sub-part of the event router for handling device events.
325 class DeviceEventRouterImpl : public DeviceEventRouter {
326 public:
327 explicit DeviceEventRouterImpl(Profile* profile) : profile_(profile) {}
328
329 // DeviceEventRouter overrides.
330 virtual void OnDeviceEvent(file_browser_private::DeviceEventType type,
331 const std::string& device_path) OVERRIDE {
332 DCHECK_CURRENTLY_ON(BrowserThread::UI);
333
334 file_browser_private::DeviceEvent event;
335 event.type = type;
336 event.device_path = device_path;
337
338 BroadcastEvent(profile_,
339 file_browser_private::OnDeviceChanged::kEventName,
340 file_browser_private::OnDeviceChanged::Create(event));
341 }
342
343 // DeviceEventRouter overrides.
344 virtual bool IsExternalStorageDisabled() OVERRIDE {
345 DCHECK_CURRENTLY_ON(BrowserThread::UI);
346 return profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled);
347 }
348
349 private:
350 Profile* const profile_;
351
352 DISALLOW_COPY_AND_ASSIGN(DeviceEventRouterImpl);
353 };
354
330 } // namespace 355 } // namespace
331 356
332 // Pass dummy value to JobInfo's constructor for make it default constructible. 357 // Pass dummy value to JobInfo's constructor for make it default constructible.
333 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus() 358 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus()
334 : job_info(drive::TYPE_DOWNLOAD_FILE) { 359 : job_info(drive::TYPE_DOWNLOAD_FILE) {
335 } 360 }
336 361
337 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus( 362 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus(
338 const drive::JobInfo& info, const std::string& status) 363 const drive::JobInfo& info, const std::string& status)
339 : job_info(info), status(status) { 364 : job_info(info), status(status) {
340 } 365 }
341 366
342 EventRouter::EventRouter(Profile* profile) 367 EventRouter::EventRouter(Profile* profile)
343 : pref_change_registrar_(new PrefChangeRegistrar), 368 : pref_change_registrar_(new PrefChangeRegistrar),
344 profile_(profile), 369 profile_(profile),
345 multi_user_window_manager_observer_registered_(false), 370 multi_user_window_manager_observer_registered_(false),
371 device_event_router_(new DeviceEventRouterImpl(profile)),
346 weak_factory_(this) { 372 weak_factory_(this) {
347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 373 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
348 } 374 }
349 375
350 EventRouter::~EventRouter() { 376 EventRouter::~EventRouter() {
351 } 377 }
352 378
353 void EventRouter::Shutdown() { 379 void EventRouter::Shutdown() {
354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
355 381
356 DLOG_IF(WARNING, !file_watchers_.empty()) 382 DLOG_IF(WARNING, !file_watchers_.empty())
357 << "Not all file watchers are " 383 << "Not all file watchers are "
358 << "removed. This can happen when Files.app is open during shutdown."; 384 << "removed. This can happen when Files.app is open during shutdown.";
359 STLDeleteValues(&file_watchers_); 385 STLDeleteValues(&file_watchers_);
360 if (!profile_) { 386 if (!profile_) {
361 NOTREACHED(); 387 NOTREACHED();
362 return; 388 return;
363 } 389 }
364 390
365 pref_change_registrar_->RemoveAll(); 391 pref_change_registrar_->RemoveAll();
366 392
367 if (NetworkHandler::IsInitialized()) { 393 if (NetworkHandler::IsInitialized()) {
368 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, 394 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
369 FROM_HERE); 395 FROM_HERE);
370 } 396 }
371 397
372 DriveIntegrationService* integration_service = 398 DriveIntegrationService* const integration_service =
373 DriveIntegrationServiceFactory::FindForProfile(profile_); 399 DriveIntegrationServiceFactory::FindForProfile(profile_);
374 if (integration_service) { 400 if (integration_service) {
375 integration_service->file_system()->RemoveObserver(this); 401 integration_service->file_system()->RemoveObserver(this);
376 integration_service->drive_service()->RemoveObserver(this); 402 integration_service->drive_service()->RemoveObserver(this);
377 integration_service->job_list()->RemoveObserver(this); 403 integration_service->job_list()->RemoveObserver(this);
378 } 404 }
379 405
380 VolumeManager* volume_manager = VolumeManager::Get(profile_); 406 VolumeManager* const volume_manager = VolumeManager::Get(profile_);
381 if (volume_manager) 407 if (volume_manager) {
382 volume_manager->RemoveObserver(this); 408 volume_manager->RemoveObserver(this);
409 volume_manager->RemoveObserver(device_event_router_.get());
410 }
411
412 chromeos::PowerManagerClient* const power_manager_client =
413 chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
414 power_manager_client->RemoveObserver(device_event_router_.get());
383 415
384 chrome::MultiUserWindowManager* const multi_user_window_manager = 416 chrome::MultiUserWindowManager* const multi_user_window_manager =
385 chrome::MultiUserWindowManager::GetInstance(); 417 chrome::MultiUserWindowManager::GetInstance();
386 if (multi_user_window_manager && 418 if (multi_user_window_manager &&
387 multi_user_window_manager_observer_registered_) { 419 multi_user_window_manager_observer_registered_) {
388 multi_user_window_manager_observer_registered_ = false; 420 multi_user_window_manager_observer_registered_ = false;
389 multi_user_window_manager->RemoveObserver(this); 421 multi_user_window_manager->RemoveObserver(this);
390 } 422 }
391 423
392 profile_ = NULL; 424 profile_ = NULL;
393 } 425 }
394 426
395 void EventRouter::ObserveEvents() { 427 void EventRouter::ObserveEvents() {
396 if (!profile_) { 428 if (!profile_) {
397 NOTREACHED(); 429 NOTREACHED();
398 return; 430 return;
399 } 431 }
400 if (!chromeos::LoginState::IsInitialized() || 432 if (!chromeos::LoginState::IsInitialized() ||
401 !chromeos::LoginState::Get()->IsUserLoggedIn()) { 433 !chromeos::LoginState::Get()->IsUserLoggedIn()) {
402 return; 434 return;
403 } 435 }
404 436
437 // Ignore device events for the first few seconds.
438 device_event_router_->Startup();
439
405 // VolumeManager's construction triggers DriveIntegrationService's 440 // VolumeManager's construction triggers DriveIntegrationService's
406 // construction, so it is necessary to call VolumeManager's Get before 441 // construction, so it is necessary to call VolumeManager's Get before
407 // accessing DriveIntegrationService. 442 // accessing DriveIntegrationService.
408 VolumeManager* volume_manager = VolumeManager::Get(profile_); 443 VolumeManager* const volume_manager = VolumeManager::Get(profile_);
409 if (volume_manager) 444 if (volume_manager) {
410 volume_manager->AddObserver(this); 445 volume_manager->AddObserver(this);
446 volume_manager->AddObserver(device_event_router_.get());
447 }
411 448
412 DriveIntegrationService* integration_service = 449 chromeos::PowerManagerClient* const power_manager_client =
450 chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
451 power_manager_client->AddObserver(device_event_router_.get());
452
453 DriveIntegrationService* const integration_service =
413 DriveIntegrationServiceFactory::FindForProfile(profile_); 454 DriveIntegrationServiceFactory::FindForProfile(profile_);
414 if (integration_service) { 455 if (integration_service) {
415 integration_service->drive_service()->AddObserver(this); 456 integration_service->drive_service()->AddObserver(this);
416 integration_service->file_system()->AddObserver(this); 457 integration_service->file_system()->AddObserver(this);
417 integration_service->job_list()->AddObserver(this); 458 integration_service->job_list()->AddObserver(this);
418 } 459 }
419 460
420 if (NetworkHandler::IsInitialized()) { 461 if (NetworkHandler::IsInitialized()) {
421 NetworkHandler::Get()->network_state_handler()->AddObserver(this, 462 NetworkHandler::Get()->network_state_handler()->AddObserver(this,
422 FROM_HERE); 463 FROM_HERE);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 event.entry.additional_properties.SetString( 858 event.entry.additional_properties.SetString(
818 "fileFullPath", "/" + entry_definition.full_path.value()); 859 "fileFullPath", "/" + entry_definition.full_path.value());
819 event.entry.additional_properties.SetBoolean("fileIsDirectory", 860 event.entry.additional_properties.SetBoolean("fileIsDirectory",
820 entry_definition.is_directory); 861 entry_definition.is_directory);
821 862
822 BroadcastEvent(profile_, 863 BroadcastEvent(profile_,
823 file_browser_private::OnDirectoryChanged::kEventName, 864 file_browser_private::OnDirectoryChanged::kEventName,
824 file_browser_private::OnDirectoryChanged::Create(event)); 865 file_browser_private::OnDirectoryChanged::Create(event));
825 } 866 }
826 867
827 void EventRouter::DispatchDeviceEvent(
828 file_browser_private::DeviceEventType type,
829 const std::string& device_path) {
830 file_browser_private::DeviceEvent event;
831
832 event.type = type;
833 event.device_path = device_path;
834 BroadcastEvent(profile_,
835 file_browser_private::OnDeviceChanged::kEventName,
836 file_browser_private::OnDeviceChanged::Create(event));
837 }
838
839 void EventRouter::OnDiskAdded( 868 void EventRouter::OnDiskAdded(
840 const DiskMountManager::Disk& disk, bool mounting) { 869 const DiskMountManager::Disk& disk, bool mounting) {
841 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 870 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
842 871 // Do nothing.
843 if (!mounting) {
844 // If the disk is not being mounted, we don't want the Scanning
845 // notification to persist.
846 DispatchDeviceEvent(
847 file_browser_private::DEVICE_EVENT_TYPE_SCAN_CANCELED,
848 disk.system_path_prefix());
849 }
850 } 872 }
851 873
852 void EventRouter::OnDiskRemoved(const DiskMountManager::Disk& disk) { 874 void EventRouter::OnDiskRemoved(const DiskMountManager::Disk& disk) {
853 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
854 // Do nothing. 876 // Do nothing.
855 } 877 }
856 878
857 void EventRouter::OnDeviceAdded(const std::string& device_path) { 879 void EventRouter::OnDeviceAdded(const std::string& device_path) {
858 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 880 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
859 881 // Do nothing.
860 // If the policy is set instead of showing the new device notification,
861 // we show a notification that the operation is not permitted.
862 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
863 DispatchDeviceEvent(
864 file_browser_private::DEVICE_EVENT_TYPE_DISABLED,
865 device_path);
866 return;
867 }
868
869 DispatchDeviceEvent(
870 file_browser_private::DEVICE_EVENT_TYPE_ADDED,
871 device_path);
872 } 882 }
873 883
874 void EventRouter::OnDeviceRemoved(const std::string& device_path) { 884 void EventRouter::OnDeviceRemoved(const std::string& device_path) {
875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 885 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
876 DispatchDeviceEvent( 886 // Do nothing.
877 file_browser_private::DEVICE_EVENT_TYPE_REMOVED,
878 device_path);
879 } 887 }
880 888
881 void EventRouter::OnVolumeMounted(chromeos::MountError error_code, 889 void EventRouter::OnVolumeMounted(chromeos::MountError error_code,
882 const VolumeInfo& volume_info, 890 const VolumeInfo& volume_info,
883 bool is_remounting) { 891 bool is_remounting) {
884 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
885 // profile_ is NULL if ShutdownOnUIThread() is called earlier. This can 893 // profile_ is NULL if ShutdownOnUIThread() is called earlier. This can
886 // happen at shutdown. This should be removed after removing Drive mounting 894 // happen at shutdown. This should be removed after removing Drive mounting
887 // code in addMount. (addMount -> OnFileSystemMounted -> OnVolumeMounted is 895 // code in addMount. (addMount -> OnFileSystemMounted -> OnVolumeMounted is
888 // the only path to come here after Shutdown is called). 896 // the only path to come here after Shutdown is called).
889 if (!profile_) 897 if (!profile_)
890 return; 898 return;
899
891 DispatchMountCompletedEvent( 900 DispatchMountCompletedEvent(
892 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_MOUNT, 901 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_MOUNT,
893 error_code, 902 error_code,
894 volume_info, 903 volume_info);
895 is_remounting);
896 } 904 }
897 905
898 void EventRouter::OnVolumeUnmounted(chromeos::MountError error_code, 906 void EventRouter::OnVolumeUnmounted(chromeos::MountError error_code,
899 const VolumeInfo& volume_info) { 907 const VolumeInfo& volume_info) {
900 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 908 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
901 DispatchMountCompletedEvent( 909 DispatchMountCompletedEvent(
902 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_UNMOUNT, 910 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_UNMOUNT,
903 error_code, 911 error_code,
904 volume_info, 912 volume_info);
905 false);
906 }
907
908 void EventRouter::OnHardUnplugged(const std::string& device_path) {
909 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
910 DispatchDeviceEvent(file_browser_private::DEVICE_EVENT_TYPE_HARD_UNPLUGGED,
911 device_path);
912 } 913 }
913 914
914 void EventRouter::DispatchMountCompletedEvent( 915 void EventRouter::DispatchMountCompletedEvent(
915 file_browser_private::MountCompletedEventType event_type, 916 file_browser_private::MountCompletedEventType event_type,
916 chromeos::MountError error, 917 chromeos::MountError error,
917 const VolumeInfo& volume_info, 918 const VolumeInfo& volume_info) {
918 bool is_remounting) {
919 // Build an event object. 919 // Build an event object.
920 file_browser_private::MountCompletedEvent event; 920 file_browser_private::MountCompletedEvent event;
921 event.event_type = event_type; 921 event.event_type = event_type;
922 event.status = MountErrorToMountCompletedStatus(error); 922 event.status = MountErrorToMountCompletedStatus(error);
923 util::VolumeInfoToVolumeMetadata( 923 util::VolumeInfoToVolumeMetadata(
924 profile_, volume_info, &event.volume_metadata); 924 profile_, volume_info, &event.volume_metadata);
925 event.is_remounting = is_remounting;
926 event.should_notify = ShouldShowNotificationForVolume( 925 event.should_notify = ShouldShowNotificationForVolume(
927 profile_, event_type, error, volume_info, is_remounting); 926 profile_, *device_event_router_, volume_info);
928 BroadcastEvent(profile_, 927 BroadcastEvent(profile_,
929 file_browser_private::OnMountCompleted::kEventName, 928 file_browser_private::OnMountCompleted::kEventName,
930 file_browser_private::OnMountCompleted::Create(event)); 929 file_browser_private::OnMountCompleted::Create(event));
931 } 930 }
932 931
933 void EventRouter::OnFormatStarted(const std::string& device_path, 932 void EventRouter::OnFormatStarted(const std::string& device_path,
934 bool success) { 933 bool success) {
935 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 934 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
936 935 // Do nothing.
937 if (success) {
938 DispatchDeviceEvent(file_browser_private::DEVICE_EVENT_TYPE_FORMAT_START,
939 device_path);
940 } else {
941 DispatchDeviceEvent(file_browser_private::DEVICE_EVENT_TYPE_FORMAT_FAIL,
942 device_path);
943 }
944 } 936 }
945 937
946 void EventRouter::OnFormatCompleted(const std::string& device_path, 938 void EventRouter::OnFormatCompleted(const std::string& device_path,
947 bool success) { 939 bool success) {
948 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
949 DispatchDeviceEvent(success ? 941 // Do nothing.
950 file_browser_private::DEVICE_EVENT_TYPE_FORMAT_SUCCESS :
951 file_browser_private::DEVICE_EVENT_TYPE_FORMAT_FAIL,
952 device_path);
953 } 942 }
954 943
955 void EventRouter::Observe(int type, 944 void EventRouter::Observe(int type,
956 const content::NotificationSource& source, 945 const content::NotificationSource& source,
957 const content::NotificationDetails& details) { 946 const content::NotificationDetails& details) {
958 if (type == chrome::NOTIFICATION_PROFILE_ADDED) { 947 if (type == chrome::NOTIFICATION_PROFILE_ADDED) {
959 Profile* const added_profile = content::Source<Profile>(source).ptr(); 948 Profile* const added_profile = content::Source<Profile>(source).ptr();
960 if (!added_profile->IsOffTheRecord()) 949 if (!added_profile->IsOffTheRecord())
961 GrantAccessForAddedProfileToRunningInstance(added_profile, profile_); 950 GrantAccessForAddedProfileToRunningInstance(added_profile, profile_);
962 951
(...skipping 14 matching lines...) Expand all
977 } 966 }
978 } 967 }
979 968
980 void EventRouter::OnOwnerEntryChanged(aura::Window* window) { 969 void EventRouter::OnOwnerEntryChanged(aura::Window* window) {
981 BroadcastEvent(profile_, 970 BroadcastEvent(profile_,
982 file_browser_private::OnDesktopChanged::kEventName, 971 file_browser_private::OnDesktopChanged::kEventName,
983 file_browser_private::OnDesktopChanged::Create()); 972 file_browser_private::OnDesktopChanged::Create());
984 } 973 }
985 974
986 } // namespace file_manager 975 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/event_router.h ('k') | chrome/browser/chromeos/file_manager/volume_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698