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

Side by Side Diff: chrome/utility/importer/bookmark_html_reader.cc

Issue 18501013: Move most importer code to chrome/utility/importer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac4 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
gab 2013/07/08 15:18:08 This should probably go in the "bookmarks" compone
scottmg 2013/07/09 16:20:49 see comment in DEPS
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/bookmark_html_reader.h" 5 #include "chrome/utility/importer/bookmark_html_reader.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/icu_string_conversions.h" 9 #include "base/i18n/icu_string_conversions.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/favicon/favicon_util.h"
15 #include "chrome/common/importer/imported_bookmark_entry.h" 14 #include "chrome/common/importer/imported_bookmark_entry.h"
16 #include "chrome/common/importer/imported_favicon_usage.h" 15 #include "chrome/common/importer/imported_favicon_usage.h"
16 #include "chrome/utility/importer/favicon_reencode.h"
17 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
18 #include "net/base/data_url.h" 18 #include "net/base/data_url.h"
19 #include "net/base/escape.h" 19 #include "net/base/escape.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 namespace { 22 namespace {
23 23
24 // Fetches the given |attribute| value from the |attribute_list|. Returns true 24 // Fetches the given |attribute| value from the |attribute_list|. Returns true
25 // if successful, and |value| will contain the value. 25 // if successful, and |value| will contain the value.
26 bool GetAttribute(const std::string& attribute_list, 26 bool GetAttribute(const std::string& attribute_list,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 !favicon_data.SchemeIs(chrome::kDataScheme)) 60 !favicon_data.SchemeIs(chrome::kDataScheme))
61 return; 61 return;
62 62
63 // Parse the data URL. 63 // Parse the data URL.
64 std::string mime_type, char_set, data; 64 std::string mime_type, char_set, data;
65 if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) || 65 if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) ||
66 data.empty()) 66 data.empty())
67 return; 67 return;
68 68
69 ImportedFaviconUsage usage; 69 ImportedFaviconUsage usage;
70 if (!FaviconUtil::ReencodeFavicon( 70 if (!importer::ReencodeFavicon(
71 reinterpret_cast<const unsigned char*>(&data[0]), 71 reinterpret_cast<const unsigned char*>(&data[0]),
72 data.size(), &usage.png_data)) 72 data.size(), &usage.png_data))
73 return; // Unable to decode. 73 return; // Unable to decode.
74 74
75 // We need to make up a URL for the favicon. We use a version of the page's 75 // We need to make up a URL for the favicon. We use a version of the page's
76 // URL so that we can be sure it will not collide. 76 // URL so that we can be sure it will not collide.
77 usage.favicon_url = GURL(std::string("made-up-favicon:") + link_url.spec()); 77 usage.favicon_url = GURL(std::string("made-up-favicon:") + link_url.spec());
78 78
79 // We only have one URL per favicon for Firefox 2 bookmarks. 79 // We only have one URL per favicon for Firefox 2 bookmarks.
80 usage.urls.insert(link_url); 80 usage.urls.insert(link_url);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 *url = GURL(value); 423 *url = GURL(value);
424 } 424 }
425 } 425 }
426 426
427 return true; 427 return true;
428 } 428 }
429 429
430 } // namespace internal 430 } // namespace internal
431 431
432 } // namespace bookmark_html_reader 432 } // namespace bookmark_html_reader
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698