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_manager/file_manager_event_rou
ter.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_event_rou
ter.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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 if (key_event_listener) | 286 if (key_event_listener) |
287 key_event_listener->RemoveModifiersObserver(this); | 287 key_event_listener->RemoveModifiersObserver(this); |
288 | 288 |
289 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 289 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
290 if (disk_mount_manager) | 290 if (disk_mount_manager) |
291 disk_mount_manager->RemoveObserver(this); | 291 disk_mount_manager->RemoveObserver(this); |
292 | 292 |
293 DriveSystemService* system_service = | 293 DriveSystemService* system_service = |
294 DriveSystemServiceFactory::FindForProfileRegardlessOfStates(profile_); | 294 DriveSystemServiceFactory::FindForProfileRegardlessOfStates(profile_); |
295 if (system_service) { | 295 if (system_service) { |
| 296 system_service->RemoveObserver(this); |
296 system_service->file_system()->RemoveObserver(this); | 297 system_service->file_system()->RemoveObserver(this); |
297 system_service->drive_service()->RemoveObserver(this); | 298 system_service->drive_service()->RemoveObserver(this); |
298 } | 299 } |
299 | 300 |
300 if (chromeos::ConnectivityStateHelper::IsInitialized()) { | 301 if (chromeos::ConnectivityStateHelper::IsInitialized()) { |
301 chromeos::ConnectivityStateHelper::Get()-> | 302 chromeos::ConnectivityStateHelper::Get()-> |
302 RemoveNetworkManagerObserver(this); | 303 RemoveNetworkManagerObserver(this); |
303 } | 304 } |
304 profile_ = NULL; | 305 profile_ = NULL; |
305 } | 306 } |
306 | 307 |
307 void FileManagerEventRouter::ObserveFileSystemEvents() { | 308 void FileManagerEventRouter::ObserveFileSystemEvents() { |
308 if (!profile_) { | 309 if (!profile_) { |
309 NOTREACHED(); | 310 NOTREACHED(); |
310 return; | 311 return; |
311 } | 312 } |
312 if (!chromeos::UserManager::Get()->IsUserLoggedIn()) | 313 if (!chromeos::UserManager::Get()->IsUserLoggedIn()) |
313 return; | 314 return; |
314 | 315 |
315 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 316 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
316 if (disk_mount_manager) { | 317 if (disk_mount_manager) { |
317 disk_mount_manager->RemoveObserver(this); | 318 disk_mount_manager->RemoveObserver(this); |
318 disk_mount_manager->AddObserver(this); | 319 disk_mount_manager->AddObserver(this); |
319 disk_mount_manager->RequestMountInfoRefresh(); | 320 disk_mount_manager->RequestMountInfoRefresh(); |
320 } | 321 } |
321 | 322 |
322 DriveSystemService* system_service = | 323 DriveSystemService* system_service = |
323 DriveSystemServiceFactory::GetForProfileRegardlessOfStates(profile_); | 324 DriveSystemServiceFactory::GetForProfileRegardlessOfStates(profile_); |
324 if (system_service) { | 325 if (system_service) { |
| 326 system_service->AddObserver(this); |
325 system_service->drive_service()->AddObserver(this); | 327 system_service->drive_service()->AddObserver(this); |
326 system_service->file_system()->AddObserver(this); | 328 system_service->file_system()->AddObserver(this); |
327 } | 329 } |
328 | 330 |
329 if (chromeos::ConnectivityStateHelper::IsInitialized()) { | 331 if (chromeos::ConnectivityStateHelper::IsInitialized()) { |
330 chromeos::ConnectivityStateHelper::Get()-> | 332 chromeos::ConnectivityStateHelper::Get()-> |
331 AddNetworkManagerObserver(this); | 333 AddNetworkManagerObserver(this); |
332 } | 334 } |
333 suspend_state_delegate_.reset(new SuspendStateDelegateImpl()); | 335 suspend_state_delegate_.reset(new SuspendStateDelegateImpl()); |
334 | 336 |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 base::FilePathWatcher* file_watcher) { | 989 base::FilePathWatcher* file_watcher) { |
988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 990 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
989 | 991 |
990 if (file_watcher) { | 992 if (file_watcher) { |
991 file_watcher_ = file_watcher; | 993 file_watcher_ = file_watcher; |
992 callback.Run(true); | 994 callback.Run(true); |
993 } else { | 995 } else { |
994 callback.Run(false); | 996 callback.Run(false); |
995 } | 997 } |
996 } | 998 } |
OLD | NEW |