| OLD | NEW |
| 1 // Copyright 2014 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 device_event_router_(new DeviceEventRouterImpl(profile)), | 390 device_event_router_(new DeviceEventRouterImpl(profile)), |
| 391 job_event_router_(new JobEventRouterImpl(profile)), | 391 job_event_router_(new JobEventRouterImpl(profile)), |
| 392 dispatch_directory_change_event_impl_( | 392 dispatch_directory_change_event_impl_( |
| 393 base::Bind(&EventRouter::DispatchDirectoryChangeEventImpl, | 393 base::Bind(&EventRouter::DispatchDirectoryChangeEventImpl, |
| 394 base::Unretained(this))), | 394 base::Unretained(this))), |
| 395 weak_factory_(this) { | 395 weak_factory_(this) { |
| 396 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 396 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 397 ObserveEvents(); | 397 ObserveEvents(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 EventRouter::~EventRouter() { | 400 EventRouter::~EventRouter() = default; |
| 401 |
| 402 void EventRouter::OnAppsUpdated() { |
| 403 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 404 BroadcastEvent(profile_, |
| 405 extensions::events::FILE_MANAGER_PRIVATE_ON_APPS_UPDATED, |
| 406 file_manager_private::OnAppsUpdated::kEventName, |
| 407 file_manager_private::OnAppsUpdated::Create()); |
| 401 } | 408 } |
| 402 | 409 |
| 403 void EventRouter::Shutdown() { | 410 void EventRouter::Shutdown() { |
| 404 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 411 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 412 |
| 413 if (ArcSessionManager::IsAllowedForProfile(profile_)) |
| 414 arc::ArcServiceManager::Get()->RemoveObserver(this); |
| 415 |
| 405 chromeos::system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 416 chromeos::system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
| 406 | 417 |
| 407 DLOG_IF(WARNING, !file_watchers_.empty()) | 418 DLOG_IF(WARNING, !file_watchers_.empty()) |
| 408 << "Not all file watchers are " | 419 << "Not all file watchers are " |
| 409 << "removed. This can happen when Files.app is open during shutdown."; | 420 << "removed. This can happen when Files.app is open during shutdown."; |
| 410 file_watchers_.clear(); | 421 file_watchers_.clear(); |
| 411 if (!profile_) { | 422 if (!profile_) { |
| 412 NOTREACHED(); | 423 NOTREACHED(); |
| 413 return; | 424 return; |
| 414 } | 425 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 base::Bind(&EventRouter::OnFileManagerPrefsChanged, | 496 base::Bind(&EventRouter::OnFileManagerPrefsChanged, |
| 486 weak_factory_.GetWeakPtr()); | 497 weak_factory_.GetWeakPtr()); |
| 487 pref_change_registrar_->Add(drive::prefs::kDisableDriveOverCellular, | 498 pref_change_registrar_->Add(drive::prefs::kDisableDriveOverCellular, |
| 488 callback); | 499 callback); |
| 489 pref_change_registrar_->Add(drive::prefs::kDisableDriveHostedFiles, callback); | 500 pref_change_registrar_->Add(drive::prefs::kDisableDriveHostedFiles, callback); |
| 490 pref_change_registrar_->Add(drive::prefs::kDisableDrive, callback); | 501 pref_change_registrar_->Add(drive::prefs::kDisableDrive, callback); |
| 491 pref_change_registrar_->Add(prefs::kSearchSuggestEnabled, callback); | 502 pref_change_registrar_->Add(prefs::kSearchSuggestEnabled, callback); |
| 492 pref_change_registrar_->Add(prefs::kUse24HourClock, callback); | 503 pref_change_registrar_->Add(prefs::kUse24HourClock, callback); |
| 493 | 504 |
| 494 chromeos::system::TimezoneSettings::GetInstance()->AddObserver(this); | 505 chromeos::system::TimezoneSettings::GetInstance()->AddObserver(this); |
| 506 |
| 507 if (ArcSessionManager::IsAllowedForProfile(profile_)) |
| 508 arc::ArcServiceManager::Get()->AddObserver(this); |
| 495 } | 509 } |
| 496 | 510 |
| 497 // File watch setup routines. | 511 // File watch setup routines. |
| 498 void EventRouter::AddFileWatch(const base::FilePath& local_path, | 512 void EventRouter::AddFileWatch(const base::FilePath& local_path, |
| 499 const base::FilePath& virtual_path, | 513 const base::FilePath& virtual_path, |
| 500 const std::string& extension_id, | 514 const std::string& extension_id, |
| 501 const BoolCallback& callback) { | 515 const BoolCallback& callback) { |
| 502 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 516 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 503 DCHECK(!callback.is_null()); | 517 DCHECK(!callback.is_null()); |
| 504 | 518 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( | 998 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( |
| 985 const DispatchDirectoryChangeEventImplCallback& callback) { | 999 const DispatchDirectoryChangeEventImplCallback& callback) { |
| 986 dispatch_directory_change_event_impl_ = callback; | 1000 dispatch_directory_change_event_impl_ = callback; |
| 987 } | 1001 } |
| 988 | 1002 |
| 989 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { | 1003 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { |
| 990 return weak_factory_.GetWeakPtr(); | 1004 return weak_factory_.GetWeakPtr(); |
| 991 } | 1005 } |
| 992 | 1006 |
| 993 } // namespace file_manager | 1007 } // namespace file_manager |
| OLD | NEW |