| Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| index 52f93cbec2ece813345b95b25c1d0ac8cef0aa45..3be11c105e74206d1021b818d55da39b64a82a29 100644
|
| --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| @@ -30,6 +30,7 @@
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| #include "chrome/browser/extensions/location_bar_controller.h"
|
| +#include "chrome/browser/extensions/script_bubble_controller.h"
|
| #include "chrome/browser/extensions/tab_helper.h"
|
| #include "chrome/browser/favicon/favicon_tab_helper.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| @@ -59,6 +60,7 @@
|
| #include "chrome/browser/ui/gtk/nine_box.h"
|
| #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h"
|
| #include "chrome/browser/ui/gtk/rounded_window.h"
|
| +#include "chrome/browser/ui/gtk/script_bubble_gtk.h"
|
| #include "chrome/browser/ui/gtk/view_id_util.h"
|
| #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h"
|
| #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
|
| @@ -67,6 +69,7 @@
|
| #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
|
| #include "chrome/browser/ui/webui/extensions/extension_info_ui.h"
|
| #include "chrome/browser/ui/zoom/zoom_controller.h"
|
| +#include "chrome/common/badge_util.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/extension.h"
|
| @@ -387,6 +390,8 @@ const GdkColor LocationBarViewGtk::kBackgroundColor =
|
|
|
| LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
|
| : zoom_image_(NULL),
|
| + script_bubble_button_image_(NULL),
|
| + num_running_scripts_(0u),
|
| star_image_(NULL),
|
| starred_(false),
|
| star_sized_(false),
|
| @@ -424,6 +429,7 @@ LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
|
| LocationBarViewGtk::~LocationBarViewGtk() {
|
| // All of our widgets should be children of / owned by the alignment.
|
| zoom_.Destroy();
|
| + script_bubble_button_.Destroy();
|
| star_.Destroy();
|
| hbox_.Destroy();
|
| content_setting_hbox_.Destroy();
|
| @@ -565,6 +571,10 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
|
| gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0);
|
| }
|
|
|
| + CreateScriptBubbleButton();
|
| + gtk_box_pack_end(GTK_BOX(hbox_.get()), script_bubble_button_.get(), FALSE,
|
| + FALSE, 0);
|
| +
|
| CreateZoomButton();
|
| gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0);
|
|
|
| @@ -725,6 +735,7 @@ GtkWidget* LocationBarViewGtk::GetPageActionWidget(
|
|
|
| void LocationBarViewGtk::Update(const WebContents* contents) {
|
| UpdateZoomIcon();
|
| + UpdateScriptBubbleIcon();
|
| UpdateStarIcon();
|
| UpdateSiteTypeArea();
|
| UpdateContentSettingsIcons();
|
| @@ -839,6 +850,19 @@ void LocationBarViewGtk::CreateZoomButton() {
|
| OnZoomButtonPressThunk));
|
| }
|
|
|
| +void LocationBarViewGtk::CreateScriptBubbleButton() {
|
| + script_bubble_button_.Own(CreateIconButton(&script_bubble_button_image_,
|
| + 0,
|
| + VIEW_ID_SCRIPT_BUBBLE,
|
| + IDS_TOOLTIP_SCRIPT_BUBBLE,
|
| + OnScriptBubbleButtonPressThunk));
|
| + gtk_image_set_from_pixbuf(
|
| + GTK_IMAGE(script_bubble_button_image_),
|
| + theme_service_->GetImageNamed(IDR_EXTENSIONS_FAVICON).ToGdkPixbuf());
|
| + g_signal_connect_after(script_bubble_button_image_, "expose-event",
|
| + G_CALLBACK(&OnScriptBubbleButtonExposeThunk), this);
|
| +}
|
| +
|
| void LocationBarViewGtk::CreateStarButton() {
|
| star_.Own(CreateIconButton(&star_image_,
|
| 0,
|
| @@ -950,6 +974,8 @@ void LocationBarViewGtk::UpdateContentSettingsIcons() {
|
| }
|
|
|
| void LocationBarViewGtk::UpdatePageActions() {
|
| + UpdateScriptBubbleIcon();
|
| +
|
| std::vector<ExtensionAction*> new_page_actions;
|
|
|
| WebContents* contents = GetWebContents();
|
| @@ -1148,6 +1174,7 @@ void LocationBarViewGtk::Observe(int type,
|
| }
|
|
|
| UpdateZoomIcon();
|
| + UpdateScriptBubbleIcon();
|
| UpdateStarIcon();
|
| UpdateSiteTypeArea();
|
| UpdateContentSettingsIcons();
|
| @@ -1500,6 +1527,30 @@ gboolean LocationBarViewGtk::OnZoomButtonPress(GtkWidget* widget,
|
| return FALSE;
|
| }
|
|
|
| +gboolean LocationBarViewGtk::OnScriptBubbleButtonPress(GtkWidget* widget,
|
| + GdkEventButton* event) {
|
| + if (event->button == 1 && GetWebContents()) {
|
| + ScriptBubbleGtk::Show(script_bubble_button_image_, GetWebContents());
|
| + return TRUE;
|
| + }
|
| + return FALSE;
|
| +}
|
| +
|
| +gboolean LocationBarViewGtk::OnScriptBubbleButtonExpose(GtkWidget* widget,
|
| + GdkEventExpose* event) {
|
| + gfx::CanvasSkiaPaint canvas(event, false);
|
| + GtkAllocation allocation;
|
| + gtk_widget_get_allocation(widget, &allocation);
|
| + badge_util::PaintBadge(&canvas,
|
| + gfx::Rect(allocation),
|
| + base::UintToString(num_running_scripts_),
|
| + SK_ColorWHITE,
|
| + SkColorSetRGB(0, 170, 0),
|
| + allocation.width,
|
| + Extension::ActionInfo::TYPE_PAGE);
|
| + return FALSE;
|
| +}
|
| +
|
| void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender,
|
| GtkAllocation* allocation) {
|
| if (!on_star_sized_.is_null()) {
|
| @@ -1584,6 +1635,23 @@ void LocationBarViewGtk::UpdateZoomIcon() {
|
| gtk_widget_show(zoom_.get());
|
| }
|
|
|
| +void LocationBarViewGtk::UpdateScriptBubbleIcon() {
|
| + num_running_scripts_ = 0;
|
| + if (GetWebContents()) {
|
| + extensions::TabHelper* tab_helper =
|
| + extensions::TabHelper::FromWebContents(GetWebContents());
|
| + if (tab_helper && tab_helper->script_bubble_controller()) {
|
| + num_running_scripts_ = tab_helper->script_bubble_controller()->
|
| + extensions_running_scripts().size();
|
| + }
|
| + }
|
| +
|
| + if (num_running_scripts_ == 0u)
|
| + gtk_widget_hide(script_bubble_button_.get());
|
| + else
|
| + gtk_widget_show(script_bubble_button_.get());
|
| +}
|
| +
|
| void LocationBarViewGtk::UpdateStarIcon() {
|
| if (!star_.get())
|
| return;
|
|
|