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, |
Peter Kasting
2013/02/16 02:55:13
Nit: Rewrapping doesn't look to be necessary, I th
no longer working on chromium
2013/02/18 17:20:04
I think this style is used more in chrome:
class A
tfarina
2013/02/18 17:33:50
No!
If it fits, then just do:
class Foo : public
Peter Kasting
2013/02/18 18:23:18
Thiago is correct. There's no reason to rewrap to
| |
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, |
46 content::WebContents* web_contents, | 58 content::WebContents* web_contents, |
47 views::View* anchor_view, | 59 views::View* anchor_view, |
48 views::BubbleBorder::ArrowLocation arrow_location); | 60 views::BubbleBorder::ArrowLocation arrow_location); |
49 virtual ~ContentSettingBubbleContents(); | 61 virtual ~ContentSettingBubbleContents(); |
50 | 62 |
51 virtual gfx::Size GetPreferredSize() OVERRIDE; | 63 virtual gfx::Size GetPreferredSize() OVERRIDE; |
52 | 64 |
65 // Callback to allow ContentSettingMediaMenuModel to update the menu label. | |
66 void UpdateMenuLabel(content::MediaStreamType type, | |
67 const std::string& label); | |
68 | |
53 protected: | 69 protected: |
54 // views::BubbleDelegateView: | 70 // views::BubbleDelegateView: |
55 virtual void Init() OVERRIDE; | 71 virtual void Init() OVERRIDE; |
56 | 72 |
57 private: | 73 private: |
58 class Favicon; | 74 class Favicon; |
75 struct MediaMenuParts; | |
59 | 76 |
60 typedef std::map<views::Link*, int> PopupLinks; | 77 typedef std::map<views::Link*, int> PopupLinks; |
61 | 78 |
Peter Kasting
2013/02/16 02:55:13
Nit: Blank line unnecessary
no longer working on chromium
2013/02/18 17:20:04
Done.
| |
79 typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap; | |
80 | |
62 // views::ButtonListener: | 81 // views::ButtonListener: |
63 virtual void ButtonPressed(views::Button* sender, | 82 virtual void ButtonPressed(views::Button* sender, |
64 const ui::Event& event) OVERRIDE; | 83 const ui::Event& event) OVERRIDE; |
65 | 84 |
66 // views::LinkListener: | 85 // views::LinkListener: |
67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 86 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
68 | 87 |
88 // views::MenuButtonListener: | |
89 virtual void OnMenuButtonClicked(views::View* source, | |
90 const gfx::Point& point) OVERRIDE; | |
91 | |
69 // content::NotificationObserver: | 92 // content::NotificationObserver: |
70 virtual void Observe(int type, | 93 virtual void Observe(int type, |
71 const content::NotificationSource& source, | 94 const content::NotificationSource& source, |
72 const content::NotificationDetails& details) OVERRIDE; | 95 const content::NotificationDetails& details) OVERRIDE; |
73 | 96 |
97 // Helper to get the preferred width of the media menu. | |
98 int GetPreferredMediaMenuWidth(views::MenuButton* button, | |
99 ui::SimpleMenuModel* menu_model); | |
100 | |
74 // Provides data for this bubble. | 101 // Provides data for this bubble. |
75 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; | 102 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; |
76 | 103 |
77 // The active web contents. | 104 // The active web contents. |
78 content::WebContents* web_contents_; | 105 content::WebContents* web_contents_; |
79 | 106 |
80 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. | 107 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. |
81 content::NotificationRegistrar registrar_; | 108 content::NotificationRegistrar registrar_; |
82 | 109 |
83 // Some of our controls, so we can tell what's been clicked when we get a | 110 // Some of our controls, so we can tell what's been clicked when we get a |
84 // message. | 111 // message. |
85 PopupLinks popup_links_; | 112 PopupLinks popup_links_; |
86 typedef std::vector<views::RadioButton*> RadioGroup; | 113 typedef std::vector<views::RadioButton*> RadioGroup; |
87 RadioGroup radio_group_; | 114 RadioGroup radio_group_; |
88 views::Link* custom_link_; | 115 views::Link* custom_link_; |
89 views::Link* manage_link_; | 116 views::Link* manage_link_; |
90 views::TextButton* close_button_; | 117 views::TextButton* close_button_; |
118 scoped_ptr<views::MenuRunner> menu_runner_; | |
119 MediaMenuPartsMap media_menus_; | |
91 | 120 |
92 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); | 121 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); |
93 }; | 122 }; |
94 | 123 |
95 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ | 124 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ |
OLD | NEW |