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/common/content_settings_types.h" | 12 #include "chrome/common/content_settings_types.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/common/media_stream_request.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 ContentSettingMediaMenuModel; | |
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 namespace views { | 33 namespace views { |
34 class MenuButton; | |
35 class MenuRunner; | |
26 class TextButton; | 36 class TextButton; |
27 class RadioButton; | 37 class RadioButton; |
28 } | 38 } |
29 | 39 |
30 // ContentSettingBubbleContents is used when the user turns on different kinds | 40 // ContentSettingBubbleContents is used when the user turns on different kinds |
31 // of content blocking (e.g. "block images"). When viewing a page with blocked | 41 // 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 | 42 // 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 | 43 // 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, | 44 // 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 | 45 // 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 | 46 // 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 | 47 // get to a more comprehensive settings management dialog. A few types have |
38 // more or fewer controls than this. | 48 // more or fewer controls than this. |
39 class ContentSettingBubbleContents : public views::BubbleDelegateView, | 49 class ContentSettingBubbleContents |
40 public views::ButtonListener, | 50 : public views::BubbleDelegateView, |
41 public views::LinkListener, | 51 public views::ButtonListener, |
42 public content::NotificationObserver { | 52 public views::LinkListener, |
53 public views::MenuButtonListener, | |
54 public content::NotificationObserver { | |
43 public: | 55 public: |
44 ContentSettingBubbleContents( | 56 ContentSettingBubbleContents( |
45 ContentSettingBubbleModel* content_setting_bubble_model, | 57 ContentSettingBubbleModel* content_setting_bubble_model, |
58 Profile* profile, | |
46 content::WebContents* web_contents, | 59 content::WebContents* web_contents, |
47 views::View* anchor_view, | 60 views::View* anchor_view, |
48 views::BubbleBorder::ArrowLocation arrow_location); | 61 views::BubbleBorder::ArrowLocation arrow_location); |
49 virtual ~ContentSettingBubbleContents(); | 62 virtual ~ContentSettingBubbleContents(); |
50 | 63 |
51 virtual gfx::Size GetPreferredSize() OVERRIDE; | 64 virtual gfx::Size GetPreferredSize() OVERRIDE; |
52 | 65 |
66 // Callback to allow ContentSettingMediaMenuModel to update the menu label. | |
67 void UpdateMenuLabel(content::MediaStreamType type, | |
68 const std::string& label); | |
69 | |
53 protected: | 70 protected: |
54 // views::BubbleDelegateView: | 71 // views::BubbleDelegateView: |
55 virtual void Init() OVERRIDE; | 72 virtual void Init() OVERRIDE; |
56 | 73 |
57 private: | 74 private: |
58 class Favicon; | 75 class Favicon; |
59 | 76 |
60 typedef std::map<views::Link*, int> PopupLinks; | 77 typedef std::map<views::Link*, int> PopupLinks; |
61 | 78 |
79 struct MediaMenuParts { | |
Peter Kasting
2013/02/06 22:11:18
Does this need to be defined here? Seems like it
no longer working on chromium
2013/02/07 16:25:19
Done.
| |
80 MediaMenuParts(content::MediaStreamType type); | |
81 ~MediaMenuParts(); | |
82 | |
83 content::MediaStreamType type; | |
84 scoped_ptr<ui::SimpleMenuModel> menu_model; | |
85 | |
86 private: | |
87 DISALLOW_COPY_AND_ASSIGN(MediaMenuParts); | |
88 }; | |
89 // A map from a views::MenuButton* to a MediaMenuParts*. MediaMenuParts struct | |
90 // is used to store the UI members that a media menu owns. | |
Peter Kasting
2013/02/06 22:11:18
Nit: First sentence is unnecessary since it merely
no longer working on chromium
2013/02/07 16:25:19
Done.
| |
91 typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap; | |
92 | |
62 // views::ButtonListener: | 93 // views::ButtonListener: |
63 virtual void ButtonPressed(views::Button* sender, | 94 virtual void ButtonPressed(views::Button* sender, |
64 const ui::Event& event) OVERRIDE; | 95 const ui::Event& event) OVERRIDE; |
65 | 96 |
66 // views::LinkListener: | 97 // views::LinkListener: |
67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 98 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
68 | 99 |
100 // views::MenuButtonListener interface. | |
Peter Kasting
2013/02/06 22:11:18
Nit: Use "// Base class:" like the other comments
no longer working on chromium
2013/02/07 16:25:19
Done.
| |
101 virtual void OnMenuButtonClicked(views::View* source, | |
102 const gfx::Point& point) OVERRIDE; | |
103 | |
69 // content::NotificationObserver: | 104 // content::NotificationObserver: |
70 virtual void Observe(int type, | 105 virtual void Observe(int type, |
71 const content::NotificationSource& source, | 106 const content::NotificationSource& source, |
72 const content::NotificationDetails& details) OVERRIDE; | 107 const content::NotificationDetails& details) OVERRIDE; |
73 | 108 |
74 // Provides data for this bubble. | 109 // Provides data for this bubble. |
75 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; | 110 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; |
76 | 111 |
112 // The active profile. | |
Peter Kasting
2013/02/06 22:11:18
Do we need to take this as a constructor arg and s
no longer working on chromium
2013/02/07 16:25:19
Done.
| |
113 Profile* profile_; | |
114 | |
77 // The active web contents. | 115 // The active web contents. |
78 content::WebContents* web_contents_; | 116 content::WebContents* web_contents_; |
79 | 117 |
80 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. | 118 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. |
81 content::NotificationRegistrar registrar_; | 119 content::NotificationRegistrar registrar_; |
82 | 120 |
83 // Some of our controls, so we can tell what's been clicked when we get a | 121 // Some of our controls, so we can tell what's been clicked when we get a |
84 // message. | 122 // message. |
85 PopupLinks popup_links_; | 123 PopupLinks popup_links_; |
86 typedef std::vector<views::RadioButton*> RadioGroup; | 124 typedef std::vector<views::RadioButton*> RadioGroup; |
87 RadioGroup radio_group_; | 125 RadioGroup radio_group_; |
88 views::Link* custom_link_; | 126 views::Link* custom_link_; |
89 views::Link* manage_link_; | 127 views::Link* manage_link_; |
90 views::TextButton* close_button_; | 128 views::TextButton* close_button_; |
129 scoped_ptr<views::MenuRunner> menu_runner_; | |
130 MediaMenuPartsMap media_menus_; | |
91 | 131 |
92 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); | 132 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); |
93 }; | 133 }; |
94 | 134 |
95 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ | 135 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ |
OLD | NEW |