| 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/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 |
| 25 // ContentSettingBubbleGtk is used when the user turns on different kinds of | 33 // 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, | 34 // 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 | 35 // and when clicked, an instance of this class is created specialized for the |
| 28 // type of content being blocked. | 36 // type of content being blocked. |
| 29 class ContentSettingBubbleGtk : public BubbleDelegateGtk, | 37 class ContentSettingBubbleGtk : public BubbleDelegateGtk, |
| 30 public content::NotificationObserver { | 38 public content::NotificationObserver { |
| 31 public: | 39 public: |
| 32 ContentSettingBubbleGtk( | 40 ContentSettingBubbleGtk( |
| 33 GtkWidget* anchor, | 41 GtkWidget* anchor, |
| 34 BubbleDelegateGtk* delegate, | 42 BubbleDelegateGtk* delegate, |
| 35 ContentSettingBubbleModel* content_setting_bubble_model, | 43 ContentSettingBubbleModel* content_setting_bubble_model, |
| 36 Profile* profile, content::WebContents* web_contents); | 44 Profile* profile, content::WebContents* web_contents); |
| 37 virtual ~ContentSettingBubbleGtk(); | 45 virtual ~ContentSettingBubbleGtk(); |
| 38 | 46 |
| 47 // Callback to allow ContentSettingMediaMenuModel to update the menu label. |
| 48 void UpdateMenuLabel(content::MediaStreamType type, |
| 49 const std::string& label) OVERRIDE; |
| 50 |
| 39 // Dismisses the bubble. | 51 // Dismisses the bubble. |
| 40 void Close(); | 52 void Close(); |
| 41 | 53 |
| 42 private: | 54 private: |
| 55 // A map from a GtkWidget* to a MediaMenuGtk*. MediaMenuGtk struct is used |
| 56 // to store the UI members that a media menu owns. |
| 57 struct MediaMenuGtk { |
| 58 explicit MediaMenuGtk(content::MediaStreamType type); |
| 59 ~MediaMenuGtk(); |
| 60 |
| 61 content::MediaStreamType type; |
| 62 scoped_ptr<ui::SimpleMenuModel> menu_model; |
| 63 scoped_ptr<MenuGtk> menu; |
| 64 ui::OwnedWidgetGtk label; |
| 65 |
| 66 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(MediaMenuGtk); |
| 68 }; |
| 69 typedef std::map<GtkWidget*, MediaMenuGtk*> GtkMediaMenuMap; |
| 70 |
| 43 typedef std::map<GtkWidget*, int> PopupMap; | 71 typedef std::map<GtkWidget*, int> PopupMap; |
| 44 | 72 |
| 45 // BubbleDelegateGtk: | 73 // BubbleDelegateGtk: |
| 46 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; | 74 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; |
| 47 | 75 |
| 48 // content::NotificationObserver: | 76 // content::NotificationObserver: |
| 49 virtual void Observe(int type, | 77 virtual void Observe(int type, |
| 50 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) OVERRIDE; | 79 const content::NotificationDetails& details) OVERRIDE; |
| 52 | 80 |
| 53 // Builds the bubble and all the widgets that it displays. | 81 // Builds the bubble and all the widgets that it displays. |
| 54 void BuildBubble(); | 82 void BuildBubble(); |
| 55 | 83 |
| 56 // Widget callback methods. | 84 // Widget callback methods. |
| 57 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress, | 85 CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress, |
| 58 GdkEventButton*); | 86 GdkEventButton*); |
| 59 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked); | 87 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked); |
| 60 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled); | 88 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled); |
| 61 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked); | 89 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCustomLinkClicked); |
| 62 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); | 90 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); |
| 63 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); | 91 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); |
| 92 CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnMenuButtonClicked); |
| 64 | 93 |
| 65 // We position the bubble near this widget. | 94 // We position the bubble near this widget. |
| 66 GtkWidget* anchor_; | 95 GtkWidget* anchor_; |
| 67 | 96 |
| 68 // The active profile. | 97 // The active profile. |
| 69 Profile* profile_; | 98 Profile* profile_; |
| 70 | 99 |
| 71 // The active web contents. | 100 // The active web contents. |
| 72 content::WebContents* web_contents_; | 101 content::WebContents* web_contents_; |
| 73 | 102 |
| 74 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. | 103 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. |
| 75 content::NotificationRegistrar registrar_; | 104 content::NotificationRegistrar registrar_; |
| 76 | 105 |
| 77 // Pass on delegate messages to this. | 106 // Pass on delegate messages to this. |
| 78 BubbleDelegateGtk* delegate_; | 107 BubbleDelegateGtk* delegate_; |
| 79 | 108 |
| 80 // Provides data for this bubble. | 109 // Provides data for this bubble. |
| 81 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; | 110 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; |
| 82 | 111 |
| 83 // The bubble. | 112 // The bubble. |
| 84 BubbleGtk* bubble_; | 113 BubbleGtk* bubble_; |
| 85 | 114 |
| 86 // Stored controls so we can figure out what was clicked. | 115 // Stored controls so we can figure out what was clicked. |
| 87 PopupMap popup_links_; | 116 PopupMap popup_links_; |
| 88 PopupMap popup_icons_; | 117 PopupMap popup_icons_; |
| 89 | 118 |
| 90 typedef std::vector<GtkWidget*> RadioGroupGtk; | 119 typedef std::vector<GtkWidget*> RadioGroupGtk; |
| 91 RadioGroupGtk radio_group_gtk_; | 120 RadioGroupGtk radio_group_gtk_; |
| 121 |
| 122 GtkMediaMenuMap media_menus_; |
| 92 }; | 123 }; |
| 93 | 124 |
| 94 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ | 125 #endif // CHROME_BROWSER_UI_GTK_CONTENT_SETTING_BUBBLE_GTK_H_ |
| OLD | NEW |