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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc

Issue 10827047: Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
===================================================================
--- chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc (revision 148477)
+++ chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc (working copy)
@@ -6,6 +6,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/event_disposition.h"
@@ -54,7 +55,7 @@
}
BookmarkMenuDelegate::~BookmarkMenuDelegate() {
- profile_->GetBookmarkModel()->RemoveObserver(this);
+ BookmarkModelFactory::GetForProfile(profile_)->RemoveObserver(this);
}
void BookmarkMenuDelegate::Init(
@@ -64,7 +65,7 @@
int start_child_index,
ShowOptions show_options,
bookmark_utils::BookmarkLaunchLocation location) {
- profile_->GetBookmarkModel()->AddObserver(this);
+ BookmarkModelFactory::GetForProfile(profile_)->AddObserver(this);
real_delegate_ = real_delegate;
if (parent) {
parent_menu_item_ = parent;
@@ -191,8 +192,10 @@
int index_to_drop_at = drop_parent->GetIndexOf(node);
switch (*position) {
case views::MenuDelegate::DROP_AFTER:
- if (node == profile_->GetBookmarkModel()->other_node() ||
- node == profile_->GetBookmarkModel()->mobile_node()) {
+ if (node == BookmarkModelFactory::GetForProfile(
+ profile_)->other_node() ||
+ node == BookmarkModelFactory::GetForProfile(
+ profile_)->mobile_node()) {
// Dropping after these nodes makes no sense.
*position = views::MenuDelegate::DROP_NONE;
}
@@ -200,7 +203,8 @@
break;
case views::MenuDelegate::DROP_BEFORE:
- if (node == profile_->GetBookmarkModel()->mobile_node()) {
+ if (node == BookmarkModelFactory::GetForProfile(
+ profile_)->mobile_node()) {
// Dropping before this node makes no sense.
*position = views::MenuDelegate::DROP_NONE;
}
@@ -226,7 +230,7 @@
const views::DropTargetEvent& event) {
const BookmarkNode* drop_node = menu_id_to_node_map_[menu->GetCommand()];
DCHECK(drop_node);
- BookmarkModel* model = profile_->GetBookmarkModel();
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_);
DCHECK(model);
const BookmarkNode* drop_parent = drop_node->parent();
DCHECK(drop_parent);
@@ -268,7 +272,8 @@
std::vector<const BookmarkNode*> nodes;
nodes.push_back(menu_id_to_node_map_[id]);
bool close_on_delete = !parent_menu_item_ &&
- (nodes[0]->parent() == profile()->GetBookmarkModel()->other_node() &&
+ (nodes[0]->parent() == BookmarkModelFactory::GetForProfile(
+ profile())->other_node() &&
nodes[0]->parent()->child_count() == 1);
context_menu_.reset(
new BookmarkContextMenu(
@@ -288,7 +293,8 @@
bool BookmarkMenuDelegate::CanDrag(MenuItemView* menu) {
const BookmarkNode* node = menu_id_to_node_map_[menu->GetCommand()];
// Don't let users drag the other folder.
- return node->parent() != profile_->GetBookmarkModel()->root_node();
+ return node->parent() != BookmarkModelFactory::GetForProfile(
+ profile_)->root_node();
}
void BookmarkMenuDelegate::WriteDragData(MenuItemView* sender,
@@ -349,7 +355,7 @@
// Remove the observer so that when the remove happens we don't prematurely
// cancel the menu. The observer ias added back in DidRemoveBookmarks.
- profile_->GetBookmarkModel()->RemoveObserver(this);
+ BookmarkModelFactory::GetForProfile(profile_)->RemoveObserver(this);
// Remove the menu items.
std::set<MenuItemView*> changed_parent_menus;
@@ -398,7 +404,7 @@
void BookmarkMenuDelegate::DidRemoveBookmarks() {
// Balances remove in WillRemoveBookmarksImpl.
- profile_->GetBookmarkModel()->AddObserver(this);
+ BookmarkModelFactory::GetForProfile(profile_)->AddObserver(this);
DCHECK(is_mutating_model_);
is_mutating_model_ = false;
}
@@ -420,7 +426,7 @@
void BookmarkMenuDelegate::BuildMenusForPermanentNodes(
views::MenuItemView* menu,
int* next_menu_id) {
- BookmarkModel* model = profile_->GetBookmarkModel();
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_);
bool added_separator = false;
BuildMenuForPermanentNode(model->other_node(), menu, next_menu_id,
&added_separator);
@@ -462,7 +468,8 @@
(*next_menu_id)++;
if (node->is_url()) {
- const gfx::Image& image = profile_->GetBookmarkModel()->GetFavicon(node);
+ const gfx::Image& image = BookmarkModelFactory::GetForProfile(
+ profile_)->GetFavicon(node);
const gfx::ImageSkia* icon = image.IsEmpty() ?
rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON) : image.ToImageSkia();
menu->AppendMenuItemWithIcon(id, node->GetTitle(), *icon);
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698