Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: trunk/src/chrome/browser/media_galleries/media_galleries_preferences.cc

Issue 25725004: Revert 226509 "Media Galleries API: Fix MediaGalleriesPreference..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/chrome/browser/media_galleries/media_galleries_preferences.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/chrome/browser/media_galleries/media_galleries_preferences.cc
===================================================================
--- trunk/src/chrome/browser/media_galleries/media_galleries_preferences.cc (revision 226516)
+++ trunk/src/chrome/browser/media_galleries/media_galleries_preferences.cc (working copy)
@@ -377,12 +377,10 @@
// FinishInitialization.
pre_initialization_callbacks_waiting_ = 3;
- // We determine the freshness of the profile here, before any of the finders
- // return and add media galleries to it.
+ // Ensure StorageMonitor is initialized.
StorageMonitor::GetInstance()->EnsureInitialized(
- base::Bind(&MediaGalleriesPreferences::OnStorageMonitorInit,
- weak_factory_.GetWeakPtr(),
- APIHasBeenUsed(profile_) /* add_default_galleries */));
+ base::Bind(&MediaGalleriesPreferences::OnInitializationCallbackReturned,
+ weak_factory_.GetWeakPtr()));
// Look for optional default galleries every time.
itunes::ITunesFinder::FindITunesLibrary(
@@ -419,6 +417,7 @@
StorageMonitor* monitor = StorageMonitor::GetInstance();
DCHECK(monitor->IsInitialized());
+ AddDefaultGalleriesIfFreshProfile();
InitFromPrefs();
StorageMonitor::GetInstance()->AddObserver(this);
@@ -448,7 +447,12 @@
on_initialize_callbacks_.clear();
}
-void MediaGalleriesPreferences::AddDefaultGalleries() {
+void MediaGalleriesPreferences::AddDefaultGalleriesIfFreshProfile() {
+ // Only add defaults the first time.
+ if (APIHasBeenUsed(profile_))
+ return;
+
+ // Fresh profile case.
const int kDirectoryKeys[] = {
chrome::DIR_USER_MUSIC,
chrome::DIR_USER_PICTURES,
@@ -511,13 +515,6 @@
return false;
}
-void MediaGalleriesPreferences::OnStorageMonitorInit(
- bool need_to_add_default_galleries) {
- if (need_to_add_default_galleries)
- AddDefaultGalleries();
- OnInitializationCallbackReturned();
-}
-
void MediaGalleriesPreferences::OnFinderDeviceID(const std::string& device_id) {
if (!device_id.empty() && !UpdateDeviceIDForSingletonType(device_id)) {
std::string gallery_name;
« no previous file with comments | « trunk/src/chrome/browser/media_galleries/media_galleries_preferences.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698