| 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 |
| 412 // Initialize on the first call, or re-inialize if more extensions have been | 421 // Initialize on the first call, or re-inialize if more extensions have been |
| 413 // loaded or added after startup. | 422 // loaded or added after startup. |
| 414 if (page_actions.size() != page_action_views_.size()) { | 423 if (page_actions.size() != page_action_views_.size()) { |
| 415 page_action_views_.reset(); // Delete the old views (if any). | 424 page_action_views_.reset(); // Delete the old views (if any). |
| 416 | 425 |
| 417 for (size_t i = 0; i < page_actions.size(); ++i) { | 426 for (size_t i = 0; i < page_actions.size(); ++i) { |
| 418 page_action_views_.push_back( | 427 page_action_views_.push_back( |
| 419 new PageActionViewGtk(this, profile_, page_actions[i])); | 428 new PageActionViewGtk(this, profile_, page_actions[i])); |
| 420 gtk_box_pack_end(GTK_BOX(page_action_hbox_), | 429 gtk_box_pack_end(GTK_BOX(page_action_hbox_), |
| 421 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 430 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 const ExtensionActionState* state = | 820 const ExtensionActionState* state = |
| 812 contents->GetPageActionState(view->page_action_); | 821 contents->GetPageActionState(view->page_action_); |
| 813 if (!state || state->badge_text().empty()) | 822 if (!state || state->badge_text().empty()) |
| 814 return FALSE; | 823 return FALSE; |
| 815 | 824 |
| 816 gfx::CanvasPaint canvas(event, false); | 825 gfx::CanvasPaint canvas(event, false); |
| 817 gfx::Rect bounding_rect(widget->allocation); | 826 gfx::Rect bounding_rect(widget->allocation); |
| 818 state->PaintBadge(&canvas, bounding_rect); | 827 state->PaintBadge(&canvas, bounding_rect); |
| 819 return FALSE; | 828 return FALSE; |
| 820 } | 829 } |
| OLD | NEW |