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 // MediaFileSystemRegistry implementation. | 5 // MediaFileSystemRegistry implementation. |
6 | 6 |
7 #include "chrome/browser/media_gallery/media_file_system_registry.h" | 7 #include "chrome/browser/media_gallery/media_file_system_registry.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/system_monitor/media_storage_util.h" | 29 #include "chrome/browser/system_monitor/media_storage_util.h" |
30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
32 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
33 #include "chrome/common/extensions/extension_set.h" | 33 #include "chrome/common/extensions/extension_set.h" |
34 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
| 38 #include "content/public/browser/notification_observer.h" |
38 #include "content/public/browser/notification_registrar.h" | 39 #include "content/public/browser/notification_registrar.h" |
39 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
40 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
41 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
42 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
43 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
44 #include "webkit/fileapi/file_system_types.h" | 45 #include "webkit/fileapi/file_system_types.h" |
45 #include "webkit/fileapi/isolated_context.h" | 46 #include "webkit/fileapi/isolated_context.h" |
46 | 47 |
47 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 48 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 system_monitor->AddDevicesChangedObserver(this); | 672 system_monitor->AddDevicesChangedObserver(this); |
672 } | 673 } |
673 | 674 |
674 MediaFileSystemRegistry::~MediaFileSystemRegistry() { | 675 MediaFileSystemRegistry::~MediaFileSystemRegistry() { |
675 // SystemMonitor may be NULL in unit tests. | 676 // SystemMonitor may be NULL in unit tests. |
676 SystemMonitor* system_monitor = SystemMonitor::Get(); | 677 SystemMonitor* system_monitor = SystemMonitor::Get(); |
677 if (system_monitor) | 678 if (system_monitor) |
678 system_monitor->RemoveDevicesChangedObserver(this); | 679 system_monitor->RemoveDevicesChangedObserver(this); |
679 } | 680 } |
680 | 681 |
681 void MediaFileSystemRegistry::Observe( | 682 void MediaFileSystemRegistry::OnPreferenceChanged( |
682 int type, | 683 PrefServiceBase* prefs, |
683 const content::NotificationSource& source, | 684 const std::string& pref_name) { |
684 const content::NotificationDetails& details) { | |
685 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | |
686 const std::string& pref_name = | |
687 *content::Details<std::string>(details).ptr(); | |
688 DCHECK_EQ(std::string(prefs::kMediaGalleriesRememberedGalleries), pref_name); | 685 DCHECK_EQ(std::string(prefs::kMediaGalleriesRememberedGalleries), pref_name); |
689 | 686 |
690 // Find the Profile that contains the source PrefService. | 687 // Find the Profile that contains the source PrefService. |
691 PrefService* prefs = content::Source<PrefService>(source).ptr(); | |
692 PrefChangeRegistrarMap::iterator pref_change_it = | 688 PrefChangeRegistrarMap::iterator pref_change_it = |
693 pref_change_registrar_map_.begin(); | 689 pref_change_registrar_map_.begin(); |
694 for (; pref_change_it != pref_change_registrar_map_.end(); ++pref_change_it) { | 690 for (; pref_change_it != pref_change_registrar_map_.end(); ++pref_change_it) { |
695 if (pref_change_it->first->GetPrefs() == prefs) | 691 if (pref_change_it->first->GetPrefs() == prefs) |
696 break; | 692 break; |
697 } | 693 } |
698 DCHECK(pref_change_it != pref_change_registrar_map_.end()); | 694 DCHECK(pref_change_it != pref_change_registrar_map_.end()); |
699 Profile* profile = pref_change_it->first; | 695 Profile* profile = pref_change_it->first; |
700 | 696 |
701 // Get the Extensions, MediaGalleriesPreferences and ExtensionHostMap for | 697 // Get the Extensions, MediaGalleriesPreferences and ExtensionHostMap for |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 758 |
763 PrefChangeRegistrarMap::iterator pref_it = | 759 PrefChangeRegistrarMap::iterator pref_it = |
764 pref_change_registrar_map_.find(profile); | 760 pref_change_registrar_map_.find(profile); |
765 DCHECK(pref_it != pref_change_registrar_map_.end()); | 761 DCHECK(pref_it != pref_change_registrar_map_.end()); |
766 delete pref_it->second; | 762 delete pref_it->second; |
767 pref_change_registrar_map_.erase(pref_it); | 763 pref_change_registrar_map_.erase(pref_it); |
768 } | 764 } |
769 } | 765 } |
770 | 766 |
771 } // namespace chrome | 767 } // namespace chrome |
OLD | NEW |