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

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 RemoverObserver. Created 4 years, 1 month 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 <utility> 9 #include <utility>
10 10
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() {
401 } 401 }
402 402
403 void EventRouter::OnAppsUpdated() {
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
405 BroadcastEvent(profile_,
406 extensions::events::FILE_MANAGER_PRIVATE_ON_APPS_UPDATED,
407 file_manager_private::OnAppsUpdated::kEventName,
408 file_manager_private::OnAppsUpdated::Create());
409 }
410
403 void EventRouter::Shutdown() { 411 void EventRouter::Shutdown() {
404 DCHECK_CURRENTLY_ON(BrowserThread::UI); 412 DCHECK_CURRENTLY_ON(BrowserThread::UI);
413
414 arc::ArcIntentHelperBridge* bridge = arc::ArcIntentHelperBridge::Get();
415 DCHECK(bridge);
416 bridge->RemoveObserver(this);
Yusuke Sato 2016/11/21 17:21:05 How did you test this? |bridge| might be NULL.
oka 2016/11/24 15:14:17 Test procedure is written in https://codereview.ch
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 arc::ArcIntentHelperBridge* bridge = arc::ArcIntentHelperBridge::Get();
510 DCHECK(bridge);
511 bridge->AddObserver(this);
495 } 512 }
496 513
497 // File watch setup routines. 514 // File watch setup routines.
498 void EventRouter::AddFileWatch(const base::FilePath& local_path, 515 void EventRouter::AddFileWatch(const base::FilePath& local_path,
499 const base::FilePath& virtual_path, 516 const base::FilePath& virtual_path,
500 const std::string& extension_id, 517 const std::string& extension_id,
501 const BoolCallback& callback) { 518 const BoolCallback& callback) {
502 DCHECK_CURRENTLY_ON(BrowserThread::UI); 519 DCHECK_CURRENTLY_ON(BrowserThread::UI);
503 DCHECK(!callback.is_null()); 520 DCHECK(!callback.is_null());
504 521
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( 1001 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting(
985 const DispatchDirectoryChangeEventImplCallback& callback) { 1002 const DispatchDirectoryChangeEventImplCallback& callback) {
986 dispatch_directory_change_event_impl_ = callback; 1003 dispatch_directory_change_event_impl_ = callback;
987 } 1004 }
988 1005
989 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { 1006 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() {
990 return weak_factory_.GetWeakPtr(); 1007 return weak_factory_.GetWeakPtr();
991 } 1008 }
992 1009
993 } // namespace file_manager 1010 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698