Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/content_settings/content_setting_media_menu_model.h" | |
| 12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 13 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 14 #include "chrome/browser/ui/gtk/menu_gtk.h" | |
| 13 #include "chrome/common/content_settings_types.h" | 15 #include "chrome/common/content_settings_types.h" |
| 14 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/common/media_stream_request.h" | |
| 16 #include "ui/base/gtk/gtk_signal.h" | 19 #include "ui/base/gtk/gtk_signal.h" |
| 20 #include "ui/base/gtk/owned_widget_gtk.h" | |
| 17 | 21 |
| 18 class ContentSettingBubbleModel; | 22 class ContentSettingBubbleModel; |
| 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 | |
| 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, |
| 40 public ContentSettingMediaMenuModel::Observer { | |
| 31 public: | 41 public: |
| 32 ContentSettingBubbleGtk( | 42 ContentSettingBubbleGtk( |
| 33 GtkWidget* anchor, | 43 GtkWidget* anchor, |
| 34 BubbleDelegateGtk* delegate, | 44 BubbleDelegateGtk* delegate, |
| 35 ContentSettingBubbleModel* content_setting_bubble_model, | 45 ContentSettingBubbleModel* content_setting_bubble_model, |
| 36 Profile* profile, content::WebContents* web_contents); | 46 Profile* profile, content::WebContents* web_contents); |
| 37 virtual ~ContentSettingBubbleGtk(); | 47 virtual ~ContentSettingBubbleGtk(); |
| 38 | 48 |
| 49 // ContentSettingMediaMenuModel::Observer implementation. | |
| 50 virtual void UpdateMenuLabel(content::MediaStreamType type, | |
| 51 const std::string& label) OVERRIDE; | |
| 52 | |
| 39 // Dismisses the bubble. | 53 // Dismisses the bubble. |
| 40 void Close(); | 54 void Close(); |
| 41 | 55 |
| 42 private: | 56 private: |
| 57 // A map from a GtkWidget* to a MediaMenuGtk*. MediaMenuGtk struct is used | |
|
markusheintz_
2013/02/06 11:03:26
See my comment in the views code.
| |
| 58 // to store the UI members that a media menu owns. | |
| 59 struct MediaMenuGtk { | |
|
markusheintz_
2013/02/06 11:03:26
Now I see we you named the equivalent in the views
no longer working on chromium
2013/02/06 13:31:52
Thanks, MediaMenu has been used by the content_set
markusheintz_
2013/02/06 14:43:19
SGTM
| |
| 60 MediaMenuGtk(); | |
| 61 ~MediaMenuGtk(); | |
| 62 | |
| 63 content::MediaStreamType type; | |
| 64 scoped_ptr<ui::SimpleMenuModel> menu_model; | |
| 65 scoped_ptr<MenuGtk> menu; | |
| 66 ui::OwnedWidgetGtk label; | |
| 67 | |
| 68 private: | |
| 69 DISALLOW_COPY_AND_ASSIGN(MediaMenuGtk); | |
| 70 }; | |
| 71 typedef std::map<GtkWidget*, MediaMenuGtk*> GtkMediaMenuMap; | |
| 72 | |
| 43 typedef std::map<GtkWidget*, int> PopupMap; | 73 typedef std::map<GtkWidget*, int> PopupMap; |
| 44 | 74 |
| 45 // BubbleDelegateGtk: | 75 // BubbleDelegateGtk: |
| 46 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; | 76 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; |
| 47 | 77 |
| 48 // content::NotificationObserver: | 78 // content::NotificationObserver: |
| 49 virtual void Observe(int type, | 79 virtual void Observe(int type, |
| 50 const content::NotificationSource& source, | 80 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) OVERRIDE; | 81 const content::NotificationDetails& details) OVERRIDE; |
| 52 | 82 |
| 53 // Builds the bubble and all the widgets that it displays. | 83 // Builds the bubble and all the widgets that it displays. |
| 54 void BuildBubble(); | 84 void BuildBubble(); |
| 55 | 85 |
| 56 // Widget callback methods. | 86 // Widget callback methods. |
| 57 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress, | 87 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress, |
| 58 GdkEventButton*); | 88 GdkEventButton*); |
| 59 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked); | 89 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked); |
| 60 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled); | 90 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled); |
| 61 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked); | 91 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked); |
| 62 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); | 92 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); |
| 63 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); | 93 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); |
| 94 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnMenuButtonClicked); | |
| 64 | 95 |
| 65 // We position the bubble near this widget. | 96 // We position the bubble near this widget. |
| 66 GtkWidget* anchor_; | 97 GtkWidget* anchor_; |
| 67 | 98 |
| 68 // The active profile. | 99 // The active profile. |
| 69 Profile* profile_; | 100 Profile* profile_; |
| 70 | 101 |
| 71 // The active web contents. | 102 // The active web contents. |
| 72 content::WebContents* web_contents_; | 103 content::WebContents* web_contents_; |
| 73 | 104 |
| 74 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. | 105 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. |
| 75 content::NotificationRegistrar registrar_; | 106 content::NotificationRegistrar registrar_; |
| 76 | 107 |
| 77 // Pass on delegate messages to this. | 108 // Pass on delegate messages to this. |
| 78 BubbleDelegateGtk* delegate_; | 109 BubbleDelegateGtk* delegate_; |
| 79 | 110 |
| 80 // Provides data for this bubble. | 111 // Provides data for this bubble. |
| 81 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; | 112 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; |
| 82 | 113 |
| 83 // The bubble. | 114 // The bubble. |
| 84 BubbleGtk* bubble_; | 115 BubbleGtk* bubble_; |
| 85 | 116 |
| 86 // Stored controls so we can figure out what was clicked. | 117 // Stored controls so we can figure out what was clicked. |
| 87 PopupMap popup_links_; | 118 PopupMap popup_links_; |
| 88 PopupMap popup_icons_; | 119 PopupMap popup_icons_; |
| 89 | 120 |
| 90 typedef std::vector<GtkWidget*> RadioGroupGtk; | 121 typedef std::vector<GtkWidget*> RadioGroupGtk; |
| 91 RadioGroupGtk radio_group_gtk_; | 122 RadioGroupGtk radio_group_gtk_; |
| 123 | |
| 124 GtkMediaMenuMap media_menus_; | |
| 92 }; | 125 }; |
| 93 | 126 |
| 94 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ | 127 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ |
| OLD | NEW |