diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 00:20:43 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 00:20:43 +0000 |
commit | b5be866f9119f720aef34428e06492577a3f64b4 (patch) | |
tree | 782d0ccd8d62d25d3ee79aa82b02720aec46e391 | |
parent | 5c42f9bb2abe00c8d87dc81968e6076076ec5cc6 (diff) | |
download | chromium_src-b5be866f9119f720aef34428e06492577a3f64b4.zip chromium_src-b5be866f9119f720aef34428e06492577a3f64b4.tar.gz chromium_src-b5be866f9119f720aef34428e06492577a3f64b4.tar.bz2 |
move SafariImporter::CanImport to common
Split out from https://codereview.chromium.org/18501013/ and that
must be landed first.
TBR=gab@chromium.org
BUG=254672, 237249
Review URL: https://codereview.chromium.org/19251002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211881 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/DEPS | 3 | ||||
-rw-r--r-- | chrome/browser/importer/importer_list.cc | 4 | ||||
-rw-r--r-- | chrome/chrome_common.gypi | 2 | ||||
-rw-r--r-- | chrome/common/importer/safari_importer_utils.h | 22 | ||||
-rw-r--r-- | chrome/common/importer/safari_importer_utils.mm | 29 | ||||
-rw-r--r-- | chrome/utility/importer/safari_importer.h | 8 | ||||
-rw-r--r-- | chrome/utility/importer/safari_importer.mm | 21 | ||||
-rw-r--r-- | chrome/utility/importer/safari_importer_unittest.mm | 5 |
8 files changed, 58 insertions, 36 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index a5224c7..6ccf6b6 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -69,9 +69,6 @@ include_rules = [ "+chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h", "+chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h", - # Should not be using utility process code. http://crbug.com/254672 - "!chrome/utility", - # Other libraries. "+chrome/third_party/mozilla_security_manager", "+libxml", # For search engine definition parsing. diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index 0339ee1..0e9ff34 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -17,7 +17,7 @@ #include <CoreFoundation/CoreFoundation.h> #include "base/mac/foundation_util.h" -#include "chrome/utility/importer/safari_importer.h" +#include "chrome/common/importer/safari_importer_utils.h" #endif using content::BrowserThread; @@ -41,7 +41,7 @@ void DetectIEProfiles(std::vector<importer::SourceProfile*>* profiles) { #if defined(OS_MACOSX) void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) { uint16 items = importer::NONE; - if (!SafariImporter::CanImport(base::mac::GetUserLibraryPath(), &items)) + if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items)) return; importer::SourceProfile* safari = new importer::SourceProfile; diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index fc4bf01..a9b5d56 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -355,6 +355,8 @@ 'common/importer/importer_url_row.h', 'common/importer/profile_import_process_messages.cc', 'common/importer/profile_import_process_messages.h', + 'common/importer/safari_importer_utils.h', + 'common/importer/safari_importer_utils.mm', 'common/instant_restricted_id_cache.h', 'common/instant_types.cc', 'common/instant_types.h', diff --git a/chrome/common/importer/safari_importer_utils.h b/chrome/common/importer/safari_importer_utils.h new file mode 100644 index 0000000..60c9546 --- /dev/null +++ b/chrome/common/importer/safari_importer_utils.h @@ -0,0 +1,22 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_IMPORTER_SAFARI_IMPORTER_UTILS_H_ +#define CHROME_COMMON_IMPORTER_SAFARI_IMPORTER_UTILS_H_ + +#include "base/basictypes.h" + +namespace base { +class FilePath; +} + +// Does this user account have a Safari Profile and if so, what items +// are supported? +// in: library_dir - ~/Library or a standin for testing purposes. +// out: services_supported - the service supported for import. +// Returns true if we can import the Safari profile. +bool SafariImporterCanImport(const base::FilePath& library_dir, + uint16* services_supported); + +#endif // CHROME_COMMON_IMPORTER_SAFARI_IMPORTER_UTILS_H_ diff --git a/chrome/common/importer/safari_importer_utils.mm b/chrome/common/importer/safari_importer_utils.mm new file mode 100644 index 0000000..21edcdd --- /dev/null +++ b/chrome/common/importer/safari_importer_utils.mm @@ -0,0 +1,29 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/importer/safari_importer_utils.h" + +#include "base/file_util.h" +#include "base/files/file_path.h" +#include "chrome/common/importer/importer_data_types.h" + +bool SafariImporterCanImport(const base::FilePath& library_dir, + uint16* services_supported) { + DCHECK(services_supported); + *services_supported = importer::NONE; + + // Import features are toggled by the following: + // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file. + // history import: existence of ~/Library/Safari/History.plist file. + base::FilePath safari_dir = library_dir.Append("Safari"); + base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist"); + base::FilePath history_path = safari_dir.Append("History.plist"); + + if (base::PathExists(bookmarks_path)) + *services_supported |= importer::FAVORITES; + if (base::PathExists(history_path)) + *services_supported |= importer::HISTORY; + + return *services_supported != importer::NONE; +} diff --git a/chrome/utility/importer/safari_importer.h b/chrome/utility/importer/safari_importer.h index 8b346d2..ea64284 100644 --- a/chrome/utility/importer/safari_importer.h +++ b/chrome/utility/importer/safari_importer.h @@ -44,14 +44,6 @@ class SafariImporter : public Importer { uint16 items, ImporterBridge* bridge) OVERRIDE; - // Does this user account have a Safari Profile and if so, what items - // are supported? - // in: library_dir - ~/Library or a standin for testing purposes. - // out: services_supported - the service supported for import. - // Returns true if we can import the Safari profile. - static bool CanImport(const base::FilePath& library_dir, - uint16* services_supported); - private: FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, BookmarkImport); FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, FaviconImport); diff --git a/chrome/utility/importer/safari_importer.mm b/chrome/utility/importer/safari_importer.mm index 8740742..2bcbce9 100644 --- a/chrome/utility/importer/safari_importer.mm +++ b/chrome/utility/importer/safari_importer.mm @@ -48,27 +48,6 @@ SafariImporter::SafariImporter(const base::FilePath& library_dir) SafariImporter::~SafariImporter() { } -// static -bool SafariImporter::CanImport(const base::FilePath& library_dir, - uint16* services_supported) { - DCHECK(services_supported); - *services_supported = importer::NONE; - - // Import features are toggled by the following: - // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file. - // history import: existence of ~/Library/Safari/History.plist file. - base::FilePath safari_dir = library_dir.Append("Safari"); - base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist"); - base::FilePath history_path = safari_dir.Append("History.plist"); - - if (base::PathExists(bookmarks_path)) - *services_supported |= importer::FAVORITES; - if (base::PathExists(history_path)) - *services_supported |= importer::HISTORY; - - return *services_supported != importer::NONE; -} - void SafariImporter::StartImport(const importer::SourceProfile& source_profile, uint16 items, ImporterBridge* bridge) { diff --git a/chrome/utility/importer/safari_importer_unittest.mm b/chrome/utility/importer/safari_importer_unittest.mm index 05392a4..d6c93e2 100644 --- a/chrome/utility/importer/safari_importer_unittest.mm +++ b/chrome/utility/importer/safari_importer_unittest.mm @@ -17,6 +17,7 @@ #include "chrome/common/importer/imported_bookmark_entry.h" #include "chrome/common/importer/imported_favicon_usage.h" #include "chrome/common/importer/importer_bridge.h" +#include "chrome/common/importer/safari_importer_utils.h" #include "chrome/utility/importer/safari_importer.h" #include "sql/connection.h" #include "testing/platform_test.h" @@ -187,7 +188,7 @@ TEST_F(SafariImporterTest, FaviconImport) { TEST_F(SafariImporterTest, CanImport) { uint16 items = importer::NONE; - EXPECT_TRUE(SafariImporter::CanImport(GetTestSafariLibraryPath(), &items)); + EXPECT_TRUE(SafariImporterCanImport(GetTestSafariLibraryPath(), &items)); EXPECT_EQ(items, importer::HISTORY | importer::FAVORITES); EXPECT_EQ(items & importer::COOKIES, importer::NONE); EXPECT_EQ(items & importer::PASSWORDS, importer::NONE); @@ -197,5 +198,5 @@ TEST_F(SafariImporterTest, CanImport) { // Check that we don't import anything from a bogus library directory. base::ScopedTempDir fake_library_dir; ASSERT_TRUE(fake_library_dir.CreateUniqueTempDir()); - EXPECT_FALSE(SafariImporter::CanImport(fake_library_dir.path(), &items)); + EXPECT_FALSE(SafariImporterCanImport(fake_library_dir.path(), &items)); } |