Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/bookmarks/bookmark_html_reader.h" | |
| 9 #include "chrome/browser/bookmarks/imported_bookmark_entry.h" | |
| 10 #include "chrome/browser/importer/firefox_importer_utils.h" | |
| 11 #include "chrome/browser/importer/importer_bridge.h" | |
| 12 #include "chrome/browser/importer/importer_data_types.h" | |
| 13 #include "chrome/browser/importer/importer_util.h" | |
| 14 #include "grit/generated_resources.h" | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 bool ImporterCancelBridge(BookmarksFileImporter* importer) { | |
|
gab
2013/05/10 20:37:57
nit: I find this name rather vague, rename to IsIm
Avi (use Gerrit)
2013/05/10 21:34:53
Done.
| |
| 19 return importer->cancelled(); | |
| 20 } | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 BookmarksFileImporter::BookmarksFileImporter() {} | |
|
gab
2013/05/10 20:37:57
Inline empty constructors in the header.
Avi (use Gerrit)
2013/05/10 21:34:53
Why? We put empty constructors in .cc files all th
gab
2013/05/10 21:47:44
Ah ok, I guess that's fine, I thought I'd mostly s
| |
| 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<history::ImportedFaviconUsage> dirty_favicons; | |
| 41 base::Callback<bool(void)> cancellation_callback = | |
| 42 base::Bind(ImporterCancelBridge, base::Unretained(this)); | |
| 43 base::Callback<bool(const GURL&)> valid_url_callback = | |
| 44 base::Bind(CanImportURL); | |
| 45 | |
| 46 bookmark_html_reader::ImportBookmarksFile(&cancellation_callback, | |
| 47 &valid_url_callback, | |
| 48 source_profile.source_path, | |
| 49 &bookmarks, | |
| 50 &dirty_favicons); | |
| 51 | |
| 52 std::vector<history::ImportedFaviconUsage> clean_favicons; | |
| 53 for (size_t i = 0; i < dirty_favicons.size(); ++i) { | |
| 54 history::ImportedFaviconUsage& favicon = dirty_favicons[i]; | |
|
gab
2013/05/10 20:37:57
Use a *, non-const & are not allowed by the style
Avi (use Gerrit)
2013/05/10 21:34:53
They're disallowed as parameters; where are they d
gab
2013/05/10 21:47:44
You're right, the style only mentions parameters..
| |
| 55 std::vector<unsigned char> clean_data; | |
| 56 if (importer::ReencodeFavicon(&favicon.png_data[0], | |
| 57 favicon.png_data.size(), | |
| 58 &clean_data)) { | |
| 59 favicon.png_data.swap(clean_data); | |
| 60 } | |
| 61 clean_favicons.push_back(favicon); | |
| 62 } | |
| 63 | |
| 64 if (!bookmarks.empty() && !cancelled()) { | |
| 65 base::string16 first_folder_name = | |
| 66 bridge->GetLocalizedString(IDS_BOOKMARK_GROUP); | |
| 67 bridge->AddBookmarks(bookmarks, first_folder_name); | |
| 68 } | |
| 69 if (!clean_favicons.empty()) | |
| 70 bridge->SetFavicons(clean_favicons); | |
| 71 | |
| 72 bridge->NotifyItemEnded(importer::FAVORITES); | |
| 73 bridge->NotifyEnded(); | |
| 74 } | |
| OLD | NEW |