| 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_galleries/media_file_system_registry.h" | 7 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" | 21 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" |
| 22 #include "chrome/browser/media_galleries/media_file_system_context.h" | 22 #include "chrome/browser/media_galleries/media_file_system_context.h" |
| 23 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 23 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
| 24 #include "chrome/browser/media_galleries/media_galleries_histograms.h" | 24 #include "chrome/browser/media_galleries/media_galleries_histograms.h" |
| 25 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" | 25 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/storage_monitor/media_storage_util.h" | 27 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 28 #include "chrome/browser/storage_monitor/storage_monitor.h" | 28 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 29 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/extensions/extension_constants.h" | 30 #include "chrome/common/extensions/extension_constants.h" |
| 31 #include "chrome/common/extensions/extension_set.h" | |
| 32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 33 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/navigation_details.h" | 33 #include "content/public/browser/navigation_details.h" |
| 35 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
| 36 #include "content/public/browser/notification_observer.h" | 35 #include "content/public/browser/notification_observer.h" |
| 37 #include "content/public/browser/notification_registrar.h" | 36 #include "content/public/browser/notification_registrar.h" |
| 38 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
| 39 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" |
| 40 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| 41 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
| 42 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
| 43 #include "extensions/common/extension.h" | 42 #include "extensions/common/extension.h" |
| 43 #include "extensions/common/extension_set.h" |
| 44 #include "webkit/browser/fileapi/isolated_context.h" | 44 #include "webkit/browser/fileapi/isolated_context.h" |
| 45 #include "webkit/common/fileapi/file_system_types.h" | 45 #include "webkit/common/fileapi/file_system_types.h" |
| 46 | 46 |
| 47 using content::BrowserThread; | 47 using content::BrowserThread; |
| 48 using content::NavigationController; | 48 using content::NavigationController; |
| 49 using content::RenderProcessHost; | 49 using content::RenderProcessHost; |
| 50 using content::WebContents; | 50 using content::WebContents; |
| 51 using fileapi::IsolatedContext; | 51 using fileapi::IsolatedContext; |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 619 } |
| 620 | 620 |
| 621 void MediaFileSystemRegistry::OnGalleryRemoved( | 621 void MediaFileSystemRegistry::OnGalleryRemoved( |
| 622 MediaGalleriesPreferences* prefs, | 622 MediaGalleriesPreferences* prefs, |
| 623 MediaGalleryPrefId pref_id) { | 623 MediaGalleryPrefId pref_id) { |
| 624 Profile* profile = prefs->profile(); | 624 Profile* profile = prefs->profile(); |
| 625 // Get the Extensions, MediaGalleriesPreferences and ExtensionHostMap for | 625 // Get the Extensions, MediaGalleriesPreferences and ExtensionHostMap for |
| 626 // |profile|. | 626 // |profile|. |
| 627 const ExtensionService* extension_service = | 627 const ExtensionService* extension_service = |
| 628 extensions::ExtensionSystem::Get(profile)->extension_service(); | 628 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 629 const ExtensionSet* extensions_set = extension_service->extensions(); | 629 const extensions::ExtensionSet* extensions_set = |
| 630 extension_service->extensions(); |
| 630 ExtensionGalleriesHostMap::const_iterator host_map_it = | 631 ExtensionGalleriesHostMap::const_iterator host_map_it = |
| 631 extension_hosts_map_.find(profile); | 632 extension_hosts_map_.find(profile); |
| 632 DCHECK(host_map_it != extension_hosts_map_.end()); | 633 DCHECK(host_map_it != extension_hosts_map_.end()); |
| 633 const ExtensionHostMap& extension_host_map = host_map_it->second; | 634 const ExtensionHostMap& extension_host_map = host_map_it->second; |
| 634 | 635 |
| 635 // Go through ExtensionHosts, and remove indicated gallery, if any. | 636 // Go through ExtensionHosts, and remove indicated gallery, if any. |
| 636 // RevokeGalleryByPrefId() may end up deleting from |extension_host_map| and | 637 // RevokeGalleryByPrefId() may end up deleting from |extension_host_map| and |
| 637 // even delete |extension_host_map| altogether. So do this in two loops to | 638 // even delete |extension_host_map| altogether. So do this in two loops to |
| 638 // avoid using an invalidated iterator or deleted map. | 639 // avoid using an invalidated iterator or deleted map. |
| 639 std::vector<const extensions::Extension*> extensions; | 640 std::vector<const extensions::Extension*> extensions; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 665 DCHECK_EQ(1U, erase_count); | 666 DCHECK_EQ(1U, erase_count); |
| 666 if (extension_hosts->second.empty()) { | 667 if (extension_hosts->second.empty()) { |
| 667 // When a profile has no ExtensionGalleriesHosts left, remove the | 668 // When a profile has no ExtensionGalleriesHosts left, remove the |
| 668 // matching gallery-change-watcher since it is no longer needed. Leave the | 669 // matching gallery-change-watcher since it is no longer needed. Leave the |
| 669 // |extension_hosts| entry alone, since it indicates the profile has been | 670 // |extension_hosts| entry alone, since it indicates the profile has been |
| 670 // previously used. | 671 // previously used. |
| 671 MediaGalleriesPreferences* preferences = GetPreferences(profile); | 672 MediaGalleriesPreferences* preferences = GetPreferences(profile); |
| 672 preferences->RemoveGalleryChangeObserver(this); | 673 preferences->RemoveGalleryChangeObserver(this); |
| 673 } | 674 } |
| 674 } | 675 } |
| OLD | NEW |