| 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 // Implements the Chrome Extensions Media Galleries API. | 5 // Implements the Chrome Extensions Media Galleries API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" | 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 MediaGalleriesEventRouter::~MediaGalleriesEventRouter() { | 270 MediaGalleriesEventRouter::~MediaGalleriesEventRouter() { |
| 271 } | 271 } |
| 272 | 272 |
| 273 void MediaGalleriesEventRouter::Shutdown() { | 273 void MediaGalleriesEventRouter::Shutdown() { |
| 274 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 274 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 275 weak_ptr_factory_.InvalidateWeakPtrs(); | 275 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 276 media_scan_manager()->RemoveObserver(profile_); | 276 media_scan_manager()->RemoveObserver(profile_); |
| 277 media_scan_manager()->CancelScansForProfile(profile_); | 277 media_scan_manager()->CancelScansForProfile(profile_); |
| 278 } | 278 } |
| 279 | 279 |
| 280 static base::LazyInstance<ProfileKeyedAPIFactory<MediaGalleriesEventRouter> > | 280 static base::LazyInstance< |
| 281 g_factory = LAZY_INSTANCE_INITIALIZER; | 281 BrowserContextKeyedAPIFactory<MediaGalleriesEventRouter> > g_factory = |
| 282 LAZY_INSTANCE_INITIALIZER; |
| 282 | 283 |
| 283 // static | 284 // static |
| 284 ProfileKeyedAPIFactory<MediaGalleriesEventRouter>* | 285 BrowserContextKeyedAPIFactory<MediaGalleriesEventRouter>* |
| 285 MediaGalleriesEventRouter::GetFactoryInstance() { | 286 MediaGalleriesEventRouter::GetFactoryInstance() { |
| 286 return g_factory.Pointer(); | 287 return g_factory.Pointer(); |
| 287 } | 288 } |
| 288 | 289 |
| 289 // static | 290 // static |
| 290 MediaGalleriesEventRouter* MediaGalleriesEventRouter::Get( | 291 MediaGalleriesEventRouter* MediaGalleriesEventRouter::Get( |
| 291 content::BrowserContext* context) { | 292 content::BrowserContext* context) { |
| 292 DCHECK(media_file_system_registry() | 293 DCHECK(media_file_system_registry() |
| 293 ->GetPreferences(Profile::FromBrowserContext(context)) | 294 ->GetPreferences(Profile::FromBrowserContext(context)) |
| 294 ->IsInitialized()); | 295 ->IsInitialized()); |
| 295 return ProfileKeyedAPIFactory<MediaGalleriesEventRouter>::GetForProfile( | 296 return BrowserContextKeyedAPIFactory<MediaGalleriesEventRouter>::Get(context); |
| 296 context); | |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool MediaGalleriesEventRouter::ExtensionHasScanProgressListener( | 299 bool MediaGalleriesEventRouter::ExtensionHasScanProgressListener( |
| 300 const std::string& extension_id) const { | 300 const std::string& extension_id) const { |
| 301 EventRouter* router = ExtensionSystem::Get(profile_)->event_router(); | 301 EventRouter* router = ExtensionSystem::Get(profile_)->event_router(); |
| 302 return router->ExtensionHasEventListener( | 302 return router->ExtensionHasEventListener( |
| 303 extension_id, | 303 extension_id, |
| 304 MediaGalleries::OnScanProgress::kEventName); | 304 MediaGalleries::OnScanProgress::kEventName); |
| 305 } | 305 } |
| 306 | 306 |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 if (!parse_success) { | 835 if (!parse_success) { |
| 836 SendResponse(false); | 836 SendResponse(false); |
| 837 return; | 837 return; |
| 838 } | 838 } |
| 839 | 839 |
| 840 SetResult(metadata_dictionary->DeepCopy()); | 840 SetResult(metadata_dictionary->DeepCopy()); |
| 841 SendResponse(true); | 841 SendResponse(true); |
| 842 } | 842 } |
| 843 | 843 |
| 844 } // namespace extensions | 844 } // namespace extensions |
| OLD | NEW |