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

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

Issue 7003039: ui/base/models: Add empty() accessor to TreeNode class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 (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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const string16& top_level_folder_name) { 115 const string16& top_level_folder_name) {
116 if (bookmarks.empty()) 116 if (bookmarks.empty())
117 return; 117 return;
118 118
119 BookmarkModel* model = profile_->GetBookmarkModel(); 119 BookmarkModel* model = profile_->GetBookmarkModel();
120 DCHECK(model->IsLoaded()); 120 DCHECK(model->IsLoaded());
121 121
122 // If the bookmark bar is currently empty, we should import directly to it. 122 // If the bookmark bar is currently empty, we should import directly to it.
123 // Otherwise, we should import everything to a subfolder. 123 // Otherwise, we should import everything to a subfolder.
124 const BookmarkNode* bookmark_bar = model->GetBookmarkBarNode(); 124 const BookmarkNode* bookmark_bar = model->GetBookmarkBarNode();
125 bool import_to_top_level = bookmark_bar->child_count() == 0; 125 bool import_to_top_level = bookmark_bar->empty();
126 126
127 // If the user currently has no bookmarks in the bookmark bar, make sure that 127 // If the user currently has no bookmarks in the bookmark bar, make sure that
128 // at least some of the imported bookmarks end up there. Otherwise, we'll end 128 // at least some of the imported bookmarks end up there. Otherwise, we'll end
129 // up with just a single folder containing the imported bookmarks, which makes 129 // up with just a single folder containing the imported bookmarks, which makes
130 // for unnecessary nesting. 130 // for unnecessary nesting.
131 bool add_all_to_top_level = import_to_top_level; 131 bool add_all_to_top_level = import_to_top_level;
132 for (std::vector<BookmarkEntry>::const_iterator it = bookmarks.begin(); 132 for (std::vector<BookmarkEntry>::const_iterator it = bookmarks.begin();
133 it != bookmarks.end() && add_all_to_top_level; ++it) { 133 it != bookmarks.end() && add_all_to_top_level; ++it) {
134 if (it->in_toolbar) 134 if (it->in_toolbar)
135 add_all_to_top_level = false; 135 add_all_to_top_level = false;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) 328 if (default_keyword && TemplateURL::SupportsReplacement(t_url))
329 model->SetDefaultSearchProvider(t_url); 329 model->SetDefaultSearchProvider(t_url);
330 } else { 330 } else {
331 // Don't add invalid TemplateURLs to the model. 331 // Don't add invalid TemplateURLs to the model.
332 delete t_url; 332 delete t_url;
333 } 333 }
334 } 334 }
335 } 335 }
336 336
337 ProfileWriter::~ProfileWriter() {} 337 ProfileWriter::~ProfileWriter() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698