Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: chrome/browser/ui/gtk/content_setting_bubble_gtk.h

Issue 12208010: Adding device selection menus to the content setting bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed the windows code. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
13 #include "chrome/browser/ui/gtk/menu_gtk.h"
13 #include "chrome/common/content_settings_types.h" 14 #include "chrome/common/content_settings_types.h"
14 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/common/media_stream_request.h"
16 #include "ui/base/gtk/gtk_signal.h" 18 #include "ui/base/gtk/gtk_signal.h"
19 #include "ui/base/gtk/owned_widget_gtk.h"
17 20
18 class ContentSettingBubbleModel; 21 class ContentSettingBubbleModel;
22 class ContentSettingMediaMenuModel;
19 class Profile; 23 class Profile;
20 24
21 namespace content { 25 namespace content {
22 class WebContents; 26 class WebContents;
23 } 27 }
24 28
29 namespace ui {
30 class SimpleMenuModel;
31 }
32
Evan Stade 2013/02/06 22:07:07 ^H
no longer working on chromium 2013/02/07 16:25:19 Done.
33
25 // ContentSettingBubbleGtk is used when the user turns on different kinds of 34 // ContentSettingBubbleGtk is used when the user turns on different kinds of
26 // content blocking (e.g. "block images"). An icon appears in the location bar, 35 // content blocking (e.g. "block images"). An icon appears in the location bar,
27 // and when clicked, an instance of this class is created specialized for the 36 // and when clicked, an instance of this class is created specialized for the
28 // type of content being blocked. 37 // type of content being blocked.
29 class ContentSettingBubbleGtk : public BubbleDelegateGtk, 38 class ContentSettingBubbleGtk : public BubbleDelegateGtk,
30 public content::NotificationObserver { 39 public content::NotificationObserver {
31 public: 40 public:
32 ContentSettingBubbleGtk( 41 ContentSettingBubbleGtk(
33 GtkWidget* anchor, 42 GtkWidget* anchor,
34 BubbleDelegateGtk* delegate, 43 BubbleDelegateGtk* delegate,
35 ContentSettingBubbleModel* content_setting_bubble_model, 44 ContentSettingBubbleModel* content_setting_bubble_model,
36 Profile* profile, content::WebContents* web_contents); 45 Profile* profile, content::WebContents* web_contents);
37 virtual ~ContentSettingBubbleGtk(); 46 virtual ~ContentSettingBubbleGtk();
38 47
48 // Callback to allow ContentSettingMediaMenuModel to update the menu label.
49 void UpdateMenuLabel(content::MediaStreamType type,
50 const std::string& label) OVERRIDE;
51
39 // Dismisses the bubble. 52 // Dismisses the bubble.
40 void Close(); 53 void Close();
41 54
42 private: 55 private:
56 // A map from a GtkWidget* to a MediaMenuGtk*. MediaMenuGtk struct is used
57 // to store the UI members that a media menu owns.
58 struct MediaMenuGtk {
59 MediaMenuGtk(content::MediaStreamType type);
60 ~MediaMenuGtk();
61
62 content::MediaStreamType type;
63 scoped_ptr<ui::SimpleMenuModel> menu_model;
64 scoped_ptr<MenuGtk> menu;
65 ui::OwnedWidgetGtk label;
66
67 private:
68 DISALLOW_COPY_AND_ASSIGN(MediaMenuGtk);
69 };
70 typedef std::map<GtkWidget*, MediaMenuGtk*> GtkMediaMenuMap;
71
43 typedef std::map<GtkWidget*, int> PopupMap; 72 typedef std::map<GtkWidget*, int> PopupMap;
44 73
45 // BubbleDelegateGtk: 74 // BubbleDelegateGtk:
46 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; 75 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
47 76
48 // content::NotificationObserver: 77 // content::NotificationObserver:
49 virtual void Observe(int type, 78 virtual void Observe(int type,
50 const content::NotificationSource& source, 79 const content::NotificationSource& source,
51 const content::NotificationDetails& details) OVERRIDE; 80 const content::NotificationDetails& details) OVERRIDE;
52 81
53 // Builds the bubble and all the widgets that it displays. 82 // Builds the bubble and all the widgets that it displays.
54 void BuildBubble(); 83 void BuildBubble();
55 84
56 // Widget callback methods. 85 // Widget callback methods.
57 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress, 86 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress,
58 GdkEventButton*); 87 GdkEventButton*);
59 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked); 88 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked);
60 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled); 89 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled);
61 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked); 90 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked);
62 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); 91 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked);
63 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); 92 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked);
93 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnMenuButtonClicked);
64 94
65 // We position the bubble near this widget. 95 // We position the bubble near this widget.
66 GtkWidget* anchor_; 96 GtkWidget* anchor_;
67 97
68 // The active profile. 98 // The active profile.
69 Profile* profile_; 99 Profile* profile_;
70 100
71 // The active web contents. 101 // The active web contents.
72 content::WebContents* web_contents_; 102 content::WebContents* web_contents_;
73 103
74 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. 104 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications.
75 content::NotificationRegistrar registrar_; 105 content::NotificationRegistrar registrar_;
76 106
77 // Pass on delegate messages to this. 107 // Pass on delegate messages to this.
78 BubbleDelegateGtk* delegate_; 108 BubbleDelegateGtk* delegate_;
79 109
80 // Provides data for this bubble. 110 // Provides data for this bubble.
81 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; 111 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
82 112
83 // The bubble. 113 // The bubble.
84 BubbleGtk* bubble_; 114 BubbleGtk* bubble_;
85 115
86 // Stored controls so we can figure out what was clicked. 116 // Stored controls so we can figure out what was clicked.
87 PopupMap popup_links_; 117 PopupMap popup_links_;
88 PopupMap popup_icons_; 118 PopupMap popup_icons_;
89 119
90 typedef std::vector<GtkWidget*> RadioGroupGtk; 120 typedef std::vector<GtkWidget*> RadioGroupGtk;
91 RadioGroupGtk radio_group_gtk_; 121 RadioGroupGtk radio_group_gtk_;
122
123 GtkMediaMenuMap media_menus_;
92 }; 124 };
93 125
94 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ 126 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698