summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-11 15:22:32 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-11 15:22:32 +0000
commitd8e41ed4a55e60be60d47de5bbcb8a027e85a879 (patch)
treee0feaa030fe3834c0fc871de7564ef74e9595b05 /chrome/browser/views
parent7903e0262e2dda44eaa186d126cf88e2cc1470eb (diff)
downloadchromium_src-d8e41ed4a55e60be60d47de5bbcb8a027e85a879.zip
chromium_src-d8e41ed4a55e60be60d47de5bbcb8a027e85a879.tar.gz
chromium_src-d8e41ed4a55e60be60d47de5bbcb8a027e85a879.tar.bz2
Renames BoomarkBarModel to BookmarkModel.
BUG=none TEST=none Review URL: http://codereview.chromium.org/1912 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc150
-rw-r--r--chrome/browser/views/bookmark_bar_view.h76
-rw-r--r--chrome/browser/views/bookmark_bar_view_test.cc17
-rw-r--r--chrome/browser/views/bookmark_bubble_view.cc30
-rw-r--r--chrome/browser/views/bookmark_bubble_view.h12
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc86
-rw-r--r--chrome/browser/views/bookmark_editor_view.h82
-rw-r--r--chrome/browser/views/bookmark_editor_view_unittest.cc50
-rw-r--r--chrome/browser/views/toolbar_star_toggle.cc2
9 files changed, 245 insertions, 260 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index d7fbabf..9c26e82 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -193,7 +193,7 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
}
// Returns the drag operations for the specified node.
-static int GetDragOperationsForNode(BookmarkBarNode* node) {
+static int GetDragOperationsForNode(BookmarkNode* node) {
if (node->GetType() == history::StarredEntry::URL) {
return DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_MOVE |
DragDropTypes::DRAG_LINK;
@@ -316,9 +316,7 @@ class MenuRunner : public ChromeViews::MenuDelegate,
public:
// start_child_index is the index of the first child in node to add to the
// menu.
- MenuRunner(BookmarkBarView* view,
- BookmarkBarNode* node,
- int start_child_index)
+ MenuRunner(BookmarkBarView* view, BookmarkNode* node, int start_child_index)
: view_(view),
node_(node),
menu_(this) {
@@ -328,7 +326,7 @@ class MenuRunner : public ChromeViews::MenuDelegate,
}
// Returns the node the menu is being run for.
- BookmarkBarNode* GetNode() {
+ BookmarkNode* GetNode() {
return node_;
}
@@ -346,7 +344,7 @@ class MenuRunner : public ChromeViews::MenuDelegate,
// Notification that the favicon has finished loading. Reset the icon
// of the menu item.
- void FavIconLoaded(BookmarkBarNode* node) {
+ void FavIconLoaded(BookmarkNode* node) {
if (node_to_menu_id_map_.find(node) !=
node_to_menu_id_map_.end()) {
menu_.SetIcon(node->GetFavIcon(), node_to_menu_id_map_[node]);
@@ -368,14 +366,14 @@ class MenuRunner : public ChromeViews::MenuDelegate,
private:
// Creates an entry in menu for each child node of parent starting at
// start_child_index, recursively invoking this for any star groups.
- void BuildMenu(BookmarkBarNode* parent,
+ void BuildMenu(BookmarkNode* parent,
int start_child_index,
MenuItemView* menu,
int* next_menu_id) {
DCHECK(!parent->GetChildCount() ||
start_child_index < parent->GetChildCount());
for (int i = start_child_index; i < parent->GetChildCount(); ++i) {
- BookmarkBarNode* node = parent->GetChild(i);
+ BookmarkNode* node = parent->GetChild(i);
int id = *next_menu_id;
(*next_menu_id)++;
@@ -428,17 +426,17 @@ class MenuRunner : public ChromeViews::MenuDelegate,
}
// Drag originated from same profile and is not a URL. Only accept it if
// the dragged node is not a parent of the node menu represents.
- BookmarkBarNode* drop_node = menu_id_to_node_map_[menu->GetCommand()];
+ BookmarkNode* drop_node = menu_id_to_node_map_[menu->GetCommand()];
DCHECK(drop_node);
- BookmarkBarNode* drag_node = drop_data_.GetNode(view_->GetProfile()->
- GetBookmarkBarModel());
+ BookmarkNode* drag_node =
+ drop_data_.GetNode(view_->GetProfile()->GetBookmarkModel());
if (!drag_node) {
// Hmmm, can't find the dragged node. This is generally an error
// condition and we won't try and do anything fancy.
NOTREACHED();
return false;
}
- BookmarkBarNode* node = drop_node;
+ BookmarkNode* node = drop_node;
while (drop_node && drop_node != drag_node)
drop_node = drop_node->GetParent();
return (drop_node == NULL);
@@ -448,8 +446,8 @@ class MenuRunner : public ChromeViews::MenuDelegate,
const ChromeViews::DropTargetEvent& event,
DropPosition* position) {
DCHECK(drop_data_.is_valid);
- BookmarkBarNode* node = menu_id_to_node_map_[item->GetCommand()];
- BookmarkBarNode* drop_parent = node->GetParent();
+ BookmarkNode* node = menu_id_to_node_map_[item->GetCommand()];
+ BookmarkNode* drop_parent = node->GetParent();
int index_to_drop_at = drop_parent->IndexOfChild(node);
if (*position == DROP_AFTER) {
index_to_drop_at++;
@@ -465,11 +463,11 @@ class MenuRunner : public ChromeViews::MenuDelegate,
virtual int OnPerformDrop(MenuItemView* menu,
DropPosition position,
const DropTargetEvent& event) {
- BookmarkBarNode* drop_node = menu_id_to_node_map_[menu->GetCommand()];
+ BookmarkNode* drop_node = menu_id_to_node_map_[menu->GetCommand()];
DCHECK(drop_node);
- BookmarkBarModel* model = view_->GetModel();
+ BookmarkModel* model = view_->GetModel();
DCHECK(model);
- BookmarkBarNode* drop_parent = drop_node->GetParent();
+ BookmarkNode* drop_parent = drop_node->GetParent();
DCHECK(drop_parent);
int index_to_drop_at = drop_parent->IndexOfChild(drop_node);
if (position == DROP_AFTER) {
@@ -526,7 +524,7 @@ class MenuRunner : public ChromeViews::MenuDelegate,
}
// The node we're showing the contents of.
- BookmarkBarNode* node_;
+ BookmarkNode* node_;
// The view that created us.
BookmarkBarView* view_;
@@ -534,12 +532,12 @@ class MenuRunner : public ChromeViews::MenuDelegate,
// The menu.
MenuItemView menu_;
- // Mapping from menu id to the BookmarkBarNode.
- std::map<int, BookmarkBarNode*> menu_id_to_node_map_;
+ // Mapping from menu id to the BookmarkNode.
+ std::map<int, BookmarkNode*> menu_id_to_node_map_;
// Mapping from node to menu id. This only contains entries for nodes of type
// URL.
- std::map<BookmarkBarNode*, int> node_to_menu_id_map_;
+ std::map<BookmarkNode*, int> node_to_menu_id_map_;
// Data for the drop.
BookmarkDragData drop_data_;
@@ -678,12 +676,12 @@ void BookmarkBarView::SetProfile(Profile* profile) {
ns->AddObserver(this, NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
NotificationService::AllSources());
- model_ = profile_->GetBookmarkBarModel();
+ model_ = profile_->GetBookmarkModel();
model_->AddObserver(this);
if (model_->IsLoaded())
Loaded(model_);
- // else case: we'll receive notification back from the BookmarkBarModel when
- // done loading, then we'll populate the bar.
+ // else case: we'll receive notification back from the BookmarkModel when done
+ // loading, then we'll populate the bar.
}
void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) {
@@ -973,7 +971,7 @@ int BookmarkBarView::OnDragUpdated(const DropTargetEvent& event) {
}
if (drop_on || is_over_overflow || is_over_other) {
- BookmarkBarNode* node;
+ BookmarkNode* node;
if (is_over_other)
node = model_->other_node();
else if (is_over_overflow)
@@ -1009,9 +1007,8 @@ int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) {
if (!drop_info_.get() || !drop_info_->drag_operation)
return DragDropTypes::DRAG_NONE;
- BookmarkBarNode* root =
- drop_info_->is_over_other ? model_->other_node() :
- model_->GetBookmarkBarNode();
+ BookmarkNode* root = drop_info_->is_over_other ? model_->other_node() :
+ model_->GetBookmarkBarNode();
int index = drop_info_->drop_index;
const bool drop_on = drop_info_->drop_on;
const BookmarkDragData data = drop_info_->data;
@@ -1024,7 +1021,7 @@ int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) {
}
drop_info_.reset();
- BookmarkBarNode* parent_node;
+ BookmarkNode* parent_node;
if (is_over_other) {
parent_node = root;
index = parent_node->GetChildCount();
@@ -1155,8 +1152,8 @@ int BookmarkBarView::GetBookmarkButtonCount() {
return GetChildViewCount() - 4;
}
-void BookmarkBarView::Loaded(BookmarkBarModel* model) {
- BookmarkBarNode* node = model_->GetBookmarkBarNode();
+void BookmarkBarView::Loaded(BookmarkModel* model) {
+ BookmarkNode* node = model_->GetBookmarkBarNode();
DCHECK(node && model_->other_node());
// Create a button for each of the children on the bookmark bar.
for (int i = 0; i < node->GetChildCount(); ++i)
@@ -1166,7 +1163,7 @@ void BookmarkBarView::Loaded(BookmarkBarModel* model) {
SchedulePaint();
}
-void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkBarModel* model) {
+void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) {
// The bookmark model should never be deleted before us. This code exists
// to check for regressions in shutdown code and not crash.
NOTREACHED();
@@ -1177,10 +1174,10 @@ void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkBarModel* model) {
model_ = NULL;
}
-void BookmarkBarView::BookmarkNodeMoved(BookmarkBarModel* model,
- BookmarkBarNode* old_parent,
+void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
int old_index,
- BookmarkBarNode* new_parent,
+ BookmarkNode* new_parent,
int new_index) {
StopThrobbing(true);
BookmarkNodeRemovedImpl(model, old_parent, old_index);
@@ -1188,16 +1185,16 @@ void BookmarkBarView::BookmarkNodeMoved(BookmarkBarModel* model,
StartThrobbing();
}
-void BookmarkBarView::BookmarkNodeAdded(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+void BookmarkBarView::BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
int index) {
StopThrobbing(true);
BookmarkNodeAddedImpl(model, parent, index);
StartThrobbing();
}
-void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model,
+ BookmarkNode* parent,
int index) {
NotifyModelChanged();
if (parent != model_->GetBookmarkBarNode()) {
@@ -1210,16 +1207,16 @@ void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkBarModel* model,
SchedulePaint();
}
-void BookmarkBarView::BookmarkNodeRemoved(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+void BookmarkBarView::BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
int index) {
StopThrobbing(true);
BookmarkNodeRemovedImpl(model, parent, index);
StartThrobbing();
}
-void BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+void BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkModel* model,
+ BookmarkNode* parent,
int index) {
NotifyModelChanged();
if (parent != model_->GetBookmarkBarNode()) {
@@ -1234,14 +1231,14 @@ void BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkBarModel* model,
SchedulePaint();
}
-void BookmarkBarView::BookmarkNodeChanged(BookmarkBarModel* model,
- BookmarkBarNode* node) {
+void BookmarkBarView::BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node) {
NotifyModelChanged();
BookmarkNodeChangedImpl(model, node);
}
-void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkBarModel* model,
- BookmarkBarNode* node) {
+void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkModel* model,
+ BookmarkNode* node) {
if (node->GetParent() != model_->GetBookmarkBarNode()) {
// We only care about nodes on the bookmark bar.
return;
@@ -1262,8 +1259,8 @@ void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkBarModel* model,
}
}
-void BookmarkBarView::BookmarkNodeFavIconLoaded(BookmarkBarModel* model,
- BookmarkBarNode* node) {
+void BookmarkBarView::BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node) {
if (menu_runner_.get())
menu_runner_->FavIconLoaded(node);
if (drop_menu_runner_.get())
@@ -1292,7 +1289,7 @@ void BookmarkBarView::WriteDragData(View* sender,
NOTREACHED();
}
-void BookmarkBarView::WriteDragData(BookmarkBarNode* node,
+void BookmarkBarView::WriteDragData(BookmarkNode* node,
OSExchangeData* data) {
DCHECK(node && data);
BookmarkDragData drag_data(node);
@@ -1314,7 +1311,7 @@ int BookmarkBarView::GetDragOperations(View* sender, int x, int y) {
void BookmarkBarView::RunMenu(ChromeViews::View* view,
const CPoint& pt,
HWND hwnd) {
- BookmarkBarNode* node;
+ BookmarkNode* node;
MenuItemView::AnchorPosition anchor_point = MenuItemView::TOPLEFT;
// When we set the menu's position, we must take into account the mirrored
@@ -1369,7 +1366,7 @@ void BookmarkBarView::RunMenu(ChromeViews::View* view,
void BookmarkBarView::ButtonPressed(ChromeViews::BaseButton* sender) {
int index = GetChildIndex(sender);
DCHECK(index != -1);
- BookmarkBarNode* node = model_->GetBookmarkBarNode()->GetChild(index);
+ BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(index);
DCHECK(page_navigator_);
page_navigator_->OpenURL(
node->GetURL(),
@@ -1387,7 +1384,7 @@ void BookmarkBarView::ShowContextMenu(View* source,
return;
}
- BookmarkBarNode* node = model_->GetBookmarkBarNode();
+ BookmarkNode* node = model_->GetBookmarkBarNode();
if (source == other_bookmarked_button_) {
node = model_->other_node();
} else if (source != this) {
@@ -1402,8 +1399,7 @@ void BookmarkBarView::ShowContextMenu(View* source,
controller.RunMenuAt(x, y);
}
-ChromeViews::View* BookmarkBarView::CreateBookmarkButton(
- BookmarkBarNode* node) {
+ChromeViews::View* BookmarkBarView::CreateBookmarkButton(BookmarkNode* node) {
if (node->GetType() == history::StarredEntry::URL) {
BookmarkButton* button = new BookmarkButton(node->GetURL(),
node->GetTitle(),
@@ -1420,7 +1416,7 @@ ChromeViews::View* BookmarkBarView::CreateBookmarkButton(
}
}
-void BookmarkBarView::ConfigureButton(BookmarkBarNode* node,
+void BookmarkBarView::ConfigureButton(BookmarkNode* node,
ChromeViews::TextButton* button) {
button->SetText(node->GetTitle());
button->ClearMaxTextSize();
@@ -1484,7 +1480,7 @@ void BookmarkBarView::NotifyModelChanged() {
model_changed_listener_->ModelChanged();
}
-void BookmarkBarView::ShowDropFolderForNode(BookmarkBarNode* node) {
+void BookmarkBarView::ShowDropFolderForNode(BookmarkNode* node) {
if (drop_menu_runner_.get() && drop_menu_runner_->GetNode() == node) {
// Already showing for the specified node.
return;
@@ -1542,7 +1538,7 @@ void BookmarkBarView::StopShowFolderDropMenuTimer() {
show_folder_drop_menu_task_->Cancel();
}
-void BookmarkBarView::StartShowFolderDropMenuTimer(BookmarkBarNode* node) {
+void BookmarkBarView::StartShowFolderDropMenuTimer(BookmarkNode* node) {
if (testing_) {
// So that tests can run as fast as possible disable the delay during
// testing.
@@ -1608,7 +1604,7 @@ int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event,
int button_w = button->GetWidth();
if (button_x < button_w) {
found = true;
- BookmarkBarNode* node = model_->GetBookmarkBarNode()->GetChild(i);
+ BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(i);
if (node->GetType() != history::StarredEntry::URL) {
if (button_x <= MenuItemView::kDropBetweenPixels) {
*index = i;
@@ -1653,7 +1649,7 @@ int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event,
}
if (*drop_on) {
- BookmarkBarNode* parent =
+ BookmarkNode* parent =
*is_over_other ? model_->other_node() :
model_->GetBookmarkBarNode()->GetChild(*index);
int operation =
@@ -1673,14 +1669,14 @@ int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event,
}
int BookmarkBarView::CalculateDropOperation(const BookmarkDragData& data,
- BookmarkBarNode* parent,
+ BookmarkNode* parent,
int index) {
if (!CanDropAt(data, parent, index))
return DragDropTypes::DRAG_NONE;
if (data.is_url) {
// User is dragging a URL.
- BookmarkBarNode* node = model_->GetNodeByURL(data.url);
+ BookmarkNode* node = model_->GetNodeByURL(data.url);
if (!node) {
// We don't have a node with this url.
return DragDropTypes::DRAG_COPY;
@@ -1690,7 +1686,7 @@ int BookmarkBarView::CalculateDropOperation(const BookmarkDragData& data,
return DragDropTypes::DRAG_MOVE | DragDropTypes::DRAG_COPY;
} else if (data.profile_id == GetProfile()->GetID()) {
// Dropping a group from the same profile results in a move.
- BookmarkBarNode* node = data.GetNode(model_);
+ BookmarkNode* node = data.GetNode(model_);
if (!node) {
// Generally shouldn't get here, we originated the drag but couldn't
// find the node.
@@ -1704,11 +1700,11 @@ int BookmarkBarView::CalculateDropOperation(const BookmarkDragData& data,
}
bool BookmarkBarView::CanDropAt(const BookmarkDragData& data,
- BookmarkBarNode* parent,
+ BookmarkNode* parent,
int index) {
DCHECK(data.is_valid);
if (data.is_url) {
- BookmarkBarNode* existing_node = model_->GetNodeByURL(data.url);
+ BookmarkNode* existing_node = model_->GetNodeByURL(data.url);
if (existing_node && existing_node->GetParent() == parent) {
const int existing_index = parent->IndexOfChild(existing_node);
if (index == existing_index || existing_index + 1 == index)
@@ -1716,7 +1712,7 @@ bool BookmarkBarView::CanDropAt(const BookmarkDragData& data,
}
return true;
} else if (data.profile_id == profile_->GetID()) {
- BookmarkBarNode* existing_node = data.GetNode(model_);
+ BookmarkNode* existing_node = data.GetNode(model_);
if (existing_node) {
if (existing_node->GetParent() == parent) {
const int existing_index = parent->IndexOfChild(existing_node);
@@ -1725,7 +1721,7 @@ bool BookmarkBarView::CanDropAt(const BookmarkDragData& data,
}
// Allow the drop only if the node we're going to drop on isn't a
// descendant of the dragged node.
- BookmarkBarNode* test_node = parent;
+ BookmarkNode* test_node = parent;
while (test_node && test_node != existing_node)
test_node = test_node->GetParent();
return (test_node == NULL);
@@ -1736,11 +1732,11 @@ bool BookmarkBarView::CanDropAt(const BookmarkDragData& data,
int BookmarkBarView::PerformDropImpl(const BookmarkDragData& data,
- BookmarkBarNode* parent_node,
+ BookmarkNode* parent_node,
int index) {
if (data.is_url) {
// User is dragging a URL.
- BookmarkBarNode* node = model_->GetNodeByURL(data.url);
+ BookmarkNode* node = model_->GetNodeByURL(data.url);
if (!node) {
std::wstring title = data.title;
if (title.empty()) {
@@ -1755,7 +1751,7 @@ int BookmarkBarView::PerformDropImpl(const BookmarkDragData& data,
model_->Move(node, parent_node, index);
return DragDropTypes::DRAG_MOVE;
} else if (data.profile_id == GetProfile()->GetID()) {
- BookmarkBarNode* node = data.GetNode(model_);
+ BookmarkNode* node = data.GetNode(model_);
if (!node) {
// Generally shouldn't get here, we originated the drag but couldn't
// find the node. Do nothing.
@@ -1771,19 +1767,19 @@ int BookmarkBarView::PerformDropImpl(const BookmarkDragData& data,
}
void BookmarkBarView::CloneDragData(const BookmarkDragData& data,
- BookmarkBarNode* parent,
+ BookmarkNode* parent,
int index_to_add_at) {
DCHECK(data.is_valid && model_);
if (data.is_url) {
- BookmarkBarNode* node = model_->GetNodeByURL(data.url);
+ BookmarkNode* node = model_->GetNodeByURL(data.url);
if (node) {
model_->Move(node, parent, index_to_add_at);
} else {
model_->AddURL(parent, index_to_add_at, data.title, data.url);
}
} else {
- BookmarkBarNode* new_folder = model_->AddGroup(parent, index_to_add_at,
- data.title);
+ BookmarkNode* new_folder = model_->AddGroup(parent, index_to_add_at,
+ data.title);
for (int i = 0; i < static_cast<int>(data.children.size()); ++i)
CloneDragData(data.children[i], new_folder, i);
}
@@ -1807,15 +1803,15 @@ void BookmarkBarView::StartThrobbing() {
if (!GetViewContainer())
return; // We're not showing, don't do anything.
- BookmarkBarNode* node = model_->GetNodeByURL(bubble_url_);
+ BookmarkNode* node = model_->GetNodeByURL(bubble_url_);
if (!node)
return; // Generally shouldn't happen.
// Determine which visible button is showing the url (or is an ancestor of
// the url).
if (node->HasAncestor(model_->GetBookmarkBarNode())) {
- BookmarkBarNode* bbn = model_->GetBookmarkBarNode();
- BookmarkBarNode* parent_on_bb = node;
+ BookmarkNode* bbn = model_->GetBookmarkBarNode();
+ BookmarkNode* parent_on_bb = node;
while (parent_on_bb->GetParent() != bbn)
parent_on_bb = parent_on_bb->GetParent();
int index = bbn->IndexOfChild(parent_on_bb);
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index 63dcacb..552dbaf 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -5,8 +5,8 @@
#ifndef CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_
#define CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_
-#include "chrome/browser/bookmarks/bookmark_bar_model.h"
#include "chrome/browser/bookmarks/bookmark_drag_data.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/common/slide_animation.h"
#include "chrome/views/label.h"
#include "chrome/views/menu.h"
@@ -28,16 +28,15 @@ namespace ChromeViews {
class MenuItemView;
}
-// BookmarkBarView renders the BookmarkBarModel. Each starred entry
-// on the BookmarkBar is rendered as a MenuButton. An additional
-// MenuButton aligned to the right allows the user to quickly see
-// recently starred entries.
+// BookmarkBarView renders the BookmarkModel. Each starred entry on the
+// BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to
+// the right allows the user to quickly see recently starred entries.
//
// BookmarkBarView shows the bookmarks from a specific Profile. BookmarkBarView
// waits until the HistoryService for the profile has been loaded before
-// creating the BookmarkBarModel.
+// creating the BookmarkModel.
class BookmarkBarView : public ChromeViews::View,
- public BookmarkBarModelObserver,
+ public BookmarkModelObserver,
public ChromeViews::ViewMenuDelegate,
public ChromeViews::BaseButton::ButtonListener,
public Menu::Delegate,
@@ -120,7 +119,7 @@ class BookmarkBarView : public ChromeViews::View,
PageNavigator* GetPageNavigator() { return page_navigator_; }
// Returns the model.
- BookmarkBarModel* GetModel() { return model_; }
+ BookmarkModel* GetModel() { return model_; }
// Toggles whether the bookmark bar is shown only on the new tab page or on
// all tabs.
@@ -174,8 +173,7 @@ class BookmarkBarView : public ChromeViews::View,
// deletes itself once run.
class ShowFolderDropMenuTask : public Task {
public:
- ShowFolderDropMenuTask(BookmarkBarView* view,
- BookmarkBarNode* node)
+ ShowFolderDropMenuTask(BookmarkBarView* view, BookmarkNode* node)
: view_(view),
node_(node) {
}
@@ -195,7 +193,7 @@ class BookmarkBarView : public ChromeViews::View,
private:
BookmarkBarView* view_;
- BookmarkBarNode* node_;
+ BookmarkNode* node_;
DISALLOW_COPY_AND_ASSIGN(ShowFolderDropMenuTask);
};
@@ -217,55 +215,55 @@ class BookmarkBarView : public ChromeViews::View,
// Invoked when the bookmark bar model has finished loading. Creates a button
// for each of the children of the root node from the model.
- virtual void Loaded(BookmarkBarModel* model);
+ virtual void Loaded(BookmarkModel* model);
// Invoked when the model is being deleted.
- virtual void BookmarkModelBeingDeleted(BookmarkBarModel* model);
+ virtual void BookmarkModelBeingDeleted(BookmarkModel* model);
// Invokes added followed by removed.
- virtual void BookmarkNodeMoved(BookmarkBarModel* model,
- BookmarkBarNode* old_parent,
+ virtual void BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
int old_index,
- BookmarkBarNode* new_parent,
+ BookmarkNode* new_parent,
int new_index);
// Notifies ModelChangeListener of change.
// If the node was added to the root node, a button is created and added to
// this bookmark bar view.
- virtual void BookmarkNodeAdded(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+ virtual void BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
int index);
// Implementation for BookmarkNodeAddedImpl.
- void BookmarkNodeAddedImpl(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+ void BookmarkNodeAddedImpl(BookmarkModel* model,
+ BookmarkNode* parent,
int index);
// Notifies ModelChangeListener of change.
// If the node was a child of the root node, the button corresponding to it
// is removed.
- virtual void BookmarkNodeRemoved(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+ virtual void BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
int index);
// Implementation for BookmarkNodeRemoved.
- void BookmarkNodeRemovedImpl(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+ void BookmarkNodeRemovedImpl(BookmarkModel* model,
+ BookmarkNode* parent,
int index);
// Notifies ModelChangedListener and invokes BookmarkNodeChangedImpl.
- virtual void BookmarkNodeChanged(BookmarkBarModel* model,
- BookmarkBarNode* node);
+ virtual void BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node);
// If the node is a child of the root node, the button is updated
// appropriately.
- void BookmarkNodeChangedImpl(BookmarkBarModel* model, BookmarkBarNode* node);
+ void BookmarkNodeChangedImpl(BookmarkModel* model, BookmarkNode* node);
// Invoked when the favicon is available. If the node is a child of the
// root node, the appropriate button is updated. If a menu is showing, the
// call is forwarded to the menu to allow for it to update the icon.
- virtual void BookmarkNodeFavIconLoaded(BookmarkBarModel* model,
- BookmarkBarNode* node);
+ virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node);
// DragController method. Determines the node representing sender and invokes
// WriteDragData to write the actual data.
@@ -275,7 +273,7 @@ class BookmarkBarView : public ChromeViews::View,
OSExchangeData* data);
// Writes a BookmarkDragData for node to data.
- void WriteDragData(BookmarkBarNode* node, OSExchangeData* data);
+ void WriteDragData(BookmarkNode* node, OSExchangeData* data);
// Returns the drag operations for the specified button.
virtual int GetDragOperations(ChromeViews::View* sender, int x, int y);
@@ -300,11 +298,11 @@ class BookmarkBarView : public ChromeViews::View,
bool is_mouse_gesture);
// Creates the button for rendering the specified bookmark node.
- ChromeViews::View* CreateBookmarkButton(BookmarkBarNode* node);
+ ChromeViews::View* CreateBookmarkButton(BookmarkNode* node);
// COnfigures the button from the specified node. This sets the text,
// and icon.
- void ConfigureButton(BookmarkBarNode* node, ChromeViews::TextButton* button);
+ void ConfigureButton(BookmarkNode* node, ChromeViews::TextButton* button);
// Used when showing the menu allowing the user to choose when the bar is
// visible. Return value corresponds to the users preference for when the
@@ -329,13 +327,13 @@ class BookmarkBarView : public ChromeViews::View,
void NotifyModelChanged();
// Shows the menu used during drag and drop for the specified node.
- void ShowDropFolderForNode(BookmarkBarNode* node);
+ void ShowDropFolderForNode(BookmarkNode* node);
// Cancels the timer used to show a drop menu.
void StopShowFolderDropMenuTimer();
// Stars the timer used to show a drop menu for node.
- void StartShowFolderDropMenuTimer(BookmarkBarNode* node);
+ void StartShowFolderDropMenuTimer(BookmarkNode* node);
// Returns the drop operation and index for the drop based on the event
// and data. Returns DragDropTypes::DRAG_NONE if not a valid location.
@@ -349,26 +347,26 @@ class BookmarkBarView : public ChromeViews::View,
// Invokes CanDropAt to determine if this is a valid location for the data,
// then returns the appropriate drag operation based on the data.
int CalculateDropOperation(const BookmarkDragData& data,
- BookmarkBarNode* parent,
+ BookmarkNode* parent,
int index);
// Returns true if the specified location is a valid drop location for
// the supplied drag data.
bool CanDropAt(const BookmarkDragData& data,
- BookmarkBarNode* parent,
+ BookmarkNode* parent,
int index);
// Performs a drop of the specified data at the specified location. Returns
// the result.
int PerformDropImpl(const BookmarkDragData& data,
- BookmarkBarNode* parent_node,
+ BookmarkNode* parent_node,
int index);
// Creates a new group/entry for data, and recursively invokes itself for
// all children of data. This is used during drag and drop to clone a
// group from another profile.
void CloneDragData(const BookmarkDragData& data,
- BookmarkBarNode* parent,
+ BookmarkNode* parent,
int index_to_add_at);
// Returns the index of the first hidden bookmark button. If all buttons are
@@ -391,7 +389,7 @@ class BookmarkBarView : public ChromeViews::View,
// Model providing details as to the starred entries/groups that should be
// shown. This is owned by the Profile.
- BookmarkBarModel* model_;
+ BookmarkModel* model_;
// Used to manage showing a Menu: either for the most recently bookmarked
// entries, or for the a starred group.
diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc
index ffaa992..211d88d 100644
--- a/chrome/browser/views/bookmark_bar_view_test.cc
+++ b/chrome/browser/views/bookmark_bar_view_test.cc
@@ -4,7 +4,7 @@
#include "base/string_util.h"
#include "chrome/browser/automation/ui_controls.h"
-#include "chrome/browser/bookmarks/bookmark_bar_model.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/page_navigator.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/views/bookmark_bar_view.h"
@@ -73,10 +73,10 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
profile_.reset(new TestingProfile());
profile_->set_has_history_service(true);
- profile_->CreateBookmarkBarModel(true);
+ profile_->CreateBookmarkModel(true);
profile_->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true);
- model_ = profile_->GetBookmarkBarModel();
+ model_ = profile_->GetBookmarkModel();
bb_view_ = new BookmarkBarView(profile_.get(), NULL);
bb_view_->SetPageNavigator(&navigator_);
@@ -129,7 +129,7 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
// See comment above class description for what this does.
virtual bool CreateBigMenu() { return false; }
- BookmarkBarModel* model_;
+ BookmarkModel* model_;
BookmarkBarView* bb_view_;
TestingPageNavigator navigator_;
@@ -137,10 +137,9 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
void AddTestData(bool big_menu) {
std::string test_base = "file:///c:/tmp/";
- BookmarkBarNode* f1 =
- model_->AddGroup(model_->GetBookmarkBarNode(), 0, L"F1");
+ BookmarkNode* f1 = model_->AddGroup(model_->GetBookmarkBarNode(), 0, L"F1");
model_->AddURL(f1, 0, L"f1a", GURL(test_base + "f1a"));
- BookmarkBarNode* f11 = model_->AddGroup(f1, 1, L"F11");
+ BookmarkNode* f11 = model_->AddGroup(f1, 1, L"F11");
model_->AddURL(f11, 0, L"f11a", GURL(test_base + "f11a"));
if (big_menu) {
for (int i = 1; i <= 100; ++i) {
@@ -157,10 +156,10 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
model_->AddURL(model_->GetBookmarkBarNode(), 4, L"d",
GURL(test_base + "d"));
model_->AddURL(model_->other_node(), 0, L"oa", GURL(test_base + "oa"));
- BookmarkBarNode* of = model_->AddGroup(model_->other_node(), 1, L"OF");
+ BookmarkNode* of = model_->AddGroup(model_->other_node(), 1, L"OF");
model_->AddURL(of, 0, L"ofa", GURL(test_base + "ofa"));
model_->AddURL(of, 1, L"ofb", GURL(test_base + "ofb"));
- BookmarkBarNode* of2 = model_->AddGroup(model_->other_node(), 2, L"OF2");
+ BookmarkNode* of2 = model_->AddGroup(model_->other_node(), 2, L"OF2");
model_->AddURL(of2, 0, L"of2a", GURL(test_base + "of2a"));
model_->AddURL(of2, 1, L"of2b", GURL(test_base + "of2b"));
}
diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc
index 1734d01..476391e 100644
--- a/chrome/browser/views/bookmark_bubble_view.cc
+++ b/chrome/browser/views/bookmark_bubble_view.cc
@@ -6,7 +6,7 @@
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/app/theme/theme_resources.h"
-#include "chrome/browser/bookmarks/bookmark_bar_model.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/standard_layout.h"
#include "chrome/browser/user_metrics.h"
@@ -51,7 +51,7 @@ static SkBitmap* kCloseImage = NULL;
// RecentlyUsedFoldersModel ---------------------------------------------------
BookmarkBubbleView::RecentlyUsedFoldersModel::RecentlyUsedFoldersModel(
- BookmarkBarModel* bb_model, BookmarkBarNode* node)
+ BookmarkModel* bb_model, BookmarkNode* node)
// Use + 2 to account for bookmark bar and other node.
: nodes_(bb_model->GetMostRecentlyModifiedGroups(kMaxMRUFolders + 2)),
node_parent_index_(0) {
@@ -93,14 +93,14 @@ std::wstring BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemAt(
return nodes_[index]->GetTitle();
}
-BookmarkBarNode* BookmarkBubbleView::RecentlyUsedFoldersModel::GetNodeAt(
+BookmarkNode* BookmarkBubbleView::RecentlyUsedFoldersModel::GetNodeAt(
int index) {
return nodes_[index];
}
void BookmarkBubbleView::RecentlyUsedFoldersModel::RemoveNode(
- BookmarkBarNode* node) {
- std::vector<BookmarkBarNode*>::iterator i =
+ BookmarkNode* node) {
+ std::vector<BookmarkNode*>::iterator i =
find(nodes_.begin(), nodes_.end(), node);
if (i != nodes_.end())
nodes_.erase(i);
@@ -163,8 +163,8 @@ BookmarkBubbleView::BookmarkBubbleView(InfoBubbleDelegate* delegate,
profile_(profile),
url_(url),
newly_bookmarked_(newly_bookmarked),
- parent_model_(profile_->GetBookmarkBarModel(),
- profile_->GetBookmarkBarModel()->GetNodeByURL(url)) {
+ parent_model_(profile_->GetBookmarkModel(),
+ profile_->GetBookmarkModel()->GetNodeByURL(url)) {
Init();
}
@@ -254,8 +254,8 @@ void BookmarkBubbleView::Init() {
}
std::wstring BookmarkBubbleView::GetTitle() {
- BookmarkBarModel* bookmark_model= profile_->GetBookmarkBarModel();
- BookmarkBarNode* node = bookmark_model->GetNodeByURL(url_);
+ BookmarkModel* bookmark_model= profile_->GetBookmarkModel();
+ BookmarkNode* node = bookmark_model->GetNodeByURL(url_);
if (node)
return node->GetTitle();
else
@@ -288,10 +288,10 @@ void BookmarkBubbleView::ItemChanged(ComboBox* combo_box,
ShowEditor();
return;
}
- BookmarkBarModel* model = profile_->GetBookmarkBarModel();
- BookmarkBarNode* node = model->GetNodeByURL(url_);
+ BookmarkModel* model = profile_->GetBookmarkModel();
+ BookmarkNode* node = model->GetNodeByURL(url_);
if (node) {
- BookmarkBarNode* new_parent = parent_model_.GetNodeAt(new_index);
+ BookmarkNode* new_parent = parent_model_.GetNodeAt(new_index);
if (new_parent != node->GetParent()) {
UserMetrics::RecordAction(L"BookmarkBubble_ChangeParent", profile_);
model->Move(node, new_parent, new_parent->GetChildCount());
@@ -320,7 +320,7 @@ void BookmarkBubbleView::RemoveBookmark() {
UserMetrics::RecordAction(L"BookmarkBubble_Unstar", profile_);
GURL url = url_;
- BookmarkBarModel* model = profile_->GetBookmarkBarModel();
+ BookmarkModel* model = profile_->GetBookmarkModel();
// Close first, then notify the service. That way we know we won't be
// visible and don't have to worry about some other window becoming
// activated and deleting us before we invoke Close.
@@ -352,8 +352,8 @@ void BookmarkBubbleView::ShowEditor() {
}
void BookmarkBubbleView::SetNodeTitleFromTextField() {
- BookmarkBarModel* model = profile_->GetBookmarkBarModel();
- BookmarkBarNode* node = model->GetNodeByURL(url_);
+ BookmarkModel* model = profile_->GetBookmarkModel();
+ BookmarkNode* node = model->GetNodeByURL(url_);
if (node) {
const std::wstring new_title = title_tf_->GetText();
if (new_title != node->GetTitle()) {
diff --git a/chrome/browser/views/bookmark_bubble_view.h b/chrome/browser/views/bookmark_bubble_view.h
index 17af49f..2b3fc9f 100644
--- a/chrome/browser/views/bookmark_bubble_view.h
+++ b/chrome/browser/views/bookmark_bubble_view.h
@@ -15,8 +15,8 @@
class Profile;
-class BookmarkBarModel;
-class BookmarkBarNode;
+class BookmarkModel;
+class BookmarkNode;
namespace ChromeViews {
class CheckBox;
@@ -57,23 +57,23 @@ class BookmarkBubbleView : public ChromeViews::View,
// also contains an extra item that shows the text 'Choose another folder...'.
class RecentlyUsedFoldersModel : public ChromeViews::ComboBox::Model {
public:
- RecentlyUsedFoldersModel(BookmarkBarModel* bb_model, BookmarkBarNode* node);
+ RecentlyUsedFoldersModel(BookmarkModel* bb_model, BookmarkNode* node);
// ComboBox::Model methods. Call through to nodes_.
virtual int GetItemCount(ChromeViews::ComboBox* source);
virtual std::wstring GetItemAt(ChromeViews::ComboBox* source, int index);
// Returns the node at the specified index.
- BookmarkBarNode* GetNodeAt(int index);
+ BookmarkNode* GetNodeAt(int index);
// Returns the index of the original parent folder.
int node_parent_index() const { return node_parent_index_; }
private:
// Removes node from nodes_. Does nothing if node is not in nodes_.
- void RemoveNode(BookmarkBarNode* node);
+ void RemoveNode(BookmarkNode* node);
- std::vector<BookmarkBarNode*> nodes_;
+ std::vector<BookmarkNode*> nodes_;
int node_parent_index_;
DISALLOW_EVIL_CONSTRUCTORS(RecentlyUsedFoldersModel);
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index b8d4a11..549474c 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -149,7 +149,7 @@ void BookmarkEditorView::OnTreeViewSelectionChanged(
bool BookmarkEditorView::CanEdit(ChromeViews::TreeView* tree_view,
ChromeViews::TreeModelNode* node) {
// Only allow editting of children of the bookmark bar node and other node.
- BookmarkNode* bb_node = tree_model_->AsNode(node);
+ EditorNode* bb_node = tree_model_->AsNode(node);
return (bb_node->GetParent() && bb_node->GetParent()->GetParent());
}
@@ -223,7 +223,7 @@ void BookmarkEditorView::ShowContextMenu(View* source,
void BookmarkEditorView::Init() {
tree_view_.SetContextMenuController(this);
- bb_model_ = profile_->GetBookmarkBarModel();
+ bb_model_ = profile_->GetBookmarkModel();
DCHECK(bb_model_);
bb_model_->AddObserver(this);
@@ -295,32 +295,32 @@ void BookmarkEditorView::Init() {
Loaded(bb_model_);
}
-void BookmarkEditorView::Loaded(BookmarkBarModel* model) {
+void BookmarkEditorView::Loaded(BookmarkModel* model) {
Reset(true);
}
-void BookmarkEditorView::BookmarkNodeMoved(BookmarkBarModel* model,
- BookmarkBarNode* old_parent,
- int old_index,
- BookmarkBarNode* new_parent,
- int new_index) {
+void BookmarkEditorView::BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
+ int old_index,
+ BookmarkNode* new_parent,
+ int new_index) {
Reset(false);
}
-void BookmarkEditorView::BookmarkNodeAdded(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+void BookmarkEditorView::BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
int index) {
Reset(false);
}
-void BookmarkEditorView::BookmarkNodeRemoved(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+void BookmarkEditorView::BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
int index) {
Reset(false);
}
void BookmarkEditorView::Reset(bool first_time) {
- BookmarkBarNode* node_editing = bb_model_->GetNodeByURL(url_);
+ BookmarkNode* node_editing = bb_model_->GetNodeByURL(url_);
// If the title is empty we need to fetch it from the node.
if (first_time && title_.empty()) {
@@ -334,8 +334,8 @@ void BookmarkEditorView::Reset(bool first_time) {
// tree_view will try to invoke something on the model we just deleted.
tree_view_.SetModel(NULL);
- BookmarkNode* root_node = CreateRootNode();
- tree_model_.reset(new BookmarkTreeModel(root_node));
+ EditorNode* root_node = CreateRootNode();
+ tree_model_.reset(new EditorTreeModel(root_node));
tree_view_.SetModel(tree_model_.get());
tree_view_.SetController(this);
@@ -374,7 +374,7 @@ void BookmarkEditorView::UserInputChanged() {
void BookmarkEditorView::NewGroup() {
// Create a new entry parented to the selected item, or the bookmark
// bar if nothing is selected.
- BookmarkNode* parent = tree_model_->AsNode(tree_view_.GetSelectedNode());
+ EditorNode* parent = tree_model_->AsNode(tree_view_.GetSelectedNode());
if (!parent) {
NOTREACHED();
return;
@@ -383,9 +383,9 @@ void BookmarkEditorView::NewGroup() {
tree_view_.StartEditing(AddNewGroup(parent));
}
-BookmarkEditorView::BookmarkNode* BookmarkEditorView::AddNewGroup(
- BookmarkNode* parent) {
- BookmarkNode* new_node = new BookmarkNode();
+BookmarkEditorView::EditorNode* BookmarkEditorView::AddNewGroup(
+ EditorNode* parent) {
+ EditorNode* new_node = new EditorNode();
new_node->SetTitle(l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME));
new_node->value = 0;
// new_node is now owned by parent.
@@ -396,13 +396,13 @@ BookmarkEditorView::BookmarkNode* BookmarkEditorView::AddNewGroup(
void BookmarkEditorView::ExpandAndSelect() {
tree_view_.ExpandAll();
- BookmarkBarNode* to_select = bb_model_->GetNodeByURL(url_);
+ BookmarkNode* to_select = bb_model_->GetNodeByURL(url_);
int group_id_to_select =
to_select ? to_select->GetParent()->id() :
bb_model_->GetParentForNewNodes()->id();
DCHECK(group_id_to_select); // GetMostRecentParent should never return NULL.
- BookmarkNode* b_node =
+ EditorNode* b_node =
FindNodeWithID(tree_model_->GetRoot(), group_id_to_select);
if (!b_node)
b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node.
@@ -410,9 +410,9 @@ void BookmarkEditorView::ExpandAndSelect() {
tree_view_.SetSelectedNode(b_node);
}
-BookmarkEditorView::BookmarkNode* BookmarkEditorView::CreateRootNode() {
- BookmarkNode* root_node = new BookmarkNode(std::wstring(), 0);
- BookmarkBarNode* bb_root_node = bb_model_->root_node();
+BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() {
+ EditorNode* root_node = new EditorNode(std::wstring(), 0);
+ BookmarkNode* bb_root_node = bb_model_->root_node();
CreateNodes(bb_root_node, root_node);
DCHECK(root_node->GetChildCount() == 2);
DCHECK(bb_root_node->GetChild(0)->GetType() ==
@@ -421,12 +421,12 @@ BookmarkEditorView::BookmarkNode* BookmarkEditorView::CreateRootNode() {
return root_node;
}
-void BookmarkEditorView::CreateNodes(BookmarkBarNode* bb_node,
- BookmarkEditorView::BookmarkNode* b_node) {
+void BookmarkEditorView::CreateNodes(BookmarkNode* bb_node,
+ BookmarkEditorView::EditorNode* b_node) {
for (int i = 0; i < bb_node->GetChildCount(); ++i) {
- BookmarkBarNode* child_bb_node = bb_node->GetChild(i);
+ BookmarkNode* child_bb_node = bb_node->GetChild(i);
if (child_bb_node->is_folder()) {
- BookmarkNode* new_b_node = new BookmarkNode(child_bb_node->GetTitle(),
+ EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(),
child_bb_node->id());
b_node->Add(b_node->GetChildCount(), new_b_node);
CreateNodes(child_bb_node, new_b_node);
@@ -434,13 +434,13 @@ void BookmarkEditorView::CreateNodes(BookmarkBarNode* bb_node,
}
}
-BookmarkEditorView::BookmarkNode* BookmarkEditorView::FindNodeWithID(
- BookmarkEditorView::BookmarkNode* node,
+BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID(
+ BookmarkEditorView::EditorNode* node,
int id) {
if (node->value == id)
return node;
for (int i = 0; i < node->GetChildCount(); ++i) {
- BookmarkNode* result = FindNodeWithID(node->GetChild(i), id);
+ EditorNode* result = FindNodeWithID(node->GetChild(i), id);
if (result)
return result;
}
@@ -457,7 +457,7 @@ void BookmarkEditorView::ApplyEdits() {
ApplyEdits(tree_model_->AsNode(tree_view_.GetSelectedNode()));
}
-void BookmarkEditorView::ApplyEdits(BookmarkNode* parent) {
+void BookmarkEditorView::ApplyEdits(EditorNode* parent) {
DCHECK(parent);
// We're going to apply edits to the bookmark bar model, which will call us
@@ -468,8 +468,8 @@ void BookmarkEditorView::ApplyEdits(BookmarkNode* parent) {
GURL new_url(GetInputURL());
std::wstring new_title(GetInputTitle());
- BookmarkBarNode* old_node = bb_model_->GetNodeByURL(url_);
- BookmarkBarNode* old_parent = old_node ? old_node->GetParent() : NULL;
+ BookmarkNode* old_node = bb_model_->GetNodeByURL(url_);
+ BookmarkNode* old_parent = old_node ? old_node->GetParent() : NULL;
const int old_index = old_parent ? old_parent->IndexOfChild(old_node) : -1;
if (url_ != new_url) {
@@ -478,7 +478,7 @@ void BookmarkEditorView::ApplyEdits(BookmarkNode* parent) {
}
// Create the new groups and update the titles.
- BookmarkBarNode* new_parent = NULL;
+ BookmarkNode* new_parent = NULL;
ApplyNameChangesAndCreateNewGroups(
bb_model_->root_node(), tree_model_->GetRoot(), parent, &new_parent);
@@ -488,7 +488,7 @@ void BookmarkEditorView::ApplyEdits(BookmarkNode* parent) {
return;
}
- BookmarkBarNode* current_node = bb_model_->GetNodeByURL(new_url);
+ BookmarkNode* current_node = bb_model_->GetNodeByURL(new_url);
if (current_node) {
// There's already a node with the URL.
@@ -515,15 +515,15 @@ void BookmarkEditorView::ApplyEdits(BookmarkNode* parent) {
}
void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups(
- BookmarkBarNode* bb_node,
- BookmarkEditorView::BookmarkNode* b_node,
- BookmarkEditorView::BookmarkNode* parent_b_node,
- BookmarkBarNode** parent_bb_node) {
+ BookmarkNode* bb_node,
+ BookmarkEditorView::EditorNode* b_node,
+ BookmarkEditorView::EditorNode* parent_b_node,
+ BookmarkNode** parent_bb_node) {
if (parent_b_node == b_node)
*parent_bb_node = bb_node;
for (int i = 0; i < b_node->GetChildCount(); ++i) {
- BookmarkNode* child_b_node = b_node->GetChild(i);
- BookmarkBarNode* child_bb_node = NULL;
+ EditorNode* child_b_node = b_node->GetChild(i);
+ BookmarkNode* child_bb_node = NULL;
if (child_b_node->value == 0) {
// New group.
child_bb_node = bb_model_->AddGroup(bb_node,
@@ -532,7 +532,7 @@ void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups(
// Existing node, reset the title (BBModel ignores changes if the title
// is the same).
for (int j = 0; j < bb_node->GetChildCount(); ++j) {
- BookmarkBarNode* node = bb_node->GetChild(j);
+ BookmarkNode* node = bb_node->GetChild(j);
if (node->is_folder() && node->id() == child_b_node->value) {
child_bb_node = node;
break;
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 01158ef..b928dc9 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H__
-#define CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_
+#define CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_
#include <set>
#include "chrome/views/tree_node_model.h"
-#include "chrome/browser/bookmarks/bookmark_bar_model.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/views/checkbox.h"
#include "chrome/views/dialog_delegate.h"
#include "chrome/views/menu.h"
@@ -27,7 +27,7 @@ class Profile;
// change the URL, title and where the bookmark appears as well as adding
// new groups and changing the name of other groups.
//
-// Edits are applied to the BookmarkBarModel when the user presses 'OK'.
+// Edits are applied to the BookmarkModel when the user presses 'OK'.
//
// To use BookmarkEditorView invoke the static show method.
@@ -38,7 +38,7 @@ class BookmarkEditorView : public ChromeViews::View,
public ChromeViews::TextField::Controller,
public ChromeViews::ContextMenuController,
public Menu::Delegate,
- public BookmarkBarModelObserver {
+ public BookmarkModelObserver {
FRIEND_TEST(BookmarkEditorViewTest, ChangeParent);
FRIEND_TEST(BookmarkEditorViewTest, ChangeURLToExistingURL);
FRIEND_TEST(BookmarkEditorViewTest, EditTitleKeepsPosition);
@@ -110,14 +110,14 @@ class BookmarkEditorView : public ChromeViews::View,
private:
// Type of node in the tree.
- typedef ChromeViews::TreeNodeWithValue<int> BookmarkNode;
+ typedef ChromeViews::TreeNodeWithValue<int> EditorNode;
// Model for the TreeView. Trivial subclass that doesn't allow titles with
// empty strings.
- class BookmarkTreeModel : public ChromeViews::TreeNodeModel<BookmarkNode> {
+ class EditorTreeModel : public ChromeViews::TreeNodeModel<EditorNode> {
public:
- explicit BookmarkTreeModel(BookmarkNode* root)
- : TreeNodeModel<BookmarkNode>(root) {}
+ explicit EditorTreeModel(EditorNode* root)
+ : TreeNodeModel<EditorNode>(root) {}
virtual void SetTitle(ChromeViews::TreeModelNode* node,
const std::wstring& title) {
@@ -126,31 +126,31 @@ class BookmarkEditorView : public ChromeViews::View,
}
private:
- DISALLOW_EVIL_CONSTRUCTORS(BookmarkTreeModel);
+ DISALLOW_COPY_AND_ASSIGN(EditorTreeModel);
};
// Creates the necessary sub-views, configures them, adds them to the layout,
// and requests the entries to display from the database.
void Init();
- // BookmarkBarModel observer methods. Any structural change results in
+ // BookmarkModel observer methods. Any structural change results in
// resetting the tree model.
- virtual void Loaded(BookmarkBarModel* model);
- virtual void BookmarkNodeMoved(BookmarkBarModel* model,
- BookmarkBarNode* old_parent,
+ virtual void Loaded(BookmarkModel* model);
+ virtual void BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
int old_index,
- BookmarkBarNode* new_parent,
+ BookmarkNode* new_parent,
int new_index);
- virtual void BookmarkNodeAdded(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+ virtual void BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
int index);
- virtual void BookmarkNodeRemoved(BookmarkBarModel* model,
- BookmarkBarNode* parent,
+ virtual void BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
int index);
- virtual void BookmarkNodeChanged(BookmarkBarModel* model,
- BookmarkBarNode* node) {}
- virtual void BookmarkNodeFavIconLoaded(BookmarkBarModel* model,
- BookmarkBarNode* node) {}
+ virtual void BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node) {}
+ virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node) {}
// Resets the model of the tree and updates the various buttons appropriately.
// If first_time is true, Reset is being invoked from the constructor or
@@ -164,37 +164,36 @@ class BookmarkEditorView : public ChromeViews::View,
// Creates a returns the new root node. This invokes CreateNodes to do
// the real work.
- BookmarkNode* CreateRootNode();
+ EditorNode* CreateRootNode();
// Adds and creates a child node in b_node for all children of bb_node that
// are groups.
- void CreateNodes(BookmarkBarNode* bb_node,
- BookmarkNode* b_node);
+ void CreateNodes(BookmarkNode* bb_node, EditorNode* b_node);
// Returns the node with the specified id, or NULL if one can't be found.
- BookmarkNode* FindNodeWithID(BookmarkEditorView::BookmarkNode* node, int id);
+ EditorNode* FindNodeWithID(BookmarkEditorView::EditorNode* node, int id);
// Invokes ApplyEdits with the selected node.
void ApplyEdits();
// Applies the edits done by the user. |parent| gives the parent of the URL
// being edited.
- void ApplyEdits(BookmarkNode* parent);
+ void ApplyEdits(EditorNode* parent);
// Recursively adds newly created groups and sets the title of nodes to
// match the user edited title.
//
- // bb_node gives the BookmarkBarNode the edits are to be applied to,
- // with b_node the source of the edits.
+ // bb_node gives the BookmarkNode the edits are to be applied to, with b_node
+ // the source of the edits.
//
// If b_node == parent_b_node, parent_bb_node is set to bb_node. This is
- // used to determine the new BookmarkBarNode parent based on the BookmarkNode
+ // used to determine the new BookmarkNode parent based on the EditorNode
// parent.
void ApplyNameChangesAndCreateNewGroups(
- BookmarkBarNode* bb_node,
- BookmarkEditorView::BookmarkNode* b_node,
- BookmarkEditorView::BookmarkNode* parent_b_node,
- BookmarkBarNode** parent_bb_node);
+ BookmarkNode* bb_node,
+ BookmarkEditorView::EditorNode* b_node,
+ BookmarkEditorView::EditorNode* parent_b_node,
+ BookmarkNode** parent_bb_node);
// Returns the current url the user has input.
GURL GetInputURL() const;
@@ -211,16 +210,16 @@ class BookmarkEditorView : public ChromeViews::View,
// editing on the new gorup as well.
void NewGroup();
- // Creates a new BookmarkNode as the last child of parent. The new node is
+ // Creates a new EditorNode as the last child of parent. The new node is
// added to the model and returned. This does NOT start editing. This is used
// internally by NewGroup and broken into a separate method for testing.
- BookmarkNode* AddNewGroup(BookmarkNode* parent);
+ EditorNode* AddNewGroup(EditorNode* parent);
// Profile the entry is from.
Profile* profile_;
// Model driving the TreeView.
- scoped_ptr<BookmarkTreeModel> tree_model_;
+ scoped_ptr<EditorTreeModel> tree_model_;
// Displays star groups.
ChromeViews::TreeView tree_view_;
@@ -244,14 +243,13 @@ class BookmarkEditorView : public ChromeViews::View,
std::wstring title_;
// Mode used to create nodes from.
- BookmarkBarModel* bb_model_;
+ BookmarkModel* bb_model_;
// If true, we're running the menu for the bookmark bar or other bookmarks
// nodes.
bool running_menu_for_root_;
- DISALLOW_EVIL_CONSTRUCTORS(BookmarkEditorView);
+ DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView);
};
-#endif // CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H__
-
+#endif // CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_
diff --git a/chrome/browser/views/bookmark_editor_view_unittest.cc b/chrome/browser/views/bookmark_editor_view_unittest.cc
index 2f161a0..74baaf5 100644
--- a/chrome/browser/views/bookmark_editor_view_unittest.cc
+++ b/chrome/browser/views/bookmark_editor_view_unittest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/string_util.h"
-#include "chrome/browser/bookmarks/bookmark_bar_model.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/views/bookmark_editor_view.h"
#include "chrome/common/pref_names.h"
@@ -11,8 +11,8 @@
#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
-// Base class for bookmark editor tests. Creates a BookmarkBarModel and
-// populates it with test data.
+// Base class for bookmark editor tests. Creates a BookmarkModel and populates
+// it with test data.
class BookmarkEditorViewTest : public testing::Test {
public:
BookmarkEditorViewTest() : model_(NULL) {
@@ -21,9 +21,9 @@ class BookmarkEditorViewTest : public testing::Test {
virtual void SetUp() {
profile_.reset(new TestingProfile());
profile_->set_has_history_service(true);
- profile_->CreateBookmarkBarModel(true);
+ profile_->CreateBookmarkModel(true);
- model_ = profile_->GetBookmarkBarModel();
+ model_ = profile_->GetBookmarkModel();
AddTestData();
}
@@ -33,7 +33,7 @@ class BookmarkEditorViewTest : public testing::Test {
protected:
MessageLoopForUI message_loop_;
- BookmarkBarModel* model_;
+ BookmarkModel* model_;
scoped_ptr<TestingProfile> profile_;
std::string base_path() const { return "file:///c:/tmp/"; }
@@ -56,18 +56,16 @@ class BookmarkEditorViewTest : public testing::Test {
model_->AddURL(model_->GetBookmarkBarNode(), 0, L"a",
GURL(test_base + "a"));
- BookmarkBarNode* f1 =
- model_->AddGroup(model_->GetBookmarkBarNode(), 1, L"F1");
+ BookmarkNode* f1 = model_->AddGroup(model_->GetBookmarkBarNode(), 1, L"F1");
model_->AddURL(f1, 0, L"f1a", GURL(test_base + "f1a"));
- BookmarkBarNode* f11 = model_->AddGroup(f1, 1, L"F11");
+ BookmarkNode* f11 = model_->AddGroup(f1, 1, L"F11");
model_->AddURL(f11, 0, L"f11a", GURL(test_base + "f11a"));
model_->AddGroup(model_->GetBookmarkBarNode(), 2, L"F2");
// Children of the other node.
model_->AddURL(model_->other_node(), 0, L"oa",
GURL(test_base + "oa"));
- BookmarkBarNode* of1 =
- model_->AddGroup(model_->other_node(), 1, L"OF1");
+ BookmarkNode* of1 = model_->AddGroup(model_->other_node(), 1, L"OF1");
model_->AddURL(of1, 0, L"of1a", GURL(test_base + "of1a"));
}
};
@@ -76,12 +74,12 @@ class BookmarkEditorViewTest : public testing::Test {
TEST_F(BookmarkEditorViewTest, ModelsMatch) {
BookmarkEditorView editor(profile_.get(), GURL(base_path() + "xxx"),
L"xxx");
- BookmarkEditorView::BookmarkNode* editor_root = editor.tree_model_->GetRoot();
+ BookmarkEditorView::EditorNode* editor_root = editor.tree_model_->GetRoot();
// The root should have two children, one for the bookmark bar node,
// the other for the 'other bookmarks' folder.
ASSERT_EQ(2, editor_root->GetChildCount());
- BookmarkEditorView::BookmarkNode* bb_node = editor_root->GetChild(0);
+ BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0);
// The root should have 2 nodes: folder F1 and F2.
ASSERT_EQ(2, bb_node->GetChildCount());
ASSERT_EQ(L"F1", bb_node->GetChild(0)->GetTitle());
@@ -91,7 +89,7 @@ TEST_F(BookmarkEditorViewTest, ModelsMatch) {
ASSERT_EQ(1, bb_node->GetChild(0)->GetChildCount());
ASSERT_EQ(L"F11", bb_node->GetChild(0)->GetChild(0)->GetTitle());
- BookmarkEditorView::BookmarkNode* other_node = editor_root->GetChild(1);
+ BookmarkEditorView::EditorNode* other_node = editor_root->GetChild(1);
// Other node should have one child (OF1).
ASSERT_EQ(1, other_node->GetChildCount());
ASSERT_EQ(L"OF1", other_node->GetChild(0)->GetTitle());
@@ -103,8 +101,7 @@ TEST_F(BookmarkEditorViewTest, EditTitleKeepsPosition) {
editor.ApplyEdits(editor.tree_model_->GetRoot()->GetChild(0));
- BookmarkBarNode* bb_node =
- profile_->GetBookmarkBarModel()->GetBookmarkBarNode();
+ BookmarkNode* bb_node = profile_->GetBookmarkModel()->GetBookmarkBarNode();
ASSERT_EQ(L"new_a", bb_node->GetChild(0)->GetTitle());
// The URL shouldn't have changed.
ASSERT_TRUE(GURL(base_path() + "a") == bb_node->GetChild(0)->GetURL());
@@ -118,8 +115,7 @@ TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) {
editor.ApplyEdits(editor.tree_model_->GetRoot()->GetChild(0));
- BookmarkBarNode* bb_node =
- profile_->GetBookmarkBarModel()->GetBookmarkBarNode();
+ BookmarkNode* bb_node = profile_->GetBookmarkModel()->GetBookmarkBarNode();
ASSERT_EQ(L"a", bb_node->GetChild(0)->GetTitle());
// The URL should have changed.
ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->GetURL());
@@ -131,7 +127,7 @@ TEST_F(BookmarkEditorViewTest, ChangeParent) {
editor.ApplyEdits(editor.tree_model_->GetRoot()->GetChild(1));
- BookmarkBarNode* other_node = profile_->GetBookmarkBarModel()->other_node();
+ BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node();
ASSERT_EQ(L"a", other_node->GetChild(2)->GetTitle());
ASSERT_TRUE(GURL(base_path() + "a") == other_node->GetChild(2)->GetURL());
}
@@ -145,8 +141,7 @@ TEST_F(BookmarkEditorViewTest, ChangeURLToExistingURL) {
editor.ApplyEdits(editor.tree_model_->GetRoot()->GetChild(0));
// Position shouldn't have changed.
- BookmarkBarNode* bb_node =
- profile_->GetBookmarkBarModel()->GetBookmarkBarNode();
+ BookmarkNode* bb_node = profile_->GetBookmarkModel()->GetBookmarkBarNode();
ASSERT_EQ(L"a", bb_node->GetChild(0)->GetTitle());
// The URL should have changed.
ASSERT_TRUE(GURL(base_path() + "f1a") == bb_node->GetChild(0)->GetURL());
@@ -161,19 +156,18 @@ TEST_F(BookmarkEditorViewTest, MoveToNewParent) {
BookmarkEditorView editor(profile_.get(), GURL(base_path() + "a"), L"a");
// Create two nodes: "F21" as a child of "F2" and "F211" as a child of "F21".
- BookmarkEditorView::BookmarkNode* f2 =
+ BookmarkEditorView::EditorNode* f2 =
editor.tree_model_->GetRoot()->GetChild(0)->GetChild(1);
- BookmarkEditorView::BookmarkNode* f21 = editor.AddNewGroup(f2);
+ BookmarkEditorView::EditorNode* f21 = editor.AddNewGroup(f2);
f21->SetTitle(L"F21");
- BookmarkEditorView::BookmarkNode* f211 = editor.AddNewGroup(f21);
+ BookmarkEditorView::EditorNode* f211 = editor.AddNewGroup(f21);
f211->SetTitle(L"F211");
// Parent the node to "F21".
editor.ApplyEdits(f2);
- BookmarkBarNode* bb_node =
- profile_->GetBookmarkBarModel()->GetBookmarkBarNode();
- BookmarkBarNode* mf2 = bb_node->GetChild(1);
+ BookmarkNode* bb_node = profile_->GetBookmarkModel()->GetBookmarkBarNode();
+ BookmarkNode* mf2 = bb_node->GetChild(1);
// F2 in the model should have two children now: F21 and the node edited.
ASSERT_EQ(2, mf2->GetChildCount());
@@ -183,7 +177,7 @@ TEST_F(BookmarkEditorViewTest, MoveToNewParent) {
ASSERT_EQ(L"a", mf2->GetChild(1)->GetTitle());
// F21 should have one child, F211.
- BookmarkBarNode* mf21 = mf2->GetChild(0);
+ BookmarkNode* mf21 = mf2->GetChild(0);
ASSERT_EQ(1, mf21->GetChildCount());
ASSERT_EQ(L"F211", mf21->GetChild(0)->GetTitle());
}
diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc
index 52d2839..101d319 100644
--- a/chrome/browser/views/toolbar_star_toggle.cc
+++ b/chrome/browser/views/toolbar_star_toggle.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/views/toolbar_star_toggle.h"
#include "chrome/app/theme/theme_resources.h"
-#include "chrome/browser/bookmarks/bookmark_bar_model.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/views/bookmark_bubble_view.h"
#include "chrome/browser/views/toolbar_view.h"