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

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

Issue 2487623002: Notify Files App when ARC++ app is installed/removed (Closed)
Patch Set: Add IsInitialized to arc_service_manager. Created 4 years 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
OLDNEW
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 <set>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "chrome/browser/app_mode/app_mode_utils.h" 20 #include "chrome/browser/app_mode/app_mode_utils.h"
21 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
20 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 22 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
21 #include "chrome/browser/chromeos/drive/file_system_util.h" 23 #include "chrome/browser/chromeos/drive/file_system_util.h"
22 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 24 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
23 #include "chrome/browser/chromeos/file_manager/app_id.h" 25 #include "chrome/browser/chromeos/file_manager/app_id.h"
24 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 26 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
25 #include "chrome/browser/chromeos/file_manager/open_util.h" 27 #include "chrome/browser/chromeos/file_manager/open_util.h"
26 #include "chrome/browser/chromeos/file_manager/volume_manager.h" 28 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
27 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 29 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
28 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 30 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
29 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 31 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 device_event_router_(new DeviceEventRouterImpl(profile)), 392 device_event_router_(new DeviceEventRouterImpl(profile)),
391 job_event_router_(new JobEventRouterImpl(profile)), 393 job_event_router_(new JobEventRouterImpl(profile)),
392 dispatch_directory_change_event_impl_( 394 dispatch_directory_change_event_impl_(
393 base::Bind(&EventRouter::DispatchDirectoryChangeEventImpl, 395 base::Bind(&EventRouter::DispatchDirectoryChangeEventImpl,
394 base::Unretained(this))), 396 base::Unretained(this))),
395 weak_factory_(this) { 397 weak_factory_(this) {
396 DCHECK_CURRENTLY_ON(BrowserThread::UI); 398 DCHECK_CURRENTLY_ON(BrowserThread::UI);
397 ObserveEvents(); 399 ObserveEvents();
398 } 400 }
399 401
400 EventRouter::~EventRouter() { 402 EventRouter::~EventRouter() = default;
403
404 void EventRouter::OnAppsUpdated() {
405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
406 BroadcastEvent(profile_,
407 extensions::events::FILE_MANAGER_PRIVATE_ON_APPS_UPDATED,
408 file_manager_private::OnAppsUpdated::kEventName,
409 file_manager_private::OnAppsUpdated::Create());
401 } 410 }
402 411
403 void EventRouter::Shutdown() { 412 void EventRouter::Shutdown() {
404 DCHECK_CURRENTLY_ON(BrowserThread::UI); 413 DCHECK_CURRENTLY_ON(BrowserThread::UI);
414
415 if (arc::ArcServiceManager::IsInitialized())
416 arc::ArcServiceManager::Get()->RemoveObserver(this);
417
405 chromeos::system::TimezoneSettings::GetInstance()->RemoveObserver(this); 418 chromeos::system::TimezoneSettings::GetInstance()->RemoveObserver(this);
406 419
407 DLOG_IF(WARNING, !file_watchers_.empty()) 420 DLOG_IF(WARNING, !file_watchers_.empty())
408 << "Not all file watchers are " 421 << "Not all file watchers are "
409 << "removed. This can happen when Files.app is open during shutdown."; 422 << "removed. This can happen when Files.app is open during shutdown.";
410 file_watchers_.clear(); 423 file_watchers_.clear();
411 if (!profile_) { 424 if (!profile_) {
412 NOTREACHED(); 425 NOTREACHED();
413 return; 426 return;
414 } 427 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 base::Bind(&EventRouter::OnFileManagerPrefsChanged, 498 base::Bind(&EventRouter::OnFileManagerPrefsChanged,
486 weak_factory_.GetWeakPtr()); 499 weak_factory_.GetWeakPtr());
487 pref_change_registrar_->Add(drive::prefs::kDisableDriveOverCellular, 500 pref_change_registrar_->Add(drive::prefs::kDisableDriveOverCellular,
488 callback); 501 callback);
489 pref_change_registrar_->Add(drive::prefs::kDisableDriveHostedFiles, callback); 502 pref_change_registrar_->Add(drive::prefs::kDisableDriveHostedFiles, callback);
490 pref_change_registrar_->Add(drive::prefs::kDisableDrive, callback); 503 pref_change_registrar_->Add(drive::prefs::kDisableDrive, callback);
491 pref_change_registrar_->Add(prefs::kSearchSuggestEnabled, callback); 504 pref_change_registrar_->Add(prefs::kSearchSuggestEnabled, callback);
492 pref_change_registrar_->Add(prefs::kUse24HourClock, callback); 505 pref_change_registrar_->Add(prefs::kUse24HourClock, callback);
493 506
494 chromeos::system::TimezoneSettings::GetInstance()->AddObserver(this); 507 chromeos::system::TimezoneSettings::GetInstance()->AddObserver(this);
508
509 if (arc::ArcSessionManager::IsAllowedForProfile(profile_))
510 arc::ArcServiceManager::Get()->AddObserver(this);
495 } 511 }
496 512
497 // File watch setup routines. 513 // File watch setup routines.
498 void EventRouter::AddFileWatch(const base::FilePath& local_path, 514 void EventRouter::AddFileWatch(const base::FilePath& local_path,
499 const base::FilePath& virtual_path, 515 const base::FilePath& virtual_path,
500 const std::string& extension_id, 516 const std::string& extension_id,
501 const BoolCallback& callback) { 517 const BoolCallback& callback) {
502 DCHECK_CURRENTLY_ON(BrowserThread::UI); 518 DCHECK_CURRENTLY_ON(BrowserThread::UI);
503 DCHECK(!callback.is_null()); 519 DCHECK(!callback.is_null());
504 520
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( 1000 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting(
985 const DispatchDirectoryChangeEventImplCallback& callback) { 1001 const DispatchDirectoryChangeEventImplCallback& callback) {
986 dispatch_directory_change_event_impl_ = callback; 1002 dispatch_directory_change_event_impl_ = callback;
987 } 1003 }
988 1004
989 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { 1005 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() {
990 return weak_factory_.GetWeakPtr(); 1006 return weak_factory_.GetWeakPtr();
991 } 1007 }
992 1008
993 } // namespace file_manager 1009 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/event_router.h ('k') | chrome/common/extensions/api/file_manager_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698