content_setting_bubble_contents.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
1// Copyright (c) 2010 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.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_
6#define CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_
7#pragma once
8
9#include <map>
10
11#include "chrome/common/content_settings_types.h"
12#include "chrome/common/notification_observer.h"
13#include "chrome/common/notification_registrar.h"
14#include "views/controls/button/button.h"
15#include "views/controls/link.h"
16
17// ContentSettingBubbleContents is used when the user turns on different kinds
18// of content blocking (e.g. "block images").  When viewing a page with blocked
19// content, icons appear in the omnibox corresponding to the content types that
20// were blocked, and the user can click one to get a bubble hosting a few
21// controls.  This class provides the content of that bubble.  In general,
22// these bubbles typically have a title, a pair of radio buttons for toggling
23// the blocking settings for the current site, a close button, and a link to
24// get to a more comprehensive settings management dialog.  A few types have
25// more or fewer controls than this.
26
27class ContentSettingBubbleModel;
28class InfoBubble;
29class Profile;
30class TabContents;
31
32namespace views {
33class NativeButton;
34class RadioButton;
35}
36
37class ContentSettingBubbleContents : public views::View,
38                                     public views::ButtonListener,
39                                     public views::LinkController,
40                                     public NotificationObserver {
41 public:
42  ContentSettingBubbleContents(
43      ContentSettingBubbleModel* content_setting_bubble_model,
44      Profile* profile, TabContents* tab_contents);
45  virtual ~ContentSettingBubbleContents();
46
47  // Sets |info_bubble_|, so we can close the bubble if needed.  The caller owns
48  // the bubble and must keep it alive.
49  void set_info_bubble(InfoBubble* info_bubble) { info_bubble_ = info_bubble; }
50
51  virtual gfx::Size GetPreferredSize();
52
53 private:
54  class Favicon;
55
56  typedef std::map<views::Link*, int> PopupLinks;
57
58  // Overridden from views::View:
59  virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
60
61  // views::ButtonListener:
62  virtual void ButtonPressed(views::Button* sender, const views::Event& event);
63
64  // views::LinkController:
65  virtual void LinkActivated(views::Link* source, int event_flags);
66
67  // NotificationObserver:
68  virtual void Observe(NotificationType type,
69                       const NotificationSource& source,
70                       const NotificationDetails& details);
71
72  // Creates the child views.
73  void InitControlLayout();
74
75  // Provides data for this bubble.
76  scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_;
77
78  // The active profile.
79  Profile* profile_;
80
81  // The active tab contents.
82  TabContents* tab_contents_;
83
84  // A registrar for listening for TAB_CONTENTS_DESTROYED notifications.
85  NotificationRegistrar registrar_;
86
87  // The InfoBubble holding us.
88  InfoBubble* info_bubble_;
89
90  // Some of our controls, so we can tell what's been clicked when we get a
91  // message.
92  PopupLinks popup_links_;
93  typedef std::vector<views::RadioButton*> RadioGroup;
94  RadioGroup radio_group_;
95  views::Link* custom_link_;
96  views::Link* manage_link_;
97  views::NativeButton* close_button_;
98
99  DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents);
100};
101
102#endif  // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_
103