• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2011 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.
4
5#include <Cocoa/Cocoa.h>
6#include <sys/param.h>
7
8#include "chrome/common/importer/firefox_importer_utils.h"
9
10#include "base/file_util.h"
11#include "base/mac/foundation_util.h"
12#include "base/path_service.h"
13
14base::FilePath GetProfilesINI() {
15  base::FilePath app_data_path;
16  if (!PathService::Get(base::DIR_APP_DATA, &app_data_path)) {
17    return base::FilePath();
18  }
19  base::FilePath ini_file =
20      app_data_path.Append("Firefox").Append("profiles.ini");
21  if (!base::PathExists(ini_file)) {
22    return base::FilePath();
23  }
24  return ini_file;
25}
26
27base::FilePath GetFirefoxDylibPath() {
28  CFURLRef appURL = nil;
29  if (LSFindApplicationForInfo(kLSUnknownCreator,
30                              CFSTR("org.mozilla.firefox"),
31                              NULL,
32                              NULL,
33                              &appURL) != noErr) {
34    return base::FilePath();
35  }
36  NSBundle *ff_bundle =
37      [NSBundle bundleWithPath:[base::mac::CFToNSCast(appURL) path]];
38  CFRelease(appURL);
39  NSString *ff_library_path =
40      [[ff_bundle executablePath] stringByDeletingLastPathComponent];
41  char buf[MAXPATHLEN];
42  if (![ff_library_path getFileSystemRepresentation:buf maxLength:sizeof(buf)])
43    return base::FilePath();
44  return base::FilePath(buf);
45}
46