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

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

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
« no previous file with comments | « chrome/browser/history/visit_database.cc ('k') | chrome/browser/importer/ie_importer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser/importer/firefox2_importer.h" 5 #include "chrome/browser/importer/firefox2_importer.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/importer/firefox_importer_utils.h" 12 #include "chrome/browser/importer/firefox_importer_utils.h"
13 #include "chrome/browser/importer/mork_reader.h" 13 #include "chrome/browser/importer/mork_reader.h"
14 #include "chrome/browser/search_engines/template_url.h" 14 #include "chrome/browser/search_engines/template_url.h"
15 #include "chrome/browser/search_engines/template_url_parser.h" 15 #include "chrome/browser/search_engines/template_url_parser.h"
16 #include "chrome/common/l10n_util.h" 16 #include "chrome/common/l10n_util.h"
17 #include "chrome/common/time_format.h" 17 #include "chrome/common/time_format.h"
18 #include "chrome/common/url_constants.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
19 #include "net/base/data_url.h" 20 #include "net/base/data_url.h"
20 21
21 using base::Time; 22 using base::Time;
22 23
23 // Firefox2Importer. 24 // Firefox2Importer.
24 25
25 Firefox2Importer::Firefox2Importer() : parsing_bookmarks_html_file_(false) { 26 Firefox2Importer::Firefox2Importer() : parsing_bookmarks_html_file_(false) {
26 } 27 }
27 28
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 file = file_enum.Next().ToWStringHack(); 521 file = file_enum.Next().ToWStringHack();
521 } 522 }
522 } 523 }
523 524
524 // static 525 // static
525 void Firefox2Importer::DataURLToFaviconUsage( 526 void Firefox2Importer::DataURLToFaviconUsage(
526 const GURL& link_url, 527 const GURL& link_url,
527 const GURL& favicon_data, 528 const GURL& favicon_data,
528 std::vector<history::ImportedFavIconUsage>* favicons) { 529 std::vector<history::ImportedFavIconUsage>* favicons) {
529 if (!link_url.is_valid() || !favicon_data.is_valid() || 530 if (!link_url.is_valid() || !favicon_data.is_valid() ||
530 !favicon_data.SchemeIs("data")) 531 !favicon_data.SchemeIs(chrome::kDataScheme))
531 return; 532 return;
532 533
533 // Parse the data URL. 534 // Parse the data URL.
534 std::string mime_type, char_set, data; 535 std::string mime_type, char_set, data;
535 if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) || 536 if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) ||
536 data.empty()) 537 data.empty())
537 return; 538 return;
538 539
539 history::ImportedFavIconUsage usage; 540 history::ImportedFavIconUsage usage;
540 if (!ReencodeFavicon(reinterpret_cast<const unsigned char*>(&data[0]), 541 if (!ReencodeFavicon(reinterpret_cast<const unsigned char*>(&data[0]),
541 data.size(), &usage.png_data)) 542 data.size(), &usage.png_data))
542 return; // Unable to decode. 543 return; // Unable to decode.
543 544
544 // We need to make up a URL for the favicon. We use a version of the page's 545 // We need to make up a URL for the favicon. We use a version of the page's
545 // URL so that we can be sure it will not collide. 546 // URL so that we can be sure it will not collide.
546 usage.favicon_url = GURL(std::string("made-up-favicon:") + link_url.spec()); 547 usage.favicon_url = GURL(std::string("made-up-favicon:") + link_url.spec());
547 548
548 // We only have one URL per favicon for Firefox 2 bookmarks. 549 // We only have one URL per favicon for Firefox 2 bookmarks.
549 usage.urls.insert(link_url); 550 usage.urls.insert(link_url);
550 551
551 favicons->push_back(usage); 552 favicons->push_back(usage);
552 } 553 }
OLDNEW
« no previous file with comments | « chrome/browser/history/visit_database.cc ('k') | chrome/browser/importer/ie_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698