| OLD | NEW |
| 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "app/gfx/gtk_util.h" | 10 #include "app/gfx/gtk_util.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 void LocationBarViewGtk::FocusSearch() { | 402 void LocationBarViewGtk::FocusSearch() { |
| 403 location_entry_->SetFocus(); | 403 location_entry_->SetFocus(); |
| 404 location_entry_->SetForcedQuery(); | 404 location_entry_->SetForcedQuery(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void LocationBarViewGtk::UpdatePageActions() { | 407 void LocationBarViewGtk::UpdatePageActions() { |
| 408 std::vector<ExtensionAction*> page_actions; | 408 std::vector<ExtensionAction*> page_actions; |
| 409 if (profile_->GetExtensionsService()) | 409 if (profile_->GetExtensionsService()) |
| 410 page_actions = profile_->GetExtensionsService()->GetPageActions(); | 410 page_actions = profile_->GetExtensionsService()->GetPageActions(); |
| 411 | 411 |
| 412 // Page actions can be created without an icon, so make sure we count only | |
| 413 // those that have been given an icon. | |
| 414 for (size_t i = 0; i < page_actions.size();) { | |
| 415 if (page_actions[i]->icon_paths().empty()) | |
| 416 page_actions.erase(page_actions.begin() + i); | |
| 417 else | |
| 418 ++i; | |
| 419 } | |
| 420 | |
| 421 // Initialize on the first call, or re-inialize if more extensions have been | 412 // Initialize on the first call, or re-inialize if more extensions have been |
| 422 // loaded or added after startup. | 413 // loaded or added after startup. |
| 423 if (page_actions.size() != page_action_views_.size()) { | 414 if (page_actions.size() != page_action_views_.size()) { |
| 424 page_action_views_.reset(); // Delete the old views (if any). | 415 page_action_views_.reset(); // Delete the old views (if any). |
| 425 | 416 |
| 426 for (size_t i = 0; i < page_actions.size(); ++i) { | 417 for (size_t i = 0; i < page_actions.size(); ++i) { |
| 427 page_action_views_.push_back( | 418 page_action_views_.push_back( |
| 428 new PageActionViewGtk(this, profile_, page_actions[i])); | 419 new PageActionViewGtk(this, profile_, page_actions[i])); |
| 429 gtk_box_pack_end(GTK_BOX(page_action_hbox_), | 420 gtk_box_pack_end(GTK_BOX(page_action_hbox_), |
| 430 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 421 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 const ExtensionActionState* state = | 811 const ExtensionActionState* state = |
| 821 contents->GetPageActionState(view->page_action_); | 812 contents->GetPageActionState(view->page_action_); |
| 822 if (!state || state->badge_text().empty()) | 813 if (!state || state->badge_text().empty()) |
| 823 return FALSE; | 814 return FALSE; |
| 824 | 815 |
| 825 gfx::CanvasPaint canvas(event, false); | 816 gfx::CanvasPaint canvas(event, false); |
| 826 gfx::Rect bounding_rect(widget->allocation); | 817 gfx::Rect bounding_rect(widget->allocation); |
| 827 state->PaintBadge(&canvas, bounding_rect); | 818 state->PaintBadge(&canvas, bounding_rect); |
| 828 return FALSE; | 819 return FALSE; |
| 829 } | 820 } |
| OLD | NEW |