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_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/ui/content_settings/content_setting_media_menu_model.h" | |
12 #include "chrome/common/content_settings_types.h" | 13 #include "chrome/common/content_settings_types.h" |
13 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
15 #include "ui/views/bubble/bubble_delegate.h" | 16 #include "ui/views/bubble/bubble_delegate.h" |
16 #include "ui/views/controls/button/button.h" | 17 #include "ui/views/controls/button/button.h" |
18 #include "ui/views/controls/button/menu_button_listener.h" | |
17 #include "ui/views/controls/link_listener.h" | 19 #include "ui/views/controls/link_listener.h" |
18 | 20 |
19 class ContentSettingBubbleModel; | 21 class ContentSettingBubbleModel; |
22 class Profile; | |
20 | 23 |
21 namespace content { | 24 namespace content { |
22 class WebContents; | 25 class WebContents; |
23 } | 26 } |
24 | 27 |
25 namespace views { | 28 namespace views { |
29 class MenuButton; | |
30 class MenuRunner; | |
26 class TextButton; | 31 class TextButton; |
27 class RadioButton; | 32 class RadioButton; |
28 } | 33 } |
29 | 34 |
30 // ContentSettingBubbleContents is used when the user turns on different kinds | 35 // ContentSettingBubbleContents is used when the user turns on different kinds |
31 // of content blocking (e.g. "block images"). When viewing a page with blocked | 36 // of content blocking (e.g. "block images"). When viewing a page with blocked |
32 // content, icons appear in the omnibox corresponding to the content types that | 37 // content, icons appear in the omnibox corresponding to the content types that |
33 // were blocked, and the user can click one to get a bubble hosting a few | 38 // were blocked, and the user can click one to get a bubble hosting a few |
34 // controls. This class provides the content of that bubble. In general, | 39 // controls. This class provides the content of that bubble. In general, |
35 // these bubbles typically have a title, a pair of radio buttons for toggling | 40 // these bubbles typically have a title, a pair of radio buttons for toggling |
36 // the blocking settings for the current site, a close button, and a link to | 41 // the blocking settings for the current site, a close button, and a link to |
37 // get to a more comprehensive settings management dialog. A few types have | 42 // get to a more comprehensive settings management dialog. A few types have |
38 // more or fewer controls than this. | 43 // more or fewer controls than this. |
39 class ContentSettingBubbleContents : public views::BubbleDelegateView, | 44 class ContentSettingBubbleContents |
40 public views::ButtonListener, | 45 : public views::BubbleDelegateView, |
41 public views::LinkListener, | 46 public views::ButtonListener, |
42 public content::NotificationObserver { | 47 public views::LinkListener, |
48 public views::MenuButtonListener, | |
49 public content::NotificationObserver, | |
50 public ContentSettingMediaMenuModel::Observer { | |
43 public: | 51 public: |
44 ContentSettingBubbleContents( | 52 ContentSettingBubbleContents( |
45 ContentSettingBubbleModel* content_setting_bubble_model, | 53 ContentSettingBubbleModel* content_setting_bubble_model, |
54 Profile* profile, | |
46 content::WebContents* web_contents, | 55 content::WebContents* web_contents, |
47 views::View* anchor_view, | 56 views::View* anchor_view, |
48 views::BubbleBorder::ArrowLocation arrow_location); | 57 views::BubbleBorder::ArrowLocation arrow_location); |
49 virtual ~ContentSettingBubbleContents(); | 58 virtual ~ContentSettingBubbleContents(); |
50 | 59 |
51 virtual gfx::Size GetPreferredSize() OVERRIDE; | 60 virtual gfx::Size GetPreferredSize() OVERRIDE; |
52 | 61 |
62 // ContentSettingMediaMenuModel::Observer implementation. | |
63 virtual void UpdateMenuLabel(content::MediaStreamType type, | |
64 const std::string& label) OVERRIDE; | |
65 | |
53 protected: | 66 protected: |
54 // views::BubbleDelegateView: | 67 // views::BubbleDelegateView: |
55 virtual void Init() OVERRIDE; | 68 virtual void Init() OVERRIDE; |
56 | 69 |
57 private: | 70 private: |
58 class Favicon; | 71 class Favicon; |
59 | 72 |
60 typedef std::map<views::Link*, int> PopupLinks; | 73 typedef std::map<views::Link*, int> PopupLinks; |
61 | 74 |
75 // A map from a views::MenuButton* to a MediaMenuView*. MediaMenuView struct | |
markusheintz_
2013/02/06 11:03:26
Since the map is defined in line 87 either move th
no longer working on chromium
2013/02/06 13:31:52
Done.
| |
76 // is used to store the UI members that a media menu owns. | |
77 struct MediaMenuView { | |
markusheintz_
2013/02/06 11:03:26
The suffix "View" is a bit misleading here, since
no longer working on chromium
2013/02/06 13:31:52
Done.
| |
78 MediaMenuView(); | |
79 ~MediaMenuView(); | |
80 | |
81 content::MediaStreamType type; | |
82 scoped_ptr<ui::SimpleMenuModel> menu_model; | |
83 | |
84 private: | |
85 DISALLOW_COPY_AND_ASSIGN(MediaMenuView); | |
86 }; | |
87 typedef std::map<views::MenuButton*, MediaMenuView*> MediaMenuViewMap; | |
88 | |
62 // views::ButtonListener: | 89 // views::ButtonListener: |
63 virtual void ButtonPressed(views::Button* sender, | 90 virtual void ButtonPressed(views::Button* sender, |
64 const ui::Event& event) OVERRIDE; | 91 const ui::Event& event) OVERRIDE; |
65 | 92 |
66 // views::LinkListener: | 93 // views::LinkListener: |
67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 94 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
68 | 95 |
96 // views::MenuButtonListener interface. | |
97 virtual void OnMenuButtonClicked(views::View* source, | |
98 const gfx::Point& point) OVERRIDE; | |
99 | |
69 // content::NotificationObserver: | 100 // content::NotificationObserver: |
70 virtual void Observe(int type, | 101 virtual void Observe(int type, |
71 const content::NotificationSource& source, | 102 const content::NotificationSource& source, |
72 const content::NotificationDetails& details) OVERRIDE; | 103 const content::NotificationDetails& details) OVERRIDE; |
73 | 104 |
74 // Provides data for this bubble. | 105 // Provides data for this bubble. |
75 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; | 106 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; |
76 | 107 |
108 // The active profile. | |
109 Profile* profile_; | |
110 | |
77 // The active web contents. | 111 // The active web contents. |
78 content::WebContents* web_contents_; | 112 content::WebContents* web_contents_; |
79 | 113 |
80 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. | 114 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. |
81 content::NotificationRegistrar registrar_; | 115 content::NotificationRegistrar registrar_; |
82 | 116 |
83 // Some of our controls, so we can tell what's been clicked when we get a | 117 // Some of our controls, so we can tell what's been clicked when we get a |
84 // message. | 118 // message. |
85 PopupLinks popup_links_; | 119 PopupLinks popup_links_; |
86 typedef std::vector<views::RadioButton*> RadioGroup; | 120 typedef std::vector<views::RadioButton*> RadioGroup; |
87 RadioGroup radio_group_; | 121 RadioGroup radio_group_; |
88 views::Link* custom_link_; | 122 views::Link* custom_link_; |
89 views::Link* manage_link_; | 123 views::Link* manage_link_; |
90 views::TextButton* close_button_; | 124 views::TextButton* close_button_; |
125 scoped_ptr<views::MenuRunner> menu_runner_; | |
126 MediaMenuViewMap media_menus_; | |
91 | 127 |
92 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); | 128 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); |
93 }; | 129 }; |
94 | 130 |
95 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ | 131 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ |
OLD | NEW |