BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / views / content_setting_bubble_contents.h
blob62968a464e258115e27df4b010678d2274e72dfc
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 "components/content_settings/core/common/content_settings_types.h"
13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/common/media_stream_request.h"
15 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/button/menu_button_listener.h"
18 #include "ui/views/controls/link_listener.h"
20 class ContentSettingBubbleModel;
21 class ContentSettingMediaMenuModel;
22 class Profile;
24 namespace ui {
25 class SimpleMenuModel;
28 namespace views {
29 class LabelButton;
30 class MenuButton;
31 class MenuRunner;
32 class RadioButton;
35 // ContentSettingBubbleContents is used when the user turns on different kinds
36 // of content blocking (e.g. "block images"). When viewing a page with blocked
37 // content, icons appear in the omnibox corresponding to the content types that
38 // were blocked, and the user can click one to get a bubble hosting a few
39 // controls. This class provides the content of that bubble. In general,
40 // these bubbles typically have a title, a pair of radio buttons for toggling
41 // the blocking settings for the current site, a close button, and a link to
42 // get to a more comprehensive settings management dialog. A few types have
43 // more or fewer controls than this.
44 class ContentSettingBubbleContents : public content::WebContentsObserver,
45 public views::BubbleDelegateView,
46 public views::ButtonListener,
47 public views::LinkListener,
48 public views::MenuButtonListener {
49 public:
50 ContentSettingBubbleContents(
51 ContentSettingBubbleModel* content_setting_bubble_model,
52 content::WebContents* web_contents,
53 views::View* anchor_view,
54 views::BubbleBorder::Arrow arrow);
55 ~ContentSettingBubbleContents() override;
57 gfx::Size GetPreferredSize() const override;
59 // Callback to allow ContentSettingMediaMenuModel to update the menu label.
60 void UpdateMenuLabel(content::MediaStreamType type,
61 const std::string& label);
63 protected:
64 // views::BubbleDelegateView:
65 void Init() override;
67 private:
68 class Favicon;
69 struct MediaMenuParts;
71 typedef std::map<views::Link*, int> ListItemLinks;
72 typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap;
74 // content::WebContentsObserver:
75 void DidNavigateMainFrame(
76 const content::LoadCommittedDetails& details,
77 const content::FrameNavigateParams& params) override;
79 // views::View:
80 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
82 // views::ButtonListener:
83 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
85 // views::LinkListener:
86 void LinkClicked(views::Link* source, int event_flags) override;
88 // views::MenuButtonListener:
89 void OnMenuButtonClicked(views::View* source,
90 const gfx::Point& point) override;
92 // Helper to get the preferred width of the media menu.
93 void UpdateMenuButtonSizes(const ui::NativeTheme* theme);
95 // Provides data for this bubble.
96 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
98 // Some of our controls, so we can tell what's been clicked when we get a
99 // message.
100 ListItemLinks list_item_links_;
101 typedef std::vector<views::RadioButton*> RadioGroup;
102 RadioGroup radio_group_;
103 views::Link* custom_link_;
104 views::Link* manage_link_;
105 views::Link* learn_more_link_;
106 views::LabelButton* close_button_;
107 scoped_ptr<views::MenuRunner> menu_runner_;
108 MediaMenuPartsMap media_menus_;
110 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents);
113 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_