OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/utility/importer/firefox_importer.h" | 5 #include "chrome/utility/importer/firefox_importer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 struct FirefoxImporter::BookmarkItem { | 80 struct FirefoxImporter::BookmarkItem { |
81 int parent; | 81 int parent; |
82 int id; | 82 int id; |
83 GURL url; | 83 GURL url; |
84 string16 title; | 84 base::string16 title; |
85 BookmarkItemType type; | 85 BookmarkItemType type; |
86 std::string keyword; | 86 std::string keyword; |
87 base::Time date_added; | 87 base::Time date_added; |
88 int64 favicon; | 88 int64 favicon; |
89 bool empty_folder; | 89 bool empty_folder; |
90 }; | 90 }; |
91 | 91 |
92 FirefoxImporter::FirefoxImporter() { | 92 FirefoxImporter::FirefoxImporter() { |
93 } | 93 } |
94 | 94 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } else { | 251 } else { |
252 continue; | 252 continue; |
253 } | 253 } |
254 | 254 |
255 // Skip the default bookmarks and unwanted URLs. | 255 // Skip the default bookmarks and unwanted URLs. |
256 if (default_urls.find(item->url) != default_urls.end() || | 256 if (default_urls.find(item->url) != default_urls.end() || |
257 post_keyword_ids.find(item->id) != post_keyword_ids.end()) | 257 post_keyword_ids.find(item->id) != post_keyword_ids.end()) |
258 continue; | 258 continue; |
259 | 259 |
260 // Find the bookmark path by tracing their links to parent folders. | 260 // Find the bookmark path by tracing their links to parent folders. |
261 std::vector<string16> path; | 261 std::vector<base::string16> path; |
262 BookmarkItem* child = item; | 262 BookmarkItem* child = item; |
263 bool found_path = false; | 263 bool found_path = false; |
264 bool is_in_toolbar = false; | 264 bool is_in_toolbar = false; |
265 while (child->parent >= 0) { | 265 while (child->parent >= 0) { |
266 BookmarkItem* parent = list[child->parent]; | 266 BookmarkItem* parent = list[child->parent]; |
267 if (livemark_id.find(parent->id) != livemark_id.end()) { | 267 if (livemark_id.find(parent->id) != livemark_id.end()) { |
268 // Don't import live bookmarks. | 268 // Don't import live bookmarks. |
269 break; | 269 break; |
270 } | 270 } |
271 | 271 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 url_keyword_info.display_name = item->title; | 314 url_keyword_info.display_name = item->title; |
315 url_keywords.push_back(url_keyword_info); | 315 url_keywords.push_back(url_keyword_info); |
316 } | 316 } |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 STLDeleteElements(&list); | 320 STLDeleteElements(&list); |
321 | 321 |
322 // Write into profile. | 322 // Write into profile. |
323 if (!bookmarks.empty() && !cancelled()) { | 323 if (!bookmarks.empty() && !cancelled()) { |
324 const string16& first_folder_name = | 324 const base::string16& first_folder_name = |
325 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_FIREFOX); | 325 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_FIREFOX); |
326 bridge_->AddBookmarks(bookmarks, first_folder_name); | 326 bridge_->AddBookmarks(bookmarks, first_folder_name); |
327 } | 327 } |
328 if (!url_keywords.empty() && !cancelled()) { | 328 if (!url_keywords.empty() && !cancelled()) { |
329 bridge_->SetKeywords(url_keywords, false); | 329 bridge_->SetKeywords(url_keywords, false); |
330 } | 330 } |
331 if (!favicon_map.empty() && !cancelled()) { | 331 if (!favicon_map.empty() && !cancelled()) { |
332 std::vector<ImportedFaviconUsage> favicons; | 332 std::vector<ImportedFaviconUsage> favicons; |
333 LoadFavicons(&db, favicon_map, &favicons); | 333 LoadFavicons(&db, favicon_map, &favicons); |
334 bridge_->SetFavicons(favicons); | 334 bridge_->SetFavicons(favicons); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 595 |
596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
597 continue; // Unable to decode. | 597 continue; // Unable to decode. |
598 | 598 |
599 usage.urls = i->second; | 599 usage.urls = i->second; |
600 favicons->push_back(usage); | 600 favicons->push_back(usage); |
601 } | 601 } |
602 s.Reset(true); | 602 s.Reset(true); |
603 } | 603 } |
604 } | 604 } |
OLD | NEW |