| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // static | 96 // static |
| 97 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( | 97 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( |
| 98 Profile* profile) { | 98 Profile* profile) { |
| 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 100 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
| 101 // Gallery watch operation is supported only on windows. | 101 // Gallery watch operation is supported only on windows. |
| 102 // Please refer to crbug.com/144491 for more details. | 102 // Please refer to crbug.com/144491 for more details. |
| 103 DCHECK(profile); | 103 DCHECK(profile); |
| 104 MediaGalleriesPrivateAPI* private_api = | 104 MediaGalleriesPrivateAPI* private_api = |
| 105 MediaGalleriesPrivateAPI::Get(profile); | 105 MediaGalleriesPrivateAPI::Get(profile); |
| 106 if (!private_api) | 106 // In unit tests, we don't have a MediaGalleriesPrivateAPI. |
| 107 return NULL; // In unit tests, we don't have a MediaGalleriesPrivateAPI. | 107 if (private_api) |
| 108 return private_api->GetGalleryWatchStateTracker(); | 108 return private_api->GetGalleryWatchStateTracker(); |
| 109 #endif | 109 #endif |
| 110 return NULL; | 110 return NULL; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void GalleryWatchStateTracker::OnPermissionAdded( | 113 void GalleryWatchStateTracker::OnPermissionAdded( |
| 114 MediaGalleriesPreferences* preferences, | 114 MediaGalleriesPreferences* preferences, |
| 115 const std::string& extension_id, | 115 const std::string& extension_id, |
| 116 MediaGalleryPrefId gallery_id) { | 116 MediaGalleryPrefId gallery_id) { |
| 117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 118 // Granted gallery permission. | 118 // Granted gallery permission. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 const std::string& extension_id, | 346 const std::string& extension_id, |
| 347 MediaGalleryPrefId gallery_id) { | 347 MediaGalleryPrefId gallery_id) { |
| 348 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 348 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 349 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) | 349 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) |
| 350 return false; | 350 return false; |
| 351 watched_extensions_map_[extension_id][gallery_id] = true; | 351 watched_extensions_map_[extension_id][gallery_id] = true; |
| 352 return true; | 352 return true; |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace extensions | 355 } // namespace extensions |
| OLD | NEW |