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

Unified Diff: chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc

Issue 8528036: gtk/bookmarks: Cache BookmarkModel in BookmarkBubbleGtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc
index 2ae7d51f3ecf6826b7f0c25a3b95c20c21c8d1d2..7144953387f97c29fed0b2439144fb16db607cca 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc
@@ -89,6 +89,7 @@ BookmarkBubbleGtk::BookmarkBubbleGtk(GtkWidget* anchor,
bool newly_bookmarked)
: url_(url),
profile_(profile),
+ model_(profile->GetBookmarkModel()),
theme_service_(GtkThemeService::GetFrom(profile_)),
anchor_(anchor),
content_(NULL),
@@ -203,10 +204,9 @@ BookmarkBubbleGtk::~BookmarkBubbleGtk() {
if (apply_edits_) {
ApplyEdits();
} else if (remove_bookmark_) {
- BookmarkModel* model = profile_->GetBookmarkModel();
- const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_);
+ const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url_);
if (node)
- model->Remove(node->parent(), node->parent()->GetIndexOf(node));
+ model_->Remove(node->parent(), node->parent()->GetIndexOf(node));
}
}
@@ -269,14 +269,13 @@ void BookmarkBubbleGtk::ApplyEdits() {
// Set this to make sure we don't attempt to apply edits again.
apply_edits_ = false;
- BookmarkModel* model = profile_->GetBookmarkModel();
- const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_);
+ const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url_);
if (node) {
const string16 new_title(
UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(name_entry_))));
if (new_title != node->GetTitle()) {
- model->SetTitle(node, new_title);
+ model_->SetTitle(node, new_title);
UserMetrics::RecordAction(
UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"));
}
@@ -289,16 +288,14 @@ void BookmarkBubbleGtk::ApplyEdits() {
if (new_parent != node->parent()) {
UserMetrics::RecordAction(
UserMetricsAction("BookmarkBubble_ChangeParent"));
- model->Move(node, new_parent, new_parent->child_count());
+ model_->Move(node, new_parent, new_parent->child_count());
}
}
}
}
std::string BookmarkBubbleGtk::GetTitle() {
- BookmarkModel* bookmark_model= profile_->GetBookmarkModel();
- const BookmarkNode* node =
- bookmark_model->GetMostRecentlyAddedNodeForURL(url_);
+ const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url_);
if (!node) {
NOTREACHED();
return std::string();
@@ -308,8 +305,7 @@ std::string BookmarkBubbleGtk::GetTitle() {
}
void BookmarkBubbleGtk::ShowEditor() {
- const BookmarkNode* node =
- profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_);
+ const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url_);
// Commit any edits now.
ApplyEdits();
@@ -329,12 +325,10 @@ void BookmarkBubbleGtk::ShowEditor() {
}
void BookmarkBubbleGtk::InitFolderComboModel() {
- const BookmarkNode* node =
- profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_);
+ const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url_);
DCHECK(node);
- folder_combo_model_.reset(new RecentlyUsedFoldersComboModel(
- profile_->GetBookmarkModel(), node));
+ folder_combo_model_.reset(new RecentlyUsedFoldersComboModel(model_, node));
// We always have nodes + 1 entries in the combo. The last entry will be
// the 'Select another folder...' entry that opens the bookmark editor.
« no previous file with comments | « chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698