Commit 1c329f67 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Revert 226509 "Media Galleries API: Fix MediaGalleriesPreference..."

> Media Galleries API: Fix MediaGalleriesPreferences initialization for fresh profiles.
> 
> BUG=151701, 295880
> R=vandebo@chromium.org
> 
> Review URL: https://codereview.chromium.org/25539003

TBR=tommycli@chromium.org

Review URL: https://codereview.chromium.org/25725004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226517 0039d316-1c4b-4281-b951-d872f2087c98
parent fca5dd85
......@@ -377,12 +377,10 @@ void MediaGalleriesPreferences::EnsureInitialized(base::Closure callback) {
// 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 @@ void MediaGalleriesPreferences::FinishInitialization() {
StorageMonitor* monitor = StorageMonitor::GetInstance();
DCHECK(monitor->IsInitialized());
AddDefaultGalleriesIfFreshProfile();
InitFromPrefs();
StorageMonitor::GetInstance()->AddObserver(this);
......@@ -448,7 +447,12 @@ void MediaGalleriesPreferences::FinishInitialization() {
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 @@ bool MediaGalleriesPreferences::UpdateDeviceIDForSingletonType(
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;
......
......@@ -240,8 +240,8 @@ class MediaGalleriesPreferences : public BrowserContextKeyedService,
void OnInitializationCallbackReturned();
void FinishInitialization();
// Populates the default galleries. Call only on fresh profiles.
void AddDefaultGalleries();
// Populates the default galleries if this is a fresh profile.
void AddDefaultGalleriesIfFreshProfile();
// This is a hack - Some devices (iTunes, Picasa) are singletons in that only
// one instance of that type is supported at a time. As such, the device id
......@@ -254,8 +254,6 @@ class MediaGalleriesPreferences : public BrowserContextKeyedService,
// device id. It returns true if the device id is up to date.
bool UpdateDeviceIDForSingletonType(const std::string& device_id);
void OnStorageMonitorInit(bool add_default_galleries);
// Handle an iPhoto, iTunes, or Picasa finder returning a device ID to us.
void OnFinderDeviceID(const std::string& device_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment