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

Side by Side Diff: chrome/browser/gtk/bookmark_bubble_gtk.cc

Issue 160495: retry r2226, with a fix for a case where we could double free. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/bookmark_bubble_gtk.h" 5 #include "chrome/browser/gtk/bookmark_bubble_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 NotificationType::BOOKMARK_BUBBLE_HIDDEN, 111 NotificationType::BOOKMARK_BUBBLE_HIDDEN,
112 Source<Profile>(profile_->GetOriginalProfile()), 112 Source<Profile>(profile_->GetOriginalProfile()),
113 NotificationService::NoDetails()); 113 NotificationService::NoDetails());
114 } 114 }
115 115
116 void BookmarkBubbleGtk::Observe(NotificationType type, 116 void BookmarkBubbleGtk::Observe(NotificationType type,
117 const NotificationSource& source, 117 const NotificationSource& source,
118 const NotificationDetails& details) { 118 const NotificationDetails& details) {
119 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); 119 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED);
120 120
121 gtk_chrome_link_button_set_use_gtk_theme(
122 GTK_CHROME_LINK_BUTTON(remove_button_),
123 theme_provider_->UseGtkTheme());
124
121 if (theme_provider_->UseGtkTheme()) { 125 if (theme_provider_->UseGtkTheme()) {
122 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); 126 for (std::vector<GtkWidget*>::iterator it = labels_.begin();
123 it != labels_.end(); ++it) { 127 it != labels_.end(); ++it) {
124 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); 128 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL);
125 } 129 }
126 } else { 130 } else {
127 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); 131 for (std::vector<GtkWidget*>::iterator it = labels_.begin();
128 it != labels_.end(); ++it) { 132 it != labels_.end(); ++it) {
129 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack); 133 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack);
130 } 134 }
(...skipping 14 matching lines...) Expand all
145 folder_combo_(NULL), 149 folder_combo_(NULL),
146 bubble_(NULL), 150 bubble_(NULL),
147 factory_(this), 151 factory_(this),
148 newly_bookmarked_(newly_bookmarked), 152 newly_bookmarked_(newly_bookmarked),
149 apply_edits_(true), 153 apply_edits_(true),
150 remove_bookmark_(false) { 154 remove_bookmark_(false) {
151 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8( 155 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8(
152 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED : 156 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED :
153 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK).c_str()); 157 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK).c_str());
154 labels_.push_back(label); 158 labels_.push_back(label);
155 GtkWidget* remove_button = gtk_chrome_link_button_new( 159 remove_button_ = gtk_chrome_link_button_new(
156 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK).c_str()); 160 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK).c_str());
157 GtkWidget* edit_button = gtk_button_new_with_label( 161 GtkWidget* edit_button = gtk_button_new_with_label(
158 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_OPTIONS).c_str()); 162 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_OPTIONS).c_str());
159 GtkWidget* close_button = gtk_button_new_with_label( 163 GtkWidget* close_button = gtk_button_new_with_label(
160 l10n_util::GetStringUTF8(IDS_CLOSE).c_str()); 164 l10n_util::GetStringUTF8(IDS_CLOSE).c_str());
161 165
162 // Our content is arrange in 3 rows. |top| contains a left justified 166 // Our content is arrange in 3 rows. |top| contains a left justified
163 // message, and a right justified remove link button. |table| is the middle 167 // message, and a right justified remove link button. |table| is the middle
164 // portion with the name entry and the folder combo. |bottom| is the final 168 // portion with the name entry and the folder combo. |bottom| is the final
165 // row with a spacer, and the edit... and close buttons on the right. 169 // row with a spacer, and the edit... and close buttons on the right.
166 GtkWidget* content = gtk_vbox_new(FALSE, 5); 170 GtkWidget* content = gtk_vbox_new(FALSE, 5);
167 GtkWidget* top = gtk_hbox_new(FALSE, 0); 171 GtkWidget* top = gtk_hbox_new(FALSE, 0);
168 172
169 gtk_misc_set_alignment(GTK_MISC(label), 0, 1); 173 gtk_misc_set_alignment(GTK_MISC(label), 0, 1);
170 gtk_box_pack_start(GTK_BOX(top), label, 174 gtk_box_pack_start(GTK_BOX(top), label,
171 TRUE, TRUE, 0); 175 TRUE, TRUE, 0);
172 gtk_box_pack_start(GTK_BOX(top), remove_button, 176 gtk_box_pack_start(GTK_BOX(top), remove_button_,
173 FALSE, FALSE, 0); 177 FALSE, FALSE, 0);
174 178
175 // TODO(deanm): We should show the bookmark bar folder along with the top 179 // TODO(deanm): We should show the bookmark bar folder along with the top
176 // other choices and an entry to go into the bookmark editor. Since we don't 180 // other choices and an entry to go into the bookmark editor. Since we don't
177 // have the editor up yet on Linux, just show the bookmark bar for now. 181 // have the editor up yet on Linux, just show the bookmark bar for now.
178 folder_combo_ = gtk_combo_box_new_text(); 182 folder_combo_ = gtk_combo_box_new_text();
179 folder_nodes_ = PopulateFolderCombo(profile_->GetBookmarkModel(), 183 folder_nodes_ = PopulateFolderCombo(profile_->GetBookmarkModel(),
180 url_, folder_combo_); 184 url_, folder_combo_);
181 185
182 // Create the edit entry for updating the bookmark name / title. 186 // Create the edit entry for updating the bookmark name / title.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 g_signal_connect(content, "destroy", 223 g_signal_connect(content, "destroy",
220 G_CALLBACK(&HandleDestroyThunk), this); 224 G_CALLBACK(&HandleDestroyThunk), this);
221 g_signal_connect(name_entry_, "activate", 225 g_signal_connect(name_entry_, "activate",
222 G_CALLBACK(&HandleNameActivateThunk), this); 226 G_CALLBACK(&HandleNameActivateThunk), this);
223 g_signal_connect(folder_combo_, "changed", 227 g_signal_connect(folder_combo_, "changed",
224 G_CALLBACK(&HandleFolderChangedThunk), this); 228 G_CALLBACK(&HandleFolderChangedThunk), this);
225 g_signal_connect(edit_button, "clicked", 229 g_signal_connect(edit_button, "clicked",
226 G_CALLBACK(&HandleEditButtonThunk), this); 230 G_CALLBACK(&HandleEditButtonThunk), this);
227 g_signal_connect(close_button, "clicked", 231 g_signal_connect(close_button, "clicked",
228 G_CALLBACK(&HandleCloseButtonThunk), this); 232 G_CALLBACK(&HandleCloseButtonThunk), this);
229 g_signal_connect(remove_button, "clicked", 233 g_signal_connect(remove_button_, "clicked",
230 G_CALLBACK(&HandleRemoveButtonThunk), this); 234 G_CALLBACK(&HandleRemoveButtonThunk), this);
231 235
232 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 236 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
233 NotificationService::AllSources()); 237 NotificationService::AllSources());
234 theme_provider_->InitThemesFor(this); 238 theme_provider_->InitThemesFor(this);
235 } 239 }
236 240
237 BookmarkBubbleGtk::~BookmarkBubbleGtk() { 241 BookmarkBubbleGtk::~BookmarkBubbleGtk() {
238 DCHECK(!content_); // |content_| should have already been destroyed. 242 DCHECK(!content_); // |content_| should have already been destroyed.
239 243
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 GtkWidget* toplevel = GTK_WIDGET(transient_toplevel_); 350 GtkWidget* toplevel = GTK_WIDGET(transient_toplevel_);
347 351
348 // Close the bubble, deleting the C++ objects, etc. 352 // Close the bubble, deleting the C++ objects, etc.
349 bubble_->Close(); 353 bubble_->Close();
350 354
351 if (node) { 355 if (node) {
352 BookmarkEditor::Show(toplevel, profile, NULL, node, 356 BookmarkEditor::Show(toplevel, profile, NULL, node,
353 BookmarkEditor::SHOW_TREE, NULL); 357 BookmarkEditor::SHOW_TREE, NULL);
354 } 358 }
355 } 359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698