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

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

Issue 2409423005: Compare GURLs to kUrlConstants with .spec() and string equality (Closed)
Patch Set: rebase on dependent patch Created 4 years, 2 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
OLDNEW
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/bookmarks_file_importer.h" 5 #include "chrome/utility/importer/bookmarks_file_importer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 25 matching lines...) Expand all
36 return false; 36 return false;
37 37
38 // Filter out the URLs with unsupported schemes. 38 // Filter out the URLs with unsupported schemes.
39 const char* const kInvalidSchemes[] = {"wyciwyg", "place"}; 39 const char* const kInvalidSchemes[] = {"wyciwyg", "place"};
40 for (size_t i = 0; i < arraysize(kInvalidSchemes); ++i) { 40 for (size_t i = 0; i < arraysize(kInvalidSchemes); ++i) {
41 if (url.SchemeIs(kInvalidSchemes[i])) 41 if (url.SchemeIs(kInvalidSchemes[i]))
42 return false; 42 return false;
43 } 43 }
44 44
45 // Check if |url| is about:blank. 45 // Check if |url| is about:blank.
46 if (url == GURL(url::kAboutBlankURL)) 46 if (url == url::kAboutBlankURL)
47 return true; 47 return true;
48 48
49 // If |url| starts with chrome:// or about:, check if it's one of the URLs 49 // If |url| starts with chrome:// or about:, check if it's one of the URLs
50 // that we support. 50 // that we support.
51 if (url.SchemeIs(content::kChromeUIScheme) || 51 if (url.SchemeIs(content::kChromeUIScheme) ||
52 url.SchemeIs(url::kAboutScheme)) { 52 url.SchemeIs(url::kAboutScheme)) {
53 if (url.host() == chrome::kChromeUIUberHost || 53 if (url.host() == chrome::kChromeUIUberHost ||
54 url.host() == chrome::kChromeUIAboutHost) 54 url.host() == chrome::kChromeUIAboutHost)
55 return true; 55 return true;
56 56
57 GURL fixed_url(url_formatter::FixupURL(url.spec(), std::string())); 57 GURL fixed_url(url_formatter::FixupURL(url.spec(), std::string()));
58 for (size_t i = 0; i < chrome::kNumberOfChromeHostURLs; ++i) { 58 for (size_t i = 0; i < chrome::kNumberOfChromeHostURLs; ++i) {
59 if (fixed_url.DomainIs(chrome::kChromeHostURLs[i])) 59 if (fixed_url.DomainIs(chrome::kChromeHostURLs[i]))
60 return true; 60 return true;
61 } 61 }
62 62
63 for (int i = 0; i < chrome::kNumberOfChromeDebugURLs; ++i) { 63 for (int i = 0; i < chrome::kNumberOfChromeDebugURLs; ++i) {
64 if (fixed_url == GURL(chrome::kChromeDebugURLs[i])) 64 if (fixed_url == chrome::kChromeDebugURLs[i])
65 return true; 65 return true;
66 } 66 }
67 67
68 // If url has either chrome:// or about: schemes but wasn't found in the 68 // If url has either chrome:// or about: schemes but wasn't found in the
69 // above lists, it means we don't support it, so we don't allow the user 69 // above lists, it means we don't support it, so we don't allow the user
70 // to import it. 70 // to import it.
71 return false; 71 return false;
72 } 72 }
73 73
74 // Otherwise, we assume the url has a valid (importable) scheme. 74 // Otherwise, we assume the url has a valid (importable) scheme.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 bridge->AddBookmarks(bookmarks, first_folder_name); 110 bridge->AddBookmarks(bookmarks, first_folder_name);
111 } 111 }
112 if (!search_engines.empty()) 112 if (!search_engines.empty())
113 bridge->SetKeywords(search_engines, false); 113 bridge->SetKeywords(search_engines, false);
114 if (!favicons.empty()) 114 if (!favicons.empty())
115 bridge->SetFavicons(favicons); 115 bridge->SetFavicons(favicons);
116 116
117 bridge->NotifyItemEnded(importer::FAVORITES); 117 bridge->NotifyItemEnded(importer::FAVORITES);
118 bridge->NotifyEnded(); 118 bridge->NotifyEnded();
119 } 119 }
OLDNEW
« no previous file with comments | « chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc ('k') | content/public/common/url_constants.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698