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

Side by Side Diff: chrome/browser/importer/bookmarks_file_importer.cc

Issue 18501013: Move most importer code to chrome/utility/importer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another gyp attempt Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/importer/bookmarks_file_importer.h"
6
7 #include "base/bind.h"
8 #include "chrome/browser/importer/bookmark_html_reader.h"
9 #include "chrome/browser/importer/firefox_importer_utils.h"
10 #include "chrome/browser/importer/importer_bridge.h"
11 #include "chrome/common/importer/imported_bookmark_entry.h"
12 #include "chrome/common/importer/imported_favicon_usage.h"
13 #include "chrome/common/importer/importer_data_types.h"
14 #include "grit/generated_resources.h"
15
16 namespace {
17
18 bool IsImporterCancelled(BookmarksFileImporter* importer) {
19 return importer->cancelled();
20 }
21
22 } // namespace
23
24 BookmarksFileImporter::BookmarksFileImporter() {}
25
26 BookmarksFileImporter::~BookmarksFileImporter() {}
27
28 void BookmarksFileImporter::StartImport(
29 const importer::SourceProfile& source_profile,
30 uint16 items,
31 ImporterBridge* bridge) {
32 // The only thing this importer can import is a bookmarks file, aka
33 // "favorites".
34 DCHECK_EQ(importer::FAVORITES, items);
35
36 bridge->NotifyStarted();
37 bridge->NotifyItemStarted(importer::FAVORITES);
38
39 std::vector<ImportedBookmarkEntry> bookmarks;
40 std::vector<ImportedFaviconUsage> favicons;
41
42 bookmark_html_reader::ImportBookmarksFile(
43 base::Bind(IsImporterCancelled, base::Unretained(this)),
44 base::Bind(CanImportURL),
45 source_profile.source_path,
46 &bookmarks,
47 &favicons);
48
49 if (!bookmarks.empty() && !cancelled()) {
50 base::string16 first_folder_name =
51 bridge->GetLocalizedString(IDS_BOOKMARK_GROUP);
52 bridge->AddBookmarks(bookmarks, first_folder_name);
53 }
54 if (!favicons.empty())
55 bridge->SetFavicons(favicons);
56
57 bridge->NotifyItemEnded(importer::FAVORITES);
58 bridge->NotifyEnded();
59 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/bookmarks_file_importer.h ('k') | chrome/browser/importer/external_process_importer_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698