OLD | NEW |
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/importer.h" | 5 #include "chrome/browser/importer/importer.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "app/gfx/favicon_size.h" | 10 #include "app/gfx/favicon_size.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const BookmarkNode* parent = | 116 const BookmarkNode* parent = |
117 (it->in_toolbar ? model->GetBookmarkBarNode() : model->other_node()); | 117 (it->in_toolbar ? model->GetBookmarkBarNode() : model->other_node()); |
118 for (std::vector<std::wstring>::const_iterator i = it->path.begin(); | 118 for (std::vector<std::wstring>::const_iterator i = it->path.begin(); |
119 i != it->path.end(); ++i) { | 119 i != it->path.end(); ++i) { |
120 const BookmarkNode* child = NULL; | 120 const BookmarkNode* child = NULL; |
121 const std::wstring& folder_name = (!import_to_bookmark_bar && | 121 const std::wstring& folder_name = (!import_to_bookmark_bar && |
122 !it->in_toolbar && (i == it->path.begin())) ? real_first_folder : *i; | 122 !it->in_toolbar && (i == it->path.begin())) ? real_first_folder : *i; |
123 | 123 |
124 for (int index = 0; index < parent->GetChildCount(); ++index) { | 124 for (int index = 0; index < parent->GetChildCount(); ++index) { |
125 const BookmarkNode* node = parent->GetChild(index); | 125 const BookmarkNode* node = parent->GetChild(index); |
126 if ((node->GetType() == history::StarredEntry::BOOKMARK_BAR || | 126 if ((node->GetType() == BookmarkNode::BOOKMARK_BAR || |
127 node->GetType() == history::StarredEntry::USER_GROUP) && | 127 node->GetType() == BookmarkNode::FOLDER) && |
128 node->GetTitle() == folder_name) { | 128 node->GetTitle() == folder_name) { |
129 child = node; | 129 child = node; |
130 break; | 130 break; |
131 } | 131 } |
132 } | 132 } |
133 if (child == NULL) | 133 if (child == NULL) |
134 child = model->AddGroup(parent, parent->GetChildCount(), folder_name); | 134 child = model->AddGroup(parent, parent->GetChildCount(), folder_name); |
135 parent = child; | 135 parent = child; |
136 } | 136 } |
137 groups_added_to.insert(parent); | 137 groups_added_to.insert(parent); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 NotificationService::NoDetails()); | 294 NotificationService::NoDetails()); |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 std::wstring ProfileWriter::GenerateUniqueFolderName( | 298 std::wstring ProfileWriter::GenerateUniqueFolderName( |
299 BookmarkModel* model, | 299 BookmarkModel* model, |
300 const std::wstring& folder_name) { | 300 const std::wstring& folder_name) { |
301 // Build a set containing the folder names of the other folder. | 301 // Build a set containing the folder names of the other folder. |
302 std::set<std::wstring> other_folder_names; | 302 std::set<std::wstring> other_folder_names; |
303 const BookmarkNode* other = model->other_node(); | 303 const BookmarkNode* other = model->other_node(); |
304 for (int i = 0; i < other->GetChildCount(); ++i) { | 304 |
| 305 for (int i = 0, child_count = other->GetChildCount(); i < child_count; ++i) { |
305 const BookmarkNode* node = other->GetChild(i); | 306 const BookmarkNode* node = other->GetChild(i); |
306 if (node->is_folder()) | 307 if (node->is_folder()) |
307 other_folder_names.insert(node->GetTitle()); | 308 other_folder_names.insert(node->GetTitle()); |
308 } | 309 } |
309 | 310 |
310 if (other_folder_names.find(folder_name) == other_folder_names.end()) | 311 if (other_folder_names.find(folder_name) == other_folder_names.end()) |
311 return folder_name; // Name is unique, use it. | 312 return folder_name; // Name is unique, use it. |
312 | 313 |
313 // Otherwise iterate until we find a unique name. | 314 // Otherwise iterate until we find a unique name. |
314 for (int i = 1; i < 100; ++i) { | 315 for (int i = 1; i < 100; ++i) { |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 ProfileInfo* google_toolbar = new ProfileInfo(); | 767 ProfileInfo* google_toolbar = new ProfileInfo(); |
767 google_toolbar->browser_type = GOOGLE_TOOLBAR5; | 768 google_toolbar->browser_type = GOOGLE_TOOLBAR5; |
768 google_toolbar->description = l10n_util::GetString( | 769 google_toolbar->description = l10n_util::GetString( |
769 IDS_IMPORT_FROM_GOOGLE_TOOLBAR); | 770 IDS_IMPORT_FROM_GOOGLE_TOOLBAR); |
770 google_toolbar->source_path.clear(); | 771 google_toolbar->source_path.clear(); |
771 google_toolbar->app_path.clear(); | 772 google_toolbar->app_path.clear(); |
772 google_toolbar->services_supported = FAVORITES; | 773 google_toolbar->services_supported = FAVORITES; |
773 source_profiles_.push_back(google_toolbar); | 774 source_profiles_.push_back(google_toolbar); |
774 } | 775 } |
775 } | 776 } |
OLD | NEW |