| 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 // GalleryWatchStateTracker implementation. | 5 // GalleryWatchStateTracker implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_st
ate_tracker.h" | 7 #include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_st
ate_tracker.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 86 MediaGalleriesPreferences* preferences = | 86 MediaGalleriesPreferences* preferences = |
| 87 g_browser_process->media_file_system_registry()->GetPreferences(profile_); | 87 g_browser_process->media_file_system_registry()->GetPreferences(profile_); |
| 88 preferences->RemoveGalleryChangeObserver(this); | 88 preferences->RemoveGalleryChangeObserver(this); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // static | 91 // static |
| 92 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( | 92 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( |
| 93 Profile* profile) { | 93 Profile* profile) { |
| 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 95 #if defined(OS_WIN) || defined(OS_LINUX) |
| 96 // Gallery watch operation is not supported on Mac: crbug.com/144491. |
| 95 DCHECK(profile); | 97 DCHECK(profile); |
| 96 MediaGalleriesPrivateAPI* private_api = | 98 MediaGalleriesPrivateAPI* private_api = |
| 97 MediaGalleriesPrivateAPI::Get(profile); | 99 MediaGalleriesPrivateAPI::Get(profile); |
| 98 // In unit tests, we don't have a MediaGalleriesPrivateAPI. | 100 // In unit tests, we don't have a MediaGalleriesPrivateAPI. |
| 99 if (private_api) | 101 if (private_api) |
| 100 return private_api->GetGalleryWatchStateTracker(); | 102 return private_api->GetGalleryWatchStateTracker(); |
| 103 #endif |
| 101 return NULL; | 104 return NULL; |
| 102 } | 105 } |
| 103 | 106 |
| 104 void GalleryWatchStateTracker::OnPermissionAdded( | 107 void GalleryWatchStateTracker::OnPermissionAdded( |
| 105 MediaGalleriesPreferences* preferences, | 108 MediaGalleriesPreferences* preferences, |
| 106 const std::string& extension_id, | 109 const std::string& extension_id, |
| 107 MediaGalleryPrefId gallery_id) { | 110 MediaGalleryPrefId gallery_id) { |
| 108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 109 // Granted gallery permission. | 112 // Granted gallery permission. |
| 110 if (HasGalleryWatchInfo(extension_id, gallery_id, false)) | 113 if (HasGalleryWatchInfo(extension_id, gallery_id, false)) |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 const std::string& extension_id, | 330 const std::string& extension_id, |
| 328 MediaGalleryPrefId gallery_id) { | 331 MediaGalleryPrefId gallery_id) { |
| 329 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 332 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 330 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) | 333 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) |
| 331 return false; | 334 return false; |
| 332 watched_extensions_map_[extension_id][gallery_id] = true; | 335 watched_extensions_map_[extension_id][gallery_id] = true; |
| 333 return true; | 336 return true; |
| 334 } | 337 } |
| 335 | 338 |
| 336 } // namespace extensions | 339 } // namespace extensions |
| OLD | NEW |