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

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

Issue 274083: Gtk/extensions: Convert a crash into a NOTREACHED(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: compile fix, 2 Created 11 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser_actions_toolbar_gtk.h" 5 #include "chrome/browser/gtk/browser_actions_toolbar_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/gfx/canvas_paint.h" 10 #include "app/gfx/canvas_paint.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ExtensionsService* extension_service = profile_->GetExtensionsService(); 190 ExtensionsService* extension_service = profile_->GetExtensionsService();
191 if (!extension_service) // The |extension_service| can be NULL in Incognito. 191 if (!extension_service) // The |extension_service| can be NULL in Incognito.
192 return; 192 return;
193 193
194 // Get all browser actions, including those with popups. 194 // Get all browser actions, including those with popups.
195 std::vector<ExtensionAction*> browser_actions = 195 std::vector<ExtensionAction*> browser_actions =
196 extension_service->GetBrowserActions(true); 196 extension_service->GetBrowserActions(true);
197 197
198 for (size_t i = 0; i < browser_actions.size(); ++i) { 198 for (size_t i = 0; i < browser_actions.size(); ++i) {
199 Extension* extension = extension_service->GetExtensionById( 199 Extension* extension = extension_service->GetExtensionById(
200 browser_actions[i]->id()); 200 browser_actions[i]->extension_id());
201 CreateButtonForExtension(extension); 201 CreateButtonForExtension(extension);
202 } 202 }
203 } 203 }
204 204
205 void BrowserActionsToolbarGtk::CreateButtonForExtension(Extension* extension) { 205 void BrowserActionsToolbarGtk::CreateButtonForExtension(Extension* extension) {
206 // Only show extensions with browser actions and that have an icon. 206 // Only show extensions with browser actions and that have an icon.
207 if (!extension->browser_action() || 207 if (!extension->browser_action() ||
208 extension->browser_action()->icon_paths().empty()) { 208 extension->browser_action()->icon_paths().empty()) {
209 return; 209 return;
210 } 210 }
211 211
212 RemoveButtonForExtension(extension); 212 RemoveButtonForExtension(extension);
213 linked_ptr<BrowserActionButton> button( 213 linked_ptr<BrowserActionButton> button(
214 new BrowserActionButton(browser_, extension)); 214 new BrowserActionButton(browser_, extension));
215 gtk_box_pack_end(GTK_BOX(hbox_.get()), button->widget(), FALSE, FALSE, 0); 215 gtk_box_pack_end(GTK_BOX(hbox_.get()), button->widget(), FALSE, FALSE, 0);
216 gtk_widget_show(button->widget()); 216 gtk_widget_show(button->widget());
217 extension_button_map_[extension->id()] = button; 217 extension_button_map_[extension->extension_id()] = button;
218 218
219 UpdateVisibility(); 219 UpdateVisibility();
220 } 220 }
221 221
222 void BrowserActionsToolbarGtk::RemoveButtonForExtension(Extension* extension) { 222 void BrowserActionsToolbarGtk::RemoveButtonForExtension(Extension* extension) {
223 if (extension_button_map_.erase(extension->id())) 223 if (extension_button_map_.erase(extension->extension_id()))
224 UpdateVisibility(); 224 UpdateVisibility();
225 } 225 }
226 226
227 void BrowserActionsToolbarGtk::UpdateVisibility() { 227 void BrowserActionsToolbarGtk::UpdateVisibility() {
228 if (button_count() == 0) 228 if (button_count() == 0)
229 gtk_widget_hide(widget()); 229 gtk_widget_hide(widget());
230 else 230 else
231 gtk_widget_show(widget()); 231 gtk_widget_show(widget());
232 } 232 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698