[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / content_setting_bubble_contents.h
blobe34f2ba15785e200ffda8629e2ea9f7d5c93b50f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_
6 #define CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/common/content_settings_types.h"
13 #include "content/public/common/media_stream_request.h"
14 #include "ui/views/bubble/bubble_delegate.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/button/menu_button_listener.h"
17 #include "ui/views/controls/link_listener.h"
19 class ContentSettingBubbleModel;
20 class ContentSettingMediaMenuModel;
21 class Profile;
23 namespace ui {
24 class SimpleMenuModel;
27 namespace views {
28 class LabelButton;
29 class MenuButton;
30 class MenuRunner;
31 class RadioButton;
34 // ContentSettingBubbleContents is used when the user turns on different kinds
35 // of content blocking (e.g. "block images"). When viewing a page with blocked
36 // content, icons appear in the omnibox corresponding to the content types that
37 // were blocked, and the user can click one to get a bubble hosting a few
38 // controls. This class provides the content of that bubble. In general,
39 // these bubbles typically have a title, a pair of radio buttons for toggling
40 // the blocking settings for the current site, a close button, and a link to
41 // get to a more comprehensive settings management dialog. A few types have
42 // more or fewer controls than this.
43 class ContentSettingBubbleContents : public views::BubbleDelegateView,
44 public views::ButtonListener,
45 public views::LinkListener,
46 public views::MenuButtonListener {
47 public:
48 ContentSettingBubbleContents(
49 ContentSettingBubbleModel* content_setting_bubble_model,
50 views::View* anchor_view,
51 views::BubbleBorder::Arrow arrow);
52 virtual ~ContentSettingBubbleContents();
54 virtual gfx::Size GetPreferredSize() const OVERRIDE;
56 // Callback to allow ContentSettingMediaMenuModel to update the menu label.
57 void UpdateMenuLabel(content::MediaStreamType type,
58 const std::string& label);
60 protected:
61 // views::BubbleDelegateView:
62 virtual void Init() OVERRIDE;
64 private:
65 class Favicon;
66 struct MediaMenuParts;
68 typedef std::map<views::Link*, int> PopupLinks;
69 typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap;
71 // views::ButtonListener:
72 virtual void ButtonPressed(views::Button* sender,
73 const ui::Event& event) OVERRIDE;
75 // views::LinkListener:
76 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
78 // views::MenuButtonListener:
79 virtual void OnMenuButtonClicked(views::View* source,
80 const gfx::Point& point) OVERRIDE;
82 // Helper to get the preferred width of the media menu.
83 int GetPreferredMediaMenuWidth(views::MenuButton* button,
84 ui::SimpleMenuModel* menu_model);
86 // Provides data for this bubble.
87 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
89 // Some of our controls, so we can tell what's been clicked when we get a
90 // message.
91 PopupLinks popup_links_;
92 typedef std::vector<views::RadioButton*> RadioGroup;
93 RadioGroup radio_group_;
94 views::Link* custom_link_;
95 views::Link* manage_link_;
96 views::LabelButton* close_button_;
97 scoped_ptr<views::MenuRunner> menu_runner_;
98 MediaMenuPartsMap media_menus_;
100 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents);
103 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_