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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 GalleryWatchStateTracker::GalleryWatchStateTracker(Profile* profile) | 76 GalleryWatchStateTracker::GalleryWatchStateTracker(Profile* profile) |
77 : profile_(profile) { | 77 : profile_(profile) { |
78 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 78 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
79 DCHECK(profile_); | 79 DCHECK(profile_); |
80 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 80 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
81 content::Source<Profile>(profile_)); | 81 content::Source<Profile>(profile_)); |
82 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 82 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
83 content::Source<Profile>(profile_)); | 83 content::Source<Profile>(profile_)); |
84 MediaGalleriesPreferences* preferences = | 84 MediaGalleriesPreferences* preferences = |
85 g_browser_process->media_file_system_registry()->GetPreferences( | 85 g_browser_process->media_file_system_registry()->GetPreferences(profile); |
86 profile); | |
87 preferences->AddGalleryChangeObserver(this); | 86 preferences->AddGalleryChangeObserver(this); |
88 } | 87 } |
89 | 88 |
90 GalleryWatchStateTracker::~GalleryWatchStateTracker() { | 89 GalleryWatchStateTracker::~GalleryWatchStateTracker() { |
91 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 90 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
92 MediaGalleriesPreferences* preferences = | 91 MediaGalleriesPreferences* preferences = |
93 g_browser_process->media_file_system_registry()->GetPreferences( | 92 g_browser_process->media_file_system_registry()->GetPreferences(profile_); |
94 profile_); | |
95 preferences->RemoveGalleryChangeObserver(this); | 93 preferences->RemoveGalleryChangeObserver(this); |
96 } | 94 } |
97 | 95 |
98 // static | 96 // static |
99 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( | 97 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( |
100 Profile* profile) { | 98 Profile* profile) { |
101 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
102 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
103 // Gallery watch operation is supported only on windows. | 101 // Gallery watch operation is supported only on windows. |
104 // Please refer to crbug.com/144491 for more details. | 102 // Please refer to crbug.com/144491 for more details. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 const std::string& extension_id, | 346 const std::string& extension_id, |
349 MediaGalleryPrefId gallery_id) { | 347 MediaGalleryPrefId gallery_id) { |
350 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 348 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
351 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) | 349 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) |
352 return false; | 350 return false; |
353 watched_extensions_map_[extension_id][gallery_id] = true; | 351 watched_extensions_map_[extension_id][gallery_id] = true; |
354 return true; | 352 return true; |
355 } | 353 } |
356 | 354 |
357 } // namespace extensions | 355 } // namespace extensions |
OLD | NEW |