Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Side by Side Diff: chrome/browser/ui/views/content_setting_bubble_contents.h

Issue 12208010: Adding device selection menus to the content setting bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Used callback instead of inheriting from a virtual interface Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/views/bubble/bubble_delegate.h" 15 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h" 16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/button/menu_button_listener.h"
17 #include "ui/views/controls/link_listener.h" 18 #include "ui/views/controls/link_listener.h"
18 19
19 class ContentSettingBubbleModel; 20 class ContentSettingBubbleModel;
21 class ContentSettingMediaMenuModel;
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 {
43 public: 50 public:
44 ContentSettingBubbleContents( 51 ContentSettingBubbleContents(
45 ContentSettingBubbleModel* content_setting_bubble_model, 52 ContentSettingBubbleModel* content_setting_bubble_model,
53 Profile* profile,
46 content::WebContents* web_contents, 54 content::WebContents* web_contents,
47 views::View* anchor_view, 55 views::View* anchor_view,
48 views::BubbleBorder::ArrowLocation arrow_location); 56 views::BubbleBorder::ArrowLocation arrow_location);
49 virtual ~ContentSettingBubbleContents(); 57 virtual ~ContentSettingBubbleContents();
50 58
51 virtual gfx::Size GetPreferredSize() OVERRIDE; 59 virtual gfx::Size GetPreferredSize() OVERRIDE;
52 60
61 // ContentSettingMediaMenuModel::Observer implementation.
62 virtual void UpdateMenuLabel(content::MediaStreamType type,
63 const std::string& label) OVERRIDE;
64
53 protected: 65 protected:
54 // views::BubbleDelegateView: 66 // views::BubbleDelegateView:
55 virtual void Init() OVERRIDE; 67 virtual void Init() OVERRIDE;
56 68
57 private: 69 private:
58 class Favicon; 70 class Favicon;
59 71
60 typedef std::map<views::Link*, int> PopupLinks; 72 typedef std::map<views::Link*, int> PopupLinks;
61 73
74 struct MediaMenuParts {
75 MediaMenuParts(content::MediaStreamType type);
76 ~MediaMenuParts();
77
78 content::MediaStreamType type;
79 scoped_ptr<ui::SimpleMenuModel> menu_model;
80
81 private:
82 DISALLOW_COPY_AND_ASSIGN(MediaMenuParts);
83 };
84 // A map from a views::MenuButton* to a MediaMenuParts*. MediaMenuParts struct
85 // is used to store the UI members that a media menu owns.
86 typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap;
87
62 // views::ButtonListener: 88 // views::ButtonListener:
63 virtual void ButtonPressed(views::Button* sender, 89 virtual void ButtonPressed(views::Button* sender,
64 const ui::Event& event) OVERRIDE; 90 const ui::Event& event) OVERRIDE;
65 91
66 // views::LinkListener: 92 // views::LinkListener:
67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 93 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
68 94
95 // views::MenuButtonListener interface.
96 virtual void OnMenuButtonClicked(views::View* source,
97 const gfx::Point& point) OVERRIDE;
98
69 // content::NotificationObserver: 99 // content::NotificationObserver:
70 virtual void Observe(int type, 100 virtual void Observe(int type,
71 const content::NotificationSource& source, 101 const content::NotificationSource& source,
72 const content::NotificationDetails& details) OVERRIDE; 102 const content::NotificationDetails& details) OVERRIDE;
73 103
74 // Provides data for this bubble. 104 // Provides data for this bubble.
75 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; 105 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
76 106
107 // The active profile.
108 Profile* profile_;
109
77 // The active web contents. 110 // The active web contents.
78 content::WebContents* web_contents_; 111 content::WebContents* web_contents_;
79 112
80 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. 113 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications.
81 content::NotificationRegistrar registrar_; 114 content::NotificationRegistrar registrar_;
82 115
83 // Some of our controls, so we can tell what's been clicked when we get a 116 // Some of our controls, so we can tell what's been clicked when we get a
84 // message. 117 // message.
85 PopupLinks popup_links_; 118 PopupLinks popup_links_;
86 typedef std::vector<views::RadioButton*> RadioGroup; 119 typedef std::vector<views::RadioButton*> RadioGroup;
87 RadioGroup radio_group_; 120 RadioGroup radio_group_;
88 views::Link* custom_link_; 121 views::Link* custom_link_;
89 views::Link* manage_link_; 122 views::Link* manage_link_;
90 views::TextButton* close_button_; 123 views::TextButton* close_button_;
124 scoped_ptr<views::MenuRunner> menu_runner_;
125 MediaMenuPartsMap media_menus_;
91 126
92 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); 127 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents);
93 }; 128 };
94 129
95 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ 130 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698