Give names to all utility processes.
[chromium-blink-merge.git] / chrome / browser / media_galleries / fileapi / picasa_finder_mac.mm
blobb0c1d158bb662e7c945516510731002f105e54ff
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h"
7 #include "base/files/file_path.h"
8 #import "base/mac/foundation_util.h"
9 #import "base/mac/scoped_nsobject.h"
10 #include "components/policy/core/common/preferences_mac.h"
11 #include "content/public/browser/browser_thread.h"
13 using base::mac::CFCast;
14 using base::mac::CFToNSCast;
15 using base::mac::NSToCFCast;
17 namespace picasa {
19 namespace {
21 static MacPreferences* g_test_mac_preferences = NULL;
23 }  // namespace
25 NSString* const kPicasaAppDataPathMacPreferencesKey = @"AppLocalDataPath";
27 void SetMacPreferencesForTesting(MacPreferences* preferences) {
28   g_test_mac_preferences = preferences;
31 base::FilePath GetCustomPicasaAppDataPathFromMacPreferences() {
32   DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
34   scoped_ptr<MacPreferences> real_preferences;
35   MacPreferences* prefs = g_test_mac_preferences;
36   if (!prefs) {
37     real_preferences.reset(new MacPreferences());
38     prefs = real_preferences.get();
39   }
41   CFStringRef picasa_app_id = CFSTR("com.google.picasa");
42   base::scoped_nsobject<NSString> database_path(
43       CFToNSCast(CFCast<CFStringRef>(prefs->CopyAppValue(
44           NSToCFCast(kPicasaAppDataPathMacPreferencesKey), picasa_app_id))));
46   if (database_path == NULL)
47     return base::FilePath();
49   return base::mac::NSStringToFilePath(database_path.get());
52 }  // namespace picasa