OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const string16& top_level_folder_name) { | 116 const string16& top_level_folder_name) { |
117 if (bookmarks.empty()) | 117 if (bookmarks.empty()) |
118 return; | 118 return; |
119 | 119 |
120 BookmarkModel* model = profile_->GetBookmarkModel(); | 120 BookmarkModel* model = profile_->GetBookmarkModel(); |
121 DCHECK(model->IsLoaded()); | 121 DCHECK(model->IsLoaded()); |
122 | 122 |
123 // If the bookmark bar is currently empty, we should import directly to it. | 123 // If the bookmark bar is currently empty, we should import directly to it. |
124 // Otherwise, we should import everything to a subfolder. | 124 // Otherwise, we should import everything to a subfolder. |
125 const BookmarkNode* bookmark_bar = model->GetBookmarkBarNode(); | 125 const BookmarkNode* bookmark_bar = model->GetBookmarkBarNode(); |
126 bool import_to_top_level = bookmark_bar->child_count() == 0; | 126 bool import_to_top_level = bookmark_bar->empty(); |
127 | 127 |
128 // If the user currently has no bookmarks in the bookmark bar, make sure that | 128 // If the user currently has no bookmarks in the bookmark bar, make sure that |
129 // at least some of the imported bookmarks end up there. Otherwise, we'll end | 129 // at least some of the imported bookmarks end up there. Otherwise, we'll end |
130 // up with just a single folder containing the imported bookmarks, which makes | 130 // up with just a single folder containing the imported bookmarks, which makes |
131 // for unnecessary nesting. | 131 // for unnecessary nesting. |
132 bool add_all_to_top_level = import_to_top_level; | 132 bool add_all_to_top_level = import_to_top_level; |
133 for (std::vector<BookmarkEntry>::const_iterator it = bookmarks.begin(); | 133 for (std::vector<BookmarkEntry>::const_iterator it = bookmarks.begin(); |
134 it != bookmarks.end() && add_all_to_top_level; ++it) { | 134 it != bookmarks.end() && add_all_to_top_level; ++it) { |
135 if (it->in_toolbar) | 135 if (it->in_toolbar) |
136 add_all_to_top_level = false; | 136 add_all_to_top_level = false; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) | 330 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) |
331 model->SetDefaultSearchProvider(t_url); | 331 model->SetDefaultSearchProvider(t_url); |
332 } else { | 332 } else { |
333 // Don't add invalid TemplateURLs to the model. | 333 // Don't add invalid TemplateURLs to the model. |
334 delete t_url; | 334 delete t_url; |
335 } | 335 } |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 ProfileWriter::~ProfileWriter() {} | 339 ProfileWriter::~ProfileWriter() {} |
OLD | NEW |