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" | |
10 #include "app/gfx/gtk_util.h" | 9 #include "app/gfx/gtk_util.h" |
11 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
12 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
13 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/string_util.h" | 14 #include "base/string_util.h" |
16 #include "chrome/app/chrome_dll_resource.h" | 15 #include "chrome/app/chrome_dll_resource.h" |
17 #include "chrome/browser/alternate_nav_url_fetcher.h" | 16 #include "chrome/browser/alternate_nav_url_fetcher.h" |
18 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 17 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
19 #include "chrome/browser/browser.h" | 18 #include "chrome/browser/browser.h" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 : owner_(owner), | 677 : owner_(owner), |
679 profile_(profile), | 678 profile_(profile), |
680 page_action_(page_action), | 679 page_action_(page_action), |
681 last_icon_skbitmap_(NULL), | 680 last_icon_skbitmap_(NULL), |
682 last_icon_pixbuf_(NULL) { | 681 last_icon_pixbuf_(NULL) { |
683 event_box_.Own(gtk_event_box_new()); | 682 event_box_.Own(gtk_event_box_new()); |
684 // Make the event box not visible so it does not paint a background. | 683 // Make the event box not visible so it does not paint a background. |
685 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 684 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
686 g_signal_connect(event_box_.get(), "button-press-event", | 685 g_signal_connect(event_box_.get(), "button-press-event", |
687 G_CALLBACK(&OnButtonPressed), this); | 686 G_CALLBACK(&OnButtonPressed), this); |
688 g_signal_connect_after(event_box_.get(), "expose-event", | |
689 G_CALLBACK(OnExposeEvent), this); | |
690 | 687 |
691 image_.Own(gtk_image_new()); | 688 image_.Own(gtk_image_new()); |
692 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); | 689 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); |
693 | 690 |
694 Extension* extension = profile->GetExtensionsService()->GetExtensionById( | 691 Extension* extension = profile->GetExtensionsService()->GetExtensionById( |
695 page_action->extension_id()); | 692 page_action->extension_id()); |
696 DCHECK(extension); | 693 DCHECK(extension); |
697 | 694 |
698 DCHECK(!page_action->icon_paths().empty()); | 695 DCHECK(!page_action->icon_paths().empty()); |
699 const std::vector<std::string>& icon_paths = page_action->icon_paths(); | 696 const std::vector<std::string>& icon_paths = page_action->icon_paths(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 LocationBarViewGtk::PageActionViewGtk* page_action_view) { | 786 LocationBarViewGtk::PageActionViewGtk* page_action_view) { |
790 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 787 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( |
791 page_action_view->profile_, | 788 page_action_view->profile_, |
792 page_action_view->page_action_->extension_id(), | 789 page_action_view->page_action_->extension_id(), |
793 page_action_view->page_action_->id(), | 790 page_action_view->page_action_->id(), |
794 page_action_view->current_tab_id_, | 791 page_action_view->current_tab_id_, |
795 page_action_view->current_url_.spec(), | 792 page_action_view->current_url_.spec(), |
796 event->button); | 793 event->button); |
797 return true; | 794 return true; |
798 } | 795 } |
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 |