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. | |
97 DCHECK(profile); | 95 DCHECK(profile); |
98 MediaGalleriesPrivateAPI* private_api = | 96 MediaGalleriesPrivateAPI* private_api = |
99 MediaGalleriesPrivateAPI::Get(profile); | 97 MediaGalleriesPrivateAPI::Get(profile); |
100 // In unit tests, we don't have a MediaGalleriesPrivateAPI. | 98 // In unit tests, we don't have a MediaGalleriesPrivateAPI. |
101 if (private_api) | 99 if (private_api) |
102 return private_api->GetGalleryWatchStateTracker(); | 100 return private_api->GetGalleryWatchStateTracker(); |
103 #endif | |
104 return NULL; | 101 return NULL; |
105 } | 102 } |
106 | 103 |
107 void GalleryWatchStateTracker::OnPermissionAdded( | 104 void GalleryWatchStateTracker::OnPermissionAdded( |
108 MediaGalleriesPreferences* preferences, | 105 MediaGalleriesPreferences* preferences, |
109 const std::string& extension_id, | 106 const std::string& extension_id, |
110 MediaGalleryPrefId gallery_id) { | 107 MediaGalleryPrefId gallery_id) { |
111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
112 // Granted gallery permission. | 109 // Granted gallery permission. |
113 if (HasGalleryWatchInfo(extension_id, gallery_id, false)) | 110 if (HasGalleryWatchInfo(extension_id, gallery_id, false)) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 const std::string& extension_id, | 327 const std::string& extension_id, |
331 MediaGalleryPrefId gallery_id) { | 328 MediaGalleryPrefId gallery_id) { |
332 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 329 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
333 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) | 330 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) |
334 return false; | 331 return false; |
335 watched_extensions_map_[extension_id][gallery_id] = true; | 332 watched_extensions_map_[extension_id][gallery_id] = true; |
336 return true; | 333 return true; |
337 } | 334 } |
338 | 335 |
339 } // namespace extensions | 336 } // namespace extensions |
OLD | NEW |