| 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 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_
private_api.h" | 5 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_
private_api.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 const char kInvalidGalleryIDError[] = "Invalid gallery ID"; | 43 const char kInvalidGalleryIDError[] = "Invalid gallery ID"; |
| 44 | 44 |
| 45 // Handles the profile shutdown event on the file thread to clean up | 45 // Handles the profile shutdown event on the file thread to clean up |
| 46 // GalleryWatchManager. | 46 // GalleryWatchManager. |
| 47 void HandleProfileShutdownOnFileThread(void* profile_id) { | 47 void HandleProfileShutdownOnFileThread(void* profile_id) { |
| 48 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 48 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 49 GalleryWatchManager::OnProfileShutdown(profile_id); | 49 GalleryWatchManager::OnProfileShutdown(profile_id); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Gets the |gallery_file_path| and |gallery_pref_id| of the gallery specified | 52 // Returns true and sets |gallery_file_path| and |gallery_pref_id| if the |
| 53 // by the |gallery_id|. Returns true and set |gallery_file_path| and | 53 // |gallery_id| is valid and returns false otherwise. |
| 54 // |gallery_pref_id| if the |gallery_id| is valid and returns false otherwise. | |
| 55 bool GetGalleryFilePathAndId(const std::string& gallery_id, | 54 bool GetGalleryFilePathAndId(const std::string& gallery_id, |
| 56 Profile* profile, | 55 Profile* profile, |
| 57 const Extension* extension, | 56 const Extension* extension, |
| 58 base::FilePath* gallery_file_path, | 57 base::FilePath* gallery_file_path, |
| 59 MediaGalleryPrefId* gallery_pref_id) { | 58 MediaGalleryPrefId* gallery_pref_id) { |
| 60 MediaGalleryPrefId pref_id; | 59 MediaGalleryPrefId pref_id; |
| 61 if (!base::StringToUint64(gallery_id, &pref_id)) | 60 if (!base::StringToUint64(gallery_id, &pref_id)) |
| 62 return false; | 61 return false; |
| 63 MediaGalleriesPreferences* preferences = | 62 MediaGalleriesPreferences* preferences = |
| 64 g_browser_process->media_file_system_registry()->GetPreferences(profile); | 63 g_browser_process->media_file_system_registry()->GetPreferences(profile); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 g_browser_process->media_file_system_registry()->GetPreferences( | 350 g_browser_process->media_file_system_registry()->GetPreferences( |
| 352 GetProfile()); | 351 GetProfile()); |
| 353 GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get( | 352 GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get( |
| 354 GetProfile())->GetGalleryWatchStateTracker(); | 353 GetProfile())->GetGalleryWatchStateTracker(); |
| 355 state_tracker->RemoveAllGalleryWatchersForExtension( | 354 state_tracker->RemoveAllGalleryWatchersForExtension( |
| 356 extension_id(), preferences); | 355 extension_id(), preferences); |
| 357 SendResponse(true); | 356 SendResponse(true); |
| 358 } | 357 } |
| 359 | 358 |
| 360 } // namespace extensions | 359 } // namespace extensions |
| OLD | NEW |