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/gtk_util.h" | 10 #include "app/gfx/gtk_util.h" |
10 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
11 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "chrome/app/chrome_dll_resource.h" | 16 #include "chrome/app/chrome_dll_resource.h" |
16 #include "chrome/browser/alternate_nav_url_fetcher.h" | 17 #include "chrome/browser/alternate_nav_url_fetcher.h" |
17 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 18 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
18 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 : owner_(owner), | 678 : owner_(owner), |
678 profile_(profile), | 679 profile_(profile), |
679 page_action_(page_action), | 680 page_action_(page_action), |
680 last_icon_skbitmap_(NULL), | 681 last_icon_skbitmap_(NULL), |
681 last_icon_pixbuf_(NULL) { | 682 last_icon_pixbuf_(NULL) { |
682 event_box_.Own(gtk_event_box_new()); | 683 event_box_.Own(gtk_event_box_new()); |
683 // Make the event box not visible so it does not paint a background. | 684 // Make the event box not visible so it does not paint a background. |
684 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 685 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
685 g_signal_connect(event_box_.get(), "button-press-event", | 686 g_signal_connect(event_box_.get(), "button-press-event", |
686 G_CALLBACK(&OnButtonPressed), this); | 687 G_CALLBACK(&OnButtonPressed), this); |
| 688 g_signal_connect_after(event_box_.get(), "expose-event", |
| 689 G_CALLBACK(OnExposeEvent), this); |
687 | 690 |
688 image_.Own(gtk_image_new()); | 691 image_.Own(gtk_image_new()); |
689 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); | 692 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); |
690 | 693 |
691 Extension* extension = profile->GetExtensionsService()->GetExtensionById( | 694 Extension* extension = profile->GetExtensionsService()->GetExtensionById( |
692 page_action->extension_id()); | 695 page_action->extension_id()); |
693 DCHECK(extension); | 696 DCHECK(extension); |
694 | 697 |
695 DCHECK(!page_action->icon_paths().empty()); | 698 DCHECK(!page_action->icon_paths().empty()); |
696 const std::vector<std::string>& icon_paths = page_action->icon_paths(); | 699 const std::vector<std::string>& icon_paths = page_action->icon_paths(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 LocationBarViewGtk::PageActionViewGtk* page_action_view) { | 789 LocationBarViewGtk::PageActionViewGtk* page_action_view) { |
787 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 790 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( |
788 page_action_view->profile_, | 791 page_action_view->profile_, |
789 page_action_view->page_action_->extension_id(), | 792 page_action_view->page_action_->extension_id(), |
790 page_action_view->page_action_->id(), | 793 page_action_view->page_action_->id(), |
791 page_action_view->current_tab_id_, | 794 page_action_view->current_tab_id_, |
792 page_action_view->current_url_.spec(), | 795 page_action_view->current_url_.spec(), |
793 event->button); | 796 event->button); |
794 return true; | 797 return true; |
795 } | 798 } |
| 799 |
| 800 // static |
| 801 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( |
| 802 GtkWidget* widget, GdkEventExpose* event, PageActionViewGtk* view) { |
| 803 TabContents* contents = view->owner_->browser_->GetSelectedTabContents(); |
| 804 if (!contents) |
| 805 return FALSE; |
| 806 const ExtensionActionState* state = |
| 807 contents->GetPageActionState(view->page_action_); |
| 808 if (!state || state->badge_text().empty()) |
| 809 return FALSE; |
| 810 |
| 811 gfx::CanvasPaint canvas(event, false); |
| 812 gfx::Rect bounding_rect(widget->allocation); |
| 813 state->PaintBadge(&canvas, bounding_rect); |
| 814 return FALSE; |
| 815 } |
OLD | NEW |