Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / gtk / content_setting_bubble_gtk.h
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
8 #include <map>
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
13 #include "chrome/browser/ui/gtk/menu_gtk.h"
14 #include "chrome/common/content_settings_types.h"
15 #include "content/public/common/media_stream_request.h"
16 #include "ui/base/gtk/gtk_signal.h"
17 #include "ui/base/gtk/owned_widget_gtk.h"
18
19 class ContentSettingBubbleModel;
20 class ContentSettingMediaMenuModel;
21 class Profile;
22
23 namespace ui {
24 class SimpleMenuModel;
25 }
26
27 // ContentSettingBubbleGtk is used when the user turns on different kinds of
28 // content blocking (e.g. "block images"). An icon appears in the location bar,
29 // and when clicked, an instance of this class is created specialized for the
30 // type of content being blocked.
31 class ContentSettingBubbleGtk : public BubbleDelegateGtk {
32  public:
33    ContentSettingBubbleGtk(
34        GtkWidget* anchor,
35        BubbleDelegateGtk* delegate,
36        ContentSettingBubbleModel* content_setting_bubble_model,
37        Profile* profile);
38   virtual ~ContentSettingBubbleGtk();
39
40   // Callback to allow ContentSettingMediaMenuModel to update the menu label.
41   void UpdateMenuLabel(content::MediaStreamType type,
42                        const std::string& label);
43
44   // Dismisses the bubble.
45   void Close();
46
47  private:
48   // A map from a GtkWidget* to a MediaMenuGtk*. MediaMenuGtk struct is used
49   // to store the UI members that a media menu owns.
50   struct MediaMenuGtk {
51     explicit MediaMenuGtk(content::MediaStreamType type);
52     ~MediaMenuGtk();
53
54     content::MediaStreamType type;
55     scoped_ptr<ui::SimpleMenuModel> menu_model;
56     scoped_ptr<MenuGtk> menu;
57     ui::OwnedWidgetGtk label;
58
59    private:
60     DISALLOW_COPY_AND_ASSIGN(MediaMenuGtk);
61   };
62   typedef std::map<GtkWidget*, MediaMenuGtk*> GtkMediaMenuMap;
63
64   typedef std::map<GtkWidget*, int> PopupMap;
65
66   // BubbleDelegateGtk:
67   virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
68
69   // Builds the bubble and all the widgets that it displays.
70   void BuildBubble();
71
72   // Widget callback methods.
73   CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress,
74                        GdkEventButton*);
75   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked);
76   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled);
77   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked);
78   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked);
79   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked);
80   CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnMenuButtonClicked);
81
82   // We position the bubble near this widget.
83   GtkWidget* anchor_;
84
85   // The active profile.
86   Profile* profile_;
87
88   // Pass on delegate messages to this.
89   BubbleDelegateGtk* delegate_;
90
91   // Provides data for this bubble.
92   scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
93
94   // The bubble.
95   BubbleGtk* bubble_;
96
97   // Stored controls so we can figure out what was clicked.
98   PopupMap popup_links_;
99   PopupMap popup_icons_;
100
101   typedef std::vector<GtkWidget*> RadioGroupGtk;
102   RadioGroupGtk radio_group_gtk_;
103
104   GtkMediaMenuMap media_menus_;
105 };
106
107 #endif  // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_