diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 22:29:20 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 22:29:20 +0000 |
commit | b3c33d463366d2725ec4d669b98dc468a751c541 (patch) | |
tree | d8496a8ae8fc73ed71b93d67c055e9f1bba4fcc7 /chrome/browser/importer | |
parent | 7b91dfd0bce7b4f864d9654e8bd0a9f93683cec0 (diff) | |
download | chromium_src-b3c33d463366d2725ec4d669b98dc468a751c541.zip chromium_src-b3c33d463366d2725ec4d669b98dc468a751c541.tar.gz chromium_src-b3c33d463366d2725ec4d669b98dc468a751c541.tar.bz2 |
Make bookmark model public interface use const BookmarkNode* instead of
BookmarkNode*. This helps in making the BookmarkNode class setters public
also without worrying about someone inadvertently changing BookmarkNode
properties directly for bookmark model bookmarks.
Change all the call sites to reflect this.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/146116
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r-- | chrome/browser/importer/importer.cc | 23 | ||||
-rw-r--r-- | chrome/browser/importer/importer.h | 14 |
2 files changed, 19 insertions, 18 deletions
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 74d2694..5af5572 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -95,7 +95,7 @@ void ProfileWriter::AddBookmarkEntry( GenerateUniqueFolderName(model, first_folder_name); bool show_bookmark_toolbar = false; - std::set<BookmarkNode*> groups_added_to; + std::set<const BookmarkNode*> groups_added_to; for (std::vector<BookmarkEntry>::const_iterator it = bookmark.begin(); it != bookmark.end(); ++it) { // Don't insert this url if it isn't valid. @@ -113,16 +113,16 @@ void ProfileWriter::AddBookmarkEntry( // the subgroup of path[i-1]. Finally they construct a path in the // model: // path[0] \ path[1] \ ... \ path[size() - 1] - BookmarkNode* parent = + const BookmarkNode* parent = (it->in_toolbar ? model->GetBookmarkBarNode() : model->other_node()); for (std::vector<std::wstring>::const_iterator i = it->path.begin(); i != it->path.end(); ++i) { - BookmarkNode* child = NULL; - const std::wstring& folder_name = (!import_to_bookmark_bar && + const BookmarkNode* child = NULL; + const std::wstring& folder_name = (!import_to_bookmark_bar && !it->in_toolbar && (i == it->path.begin())) ? real_first_folder : *i; for (int index = 0; index < parent->GetChildCount(); ++index) { - BookmarkNode* node = parent->GetChild(index); + const BookmarkNode* node = parent->GetChild(index); if ((node->GetType() == history::StarredEntry::BOOKMARK_BAR || node->GetType() == history::StarredEntry::USER_GROUP) && node->GetTitle() == folder_name) { @@ -147,7 +147,8 @@ void ProfileWriter::AddBookmarkEntry( // Reset the date modified time of the groups we added to. We do this to // make sure the 'recently added to' combobox in the bubble doesn't get random // groups. - for (std::set<BookmarkNode*>::const_iterator i = groups_added_to.begin(); + for (std::set<const BookmarkNode*>::const_iterator i = + groups_added_to.begin(); i != groups_added_to.end(); ++i) { model->ResetDateGroupModified(*i); } @@ -299,9 +300,9 @@ std::wstring ProfileWriter::GenerateUniqueFolderName( const std::wstring& folder_name) { // Build a set containing the folder names of the other folder. std::set<std::wstring> other_folder_names; - BookmarkNode* other = model->other_node(); + const BookmarkNode* other = model->other_node(); for (int i = 0; i < other->GetChildCount(); ++i) { - BookmarkNode* node = other->GetChild(i); + const BookmarkNode* node = other->GetChild(i); if (node->is_folder()) other_folder_names.insert(node->GetTitle()); } @@ -324,19 +325,19 @@ bool ProfileWriter::DoesBookmarkExist( const BookmarkEntry& entry, const std::wstring& first_folder_name, bool import_to_bookmark_bar) { - std::vector<BookmarkNode*> nodes_with_same_url; + std::vector<const BookmarkNode*> nodes_with_same_url; model->GetNodesByURL(entry.url, &nodes_with_same_url); if (nodes_with_same_url.empty()) return false; for (size_t i = 0; i < nodes_with_same_url.size(); ++i) { - BookmarkNode* node = nodes_with_same_url[i]; + const BookmarkNode* node = nodes_with_same_url[i]; if (entry.title != node->GetTitle()) continue; // Does the path match? bool found_match = true; - BookmarkNode* parent = node->GetParent(); + const BookmarkNode* parent = node->GetParent(); for (std::vector<std::wstring>::const_reverse_iterator path_it = entry.path.rbegin(); (path_it != entry.path.rend()) && found_match; ++path_it) { diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index 93ed19b..41ef11b 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -172,22 +172,22 @@ class ImporterHost : public base::RefCounted<ImporterHost>, // BookmarkModelObserver methods. virtual void Loaded(BookmarkModel* model); virtual void BookmarkNodeMoved(BookmarkModel* model, - BookmarkNode* old_parent, + const BookmarkNode* old_parent, int old_index, - BookmarkNode* new_parent, + const BookmarkNode* new_parent, int new_index) {} virtual void BookmarkNodeAdded(BookmarkModel* model, - BookmarkNode* parent, + const BookmarkNode* parent, int index) {} virtual void BookmarkNodeRemoved(BookmarkModel* model, - BookmarkNode* parent, + const BookmarkNode* parent, int index) {} virtual void BookmarkNodeChanged(BookmarkModel* model, - BookmarkNode* node) {} + const BookmarkNode* node) {} virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, - BookmarkNode* node) {} + const BookmarkNode* node) {} virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, - BookmarkNode* node) {} + const BookmarkNode* node) {} // NotificationObserver method. Called when TemplateURLModel has been loaded. void Observe(NotificationType type, |