Home | History | Annotate | Download | only in gtk
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
      6 #define CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
      7 #pragma once
      8 
      9 #include <map>
     10 
     11 #include "base/memory/scoped_ptr.h"
     12 #include "chrome/browser/ui/gtk/info_bubble_gtk.h"
     13 #include "chrome/common/content_settings_types.h"
     14 #include "content/common/notification_observer.h"
     15 #include "content/common/notification_registrar.h"
     16 #include "ui/base/gtk/gtk_signal.h"
     17 
     18 class ContentSettingBubbleModel;
     19 class Profile;
     20 class TabContents;
     21 
     22 // ContentSettingBubbleGtk is used when the user turns on different kinds of
     23 // content blocking (e.g. "block images"). An icon appears in the location bar,
     24 // and when clicked, an instance of this class is created specialized for the
     25 // type of content being blocked.
     26 class ContentSettingBubbleGtk : public InfoBubbleGtkDelegate,
     27                                 public NotificationObserver {
     28  public:
     29    ContentSettingBubbleGtk(
     30        GtkWidget* anchor,
     31        InfoBubbleGtkDelegate* delegate,
     32        ContentSettingBubbleModel* content_setting_bubble_model,
     33        Profile* profile, TabContents* tab_contents);
     34   virtual ~ContentSettingBubbleGtk();
     35 
     36   // Dismisses the infobubble.
     37   void Close();
     38 
     39  private:
     40   typedef std::map<GtkWidget*, int> PopupMap;
     41 
     42   // InfoBubbleGtkDelegate:
     43   virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble,
     44                                  bool closed_by_escape);
     45 
     46   // NotificationObserver:
     47   virtual void Observe(NotificationType type,
     48                        const NotificationSource& source,
     49                        const NotificationDetails& details);
     50 
     51   // Builds the info bubble and all the widgets that it displays.
     52   void BuildBubble();
     53 
     54   // Widget callback methods.
     55   CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress,
     56                        GdkEventButton*);
     57   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked);
     58   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled);
     59   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked);
     60   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked);
     61   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked);
     62 
     63   // We position the bubble near this widget.
     64   GtkWidget* anchor_;
     65 
     66   // The active profile.
     67   Profile* profile_;
     68 
     69   // The active tab contents.
     70   TabContents* tab_contents_;
     71 
     72   // A registrar for listening for TAB_CONTENTS_DESTROYED notifications.
     73   NotificationRegistrar registrar_;
     74 
     75   // Pass on delegate messages to this.
     76   InfoBubbleGtkDelegate* delegate_;
     77 
     78   // Provides data for this bubble.
     79   scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
     80 
     81   // The info bubble.
     82   InfoBubbleGtk* info_bubble_;
     83 
     84   // Stored controls so we can figure out what was clicked.
     85   PopupMap popup_links_;
     86   PopupMap popup_icons_;
     87 
     88   typedef std::vector<GtkWidget*> RadioGroupGtk;
     89   RadioGroupGtk radio_group_gtk_;
     90 };
     91 
     92 #endif  // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
     93