Index: chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc |
=================================================================== |
--- chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc (revision 95527) |
+++ chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc (working copy) |
@@ -121,10 +121,9 @@ |
const int BookmarkBarGtk::kBookmarkBarNTPHeight = 57; |
BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window, |
- Profile* profile, Browser* browser, |
+ Browser* browser, |
TabstripOriginProvider* tabstrip_origin_provider) |
- : profile_(NULL), |
- page_navigator_(NULL), |
+ : page_navigator_(NULL), |
browser_(browser), |
window_(window), |
tabstrip_origin_provider_(tabstrip_origin_provider), |
@@ -134,7 +133,7 @@ |
dragged_node_(NULL), |
drag_icon_(NULL), |
toolbar_drop_item_(NULL), |
- theme_service_(GtkThemeService::GetFrom(profile)), |
+ theme_service_(GtkThemeService::GetFrom(browser->profile())), |
show_instructions_(true), |
menu_bar_helper_(this), |
slide_animation_(this), |
@@ -142,6 +141,7 @@ |
throbbing_widget_(NULL), |
method_factory_(this), |
bookmark_bar_state_(BookmarkBar::DETACHED) { |
+ Profile* profile = browser->profile(); |
if (profile->GetProfileSyncService()) { |
// Obtain a pointer to the profile sync service and add our instance as an |
// observer. |
@@ -149,8 +149,7 @@ |
sync_service_->AddObserver(this); |
} |
- Init(profile); |
- SetProfile(profile); |
+ Init(); |
// Force an update by simulating being in the wrong state. |
// BrowserWindowGtk sets our true state after we're created. |
SetBookmarkBarState(BookmarkBar::SHOW, |
@@ -160,7 +159,7 @@ |
Source<ThemeService>(theme_service_)); |
edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
- profile_->GetPrefs(), this); |
+ profile->GetPrefs(), this); |
OnEditBookmarksEnabledChanged(); |
} |
@@ -170,34 +169,11 @@ |
event_box_.Destroy(); |
} |
-void BookmarkBarGtk::SetProfile(Profile* profile) { |
- DCHECK(profile); |
- if (profile_ == profile) |
- return; |
- |
- RemoveAllBookmarkButtons(); |
- |
- profile_ = profile; |
- |
- if (model_) |
- model_->RemoveObserver(this); |
- |
- // TODO(erg): Handle extensions |
- |
- model_ = profile_->GetBookmarkModel(); |
- model_->AddObserver(this); |
- if (model_->IsLoaded()) |
- Loaded(model_, false); |
- |
- // else case: we'll receive notification back from the BookmarkModel when done |
- // loading, then we'll populate the bar. |
-} |
- |
void BookmarkBarGtk::SetPageNavigator(PageNavigator* navigator) { |
page_navigator_ = navigator; |
} |
-void BookmarkBarGtk::Init(Profile* profile) { |
+void BookmarkBarGtk::Init() { |
event_box_.Own(gtk_event_box_new()); |
g_signal_connect(event_box_.get(), "destroy", |
G_CALLBACK(&OnEventBoxDestroyThunk), this); |
@@ -221,6 +197,7 @@ |
instructions_ = gtk_alignment_new(0, 0, 1, 1); |
gtk_alignment_set_padding(GTK_ALIGNMENT(instructions_), 0, 0, |
kInstructionsPadding, 0); |
+ Profile* profile = browser_->profile(); |
instructions_gtk_.reset(new BookmarkBarInstructionsGtk(this, profile)); |
gtk_container_add(GTK_CONTAINER(instructions_), instructions_gtk_->widget()); |
gtk_box_pack_start(GTK_BOX(bookmark_hbox_), instructions_, |
@@ -310,6 +287,15 @@ |
gtk_widget_show_all(widget()); |
gtk_widget_hide(widget()); |
+ |
+ RemoveAllBookmarkButtons(); |
sky
2011/08/08 16:02:29
I don't think you need this anymore. It made sense
Peter Kasting
2011/08/08 17:52:07
Unfortunately this function does more than removin
|
+ // TODO(erg): Handle extensions |
+ model_ = profile->GetBookmarkModel(); |
+ model_->AddObserver(this); |
+ if (model_->IsLoaded()) |
+ Loaded(model_, false); |
+ // else case: we'll receive notification back from the BookmarkModel when done |
+ // loading, then we'll populate the bar. |
} |
void BookmarkBarGtk::SetBookmarkBarState( |
@@ -398,7 +384,7 @@ |
} |
current_menu_.reset( |
- new BookmarkMenuController(browser_, profile_, page_navigator_, |
+ new BookmarkMenuController(browser_, browser_->profile(), page_navigator_, |
GTK_WINDOW(gtk_widget_get_toplevel(button)), |
node, |
button == overflow_button_ ? |
@@ -1119,7 +1105,7 @@ |
GtkWindow* window = GTK_WINDOW(gtk_widget_get_toplevel(sender)); |
current_context_menu_controller_.reset( |
new BookmarkContextMenuController( |
- window, this, profile_, page_navigator_, parent, nodes)); |
+ window, this, browser_->profile(), page_navigator_, parent, nodes)); |
current_context_menu_.reset( |
new MenuGtk(NULL, current_context_menu_controller_->menu_model())); |
current_context_menu_->PopupAsContext( |
@@ -1157,10 +1143,10 @@ |
DCHECK(node->is_url()); |
DCHECK(page_navigator_); |
- RecordAppLaunch(profile_, node->url()); |
- bookmark_utils::OpenAll(window_->GetNativeHandle(), |
- profile_, page_navigator_, node, |
- gtk_util::DispositionForCurrentButtonPressEvent()); |
+ Profile* profile = browser_->profile(); |
+ RecordAppLaunch(profile, node->url()); |
+ bookmark_utils::OpenAll(window_->GetNativeHandle(), profile, page_navigator_, |
+ node, gtk_util::DispositionForCurrentButtonPressEvent()); |
UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); |
} |
@@ -1220,12 +1206,14 @@ |
g_object_unref(button->parent); |
} |
-void BookmarkBarGtk::OnButtonDragGet(GtkWidget* widget, GdkDragContext* context, |
+void BookmarkBarGtk::OnButtonDragGet(GtkWidget* widget, |
+ GdkDragContext* context, |
GtkSelectionData* selection_data, |
- guint target_type, guint time) { |
+ guint target_type, |
+ guint time) { |
const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); |
bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, |
- profile_); |
+ browser_->profile()); |
} |
void BookmarkBarGtk::OnFolderClicked(GtkWidget* sender) { |
@@ -1240,9 +1228,8 @@ |
PopupForButton(sender); |
} else if (event->button.button == 2) { |
const BookmarkNode* node = GetNodeForToolButton(sender); |
- bookmark_utils::OpenAll(window_->GetNativeHandle(), |
- profile_, page_navigator_, |
- node, NEW_BACKGROUND_TAB); |
+ bookmark_utils::OpenAll(window_->GetNativeHandle(), browser_->profile(), |
+ page_navigator_, node, NEW_BACKGROUND_TAB); |
} |
} |
@@ -1304,7 +1291,7 @@ |
std::vector<const BookmarkNode*> nodes = |
bookmark_utils::GetNodesFromSelection(context, selection_data, |
target_type, |
- profile_, |
+ browser_->profile(), |
&delete_selection_data, |
&dnd_success); |
DCHECK(!nodes.empty()); |