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

Unified Diff: chrome/browser/media_galleries/fileapi/itunes_finder_mac.mm

Issue 19617005: Define iTunes location for media galleries tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile Created 7 years, 4 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
Index: chrome/browser/media_galleries/fileapi/itunes_finder_mac.mm
diff --git a/chrome/browser/media_galleries/fileapi/itunes_finder_mac.mm b/chrome/browser/media_galleries/fileapi/itunes_finder_mac.mm
index 3780160263982a9f35de8a998d938ec81cf53bc4..5a44902fd0936edaa83528116bbd4e673582fcca 100644
--- a/chrome/browser/media_galleries/fileapi/itunes_finder_mac.mm
+++ b/chrome/browser/media_galleries/fileapi/itunes_finder_mac.mm
@@ -7,29 +7,56 @@
#include "base/file_util.h"
#include "base/logging.h"
#import "base/mac/foundation_util.h"
+#import "base/mac/scoped_cftyperef.h"
#import "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/time/time.h"
+#include "chrome/browser/policy/preferences_mac.h"
#include "content/public/browser/browser_thread.h"
using base::mac::CFCast;
using base::mac::CFToNSCast;
+namespace {
+
+static MacPreferences* g_mac_preferences = NULL;
+
+NSArray* GetItunesRecentDatabasePaths() {
+ scoped_ptr<MacPreferences> real_preferences;
+ MacPreferences* prefs = g_mac_preferences;
+ if (!prefs) {
+ real_preferences.reset(new MacPreferences());
+ prefs = real_preferences.get();
+ }
+ CFStringRef iapp_id = CFSTR("com.apple.iApps");
+ base::ScopedCFTypeRef<CFString> recent_database_path_key(
+ CFStringCreateWithCStringNoCopy(NULL, kITunesRecentDatabasePathsKey,
+ kCFStringEncodingASCII, NULL));
+ return CFToNSCast(CFCast<CFArrayRef>(prefs->CopyAppValue(
+ recent_database_path_key.get(), iapp_id)));
+}
+
+} // namespace
+
namespace itunes {
+const char kITunesRecentDatabasePathsKey[] = "iTunesRecentDatabasePaths";
+
ITunesFinderMac::ITunesFinderMac(const ITunesFinderCallback& callback)
: ITunesFinder(callback) {
}
ITunesFinderMac::~ITunesFinderMac() {}
+// static
+void ITunesFinderMac::SetMacPreferencesForTesting(MacPreferences* preferences) {
+ g_mac_preferences = preferences;
+}
+
void ITunesFinderMac::FindITunesLibraryOnFileThread() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
- CFStringRef iapp_id = CFSTR("com.apple.iApps");
- CFStringRef itunes_db_key = CFSTR("iTunesRecentDatabasePaths");
- base::scoped_nsobject<NSArray> plist(CFToNSCast(
- CFCast<CFArrayRef>(CFPreferencesCopyAppValue(itunes_db_key, iapp_id))));
+ base::scoped_nsobject<NSArray> plist(GetItunesRecentDatabasePaths());
if (!plist) {
PostResultToUIThread(std::string());
return;
« no previous file with comments | « chrome/browser/media_galleries/fileapi/itunes_finder_mac.h ('k') | chrome/browser/media_galleries/media_galleries_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698