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.
5 #ifndef CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
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"
19 class ContentSettingBubbleModel
;
20 class ContentSettingMediaMenuModel
;
24 class SimpleMenuModel
;
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
{
33 ContentSettingBubbleGtk(
35 BubbleDelegateGtk
* delegate
,
36 ContentSettingBubbleModel
* content_setting_bubble_model
,
38 virtual ~ContentSettingBubbleGtk();
40 // Callback to allow ContentSettingMediaMenuModel to update the menu label.
41 void UpdateMenuLabel(content::MediaStreamType type
,
42 const std::string
& label
);
44 // Dismisses the bubble.
48 // A map from a GtkWidget* to a MediaMenuGtk*. MediaMenuGtk struct is used
49 // to store the UI members that a media menu owns.
51 explicit MediaMenuGtk(content::MediaStreamType type
);
54 content::MediaStreamType type
;
55 scoped_ptr
<ui::SimpleMenuModel
> menu_model
;
56 scoped_ptr
<MenuGtk
> menu
;
57 ui::OwnedWidgetGtk label
;
60 DISALLOW_COPY_AND_ASSIGN(MediaMenuGtk
);
62 typedef std::map
<GtkWidget
*, MediaMenuGtk
*> GtkMediaMenuMap
;
64 typedef std::map
<GtkWidget
*, int> PopupMap
;
67 virtual void BubbleClosing(BubbleGtk
* bubble
, bool closed_by_escape
) OVERRIDE
;
69 // Builds the bubble and all the widgets that it displays.
72 // Widget callback methods.
73 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk
, void, OnPopupIconButtonPress
,
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
);
82 // We position the bubble near this widget.
85 // The active profile.
88 // Pass on delegate messages to this.
89 BubbleDelegateGtk
* delegate_
;
91 // Provides data for this bubble.
92 scoped_ptr
<ContentSettingBubbleModel
> content_setting_bubble_model_
;
97 // Stored controls so we can figure out what was clicked.
98 PopupMap popup_links_
;
99 PopupMap popup_icons_
;
101 typedef std::vector
<GtkWidget
*> RadioGroupGtk
;
102 RadioGroupGtk radio_group_gtk_
;
104 GtkMediaMenuMap media_menus_
;
107 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_