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/common/importer/safari_importer_utils.h"
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "chrome/common/importer/importer_data_types.h"
11 bool SafariImporterCanImport(const base::FilePath& library_dir,
12 uint16* services_supported) {
13 DCHECK(services_supported);
14 *services_supported = importer::NONE;
16 // Import features are toggled by the following:
17 // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file.
18 // history import: existence of ~/Library/Safari/History.plist file.
19 base::FilePath safari_dir = library_dir.Append("Safari");
20 base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist");
21 base::FilePath history_path = safari_dir.Append("History.plist");
23 if (base::PathExists(bookmarks_path))
24 *services_supported |= importer::FAVORITES;
25 if (base::PathExists(history_path))
26 *services_supported |= importer::HISTORY;
28 return *services_supported != importer::NONE;