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 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 5 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
6 | 6 |
7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 on_initialize_callbacks_.push_back(callback); | 356 on_initialize_callbacks_.push_back(callback); |
357 } | 357 } |
358 | 358 |
359 if (initializing_) | 359 if (initializing_) |
360 return; | 360 return; |
361 | 361 |
362 initializing_ = true; | 362 initializing_ = true; |
363 | 363 |
364 AddDefaultGalleriesIfFreshProfile(); | 364 AddDefaultGalleriesIfFreshProfile(); |
365 | 365 |
366 pre_initialization_callbacks_waiting_ = 2; | 366 pre_initialization_callbacks_waiting_ = 3; |
367 | 367 |
368 // Ensure StorageMonitor is initialized. | 368 // Ensure StorageMonitor is initialized. |
369 StorageMonitor::GetInstance()->EnsureInitialized( | 369 StorageMonitor::GetInstance()->EnsureInitialized( |
370 base::Bind(&MediaGalleriesPreferences::OnInitializationCallbackReturned, | 370 base::Bind(&MediaGalleriesPreferences::OnInitializationCallbackReturned, |
371 weak_factory_.GetWeakPtr())); | 371 weak_factory_.GetWeakPtr())); |
372 | 372 |
373 // Look for optional default galleries every time. | 373 // Look for optional default galleries every time. |
374 itunes::ITunesFinder::FindITunesLibrary( | 374 itunes::ITunesFinder::FindITunesLibrary( |
375 base::Bind(&MediaGalleriesPreferences::OnFinderDeviceID, | 375 base::Bind(&MediaGalleriesPreferences::OnFinderDeviceID, |
376 weak_factory_.GetWeakPtr())); | 376 weak_factory_.GetWeakPtr())); |
377 | 377 |
378 // TODO(tommycli): Turn on when Picasa code is ready. | 378 picasa::FindPicasaDatabase( |
379 #if 0 | |
380 picasa::PicasaFinder::FindPicasaDatabaseOnUIThread( | |
381 base::Bind(&MediaGalleriesPreferences::OnFinderDeviceID, | 379 base::Bind(&MediaGalleriesPreferences::OnFinderDeviceID, |
382 weak_factory_.GetWeakPtr())); | 380 weak_factory_.GetWeakPtr())); |
383 #endif | |
384 } | 381 } |
385 | 382 |
386 bool MediaGalleriesPreferences::IsInitialized() const { return initialized_; } | 383 bool MediaGalleriesPreferences::IsInitialized() const { return initialized_; } |
387 | 384 |
388 Profile* MediaGalleriesPreferences::profile() { return profile_; } | 385 Profile* MediaGalleriesPreferences::profile() { return profile_; } |
389 | 386 |
390 void MediaGalleriesPreferences::OnInitializationCallbackReturned() { | 387 void MediaGalleriesPreferences::OnInitializationCallbackReturned() { |
391 DCHECK(!IsInitialized()); | 388 DCHECK(!IsInitialized()); |
392 DCHECK(pre_initialization_callbacks_waiting_ > 0); | 389 DCHECK(pre_initialization_callbacks_waiting_ > 0); |
393 if (--pre_initialization_callbacks_waiting_ == 0) | 390 if (--pre_initialization_callbacks_waiting_ == 0) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 gallery_change_observers_, | 490 gallery_change_observers_, |
494 OnGalleryInfoUpdated(this, pref_id)); | 491 OnGalleryInfoUpdated(this, pref_id)); |
495 } | 492 } |
496 return true; | 493 return true; |
497 } | 494 } |
498 } | 495 } |
499 return false; | 496 return false; |
500 } | 497 } |
501 | 498 |
502 void MediaGalleriesPreferences::OnFinderDeviceID(const std::string& device_id) { | 499 void MediaGalleriesPreferences::OnFinderDeviceID(const std::string& device_id) { |
500 DLOG(INFO) << "OnFinderDeviceID: " << device_id; | |
vandebo (ex-Chrome)
2013/09/23 16:01:31
remove
tommycli
2013/09/24 00:42:36
Done.
| |
503 if (!device_id.empty() && !UpdateDeviceIDForSingletonType(device_id)) { | 501 if (!device_id.empty() && !UpdateDeviceIDForSingletonType(device_id)) { |
504 std::string gallery_name; | 502 std::string gallery_name; |
505 if (StorageInfo::IsITunesDevice(device_id)) | 503 if (StorageInfo::IsITunesDevice(device_id)) |
506 gallery_name = kITunesGalleryName; | 504 gallery_name = kITunesGalleryName; |
507 else if (StorageInfo::IsPicasaDevice(device_id)) | 505 else if (StorageInfo::IsPicasaDevice(device_id)) |
508 gallery_name = kPicasaGalleryName; | 506 gallery_name = kPicasaGalleryName; |
509 else | 507 else |
510 NOTREACHED(); | 508 NOTREACHED(); |
511 | 509 |
512 AddGalleryInternal(device_id, ASCIIToUTF16(gallery_name), | 510 AddGalleryInternal(device_id, ASCIIToUTF16(gallery_name), |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1048 if (extension_prefs_for_testing_) | 1046 if (extension_prefs_for_testing_) |
1049 return extension_prefs_for_testing_; | 1047 return extension_prefs_for_testing_; |
1050 return extensions::ExtensionPrefs::Get(profile_); | 1048 return extensions::ExtensionPrefs::Get(profile_); |
1051 } | 1049 } |
1052 | 1050 |
1053 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1051 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1054 extensions::ExtensionPrefs* extension_prefs) { | 1052 extensions::ExtensionPrefs* extension_prefs) { |
1055 DCHECK(IsInitialized()); | 1053 DCHECK(IsInitialized()); |
1056 extension_prefs_for_testing_ = extension_prefs; | 1054 extension_prefs_for_testing_ = extension_prefs; |
1057 } | 1055 } |
OLD | NEW |