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. 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 "content/common/notification_observer.h" 13 #include "content/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 27 class Bubble; 28 class ContentSettingBubbleModel; 29 class Profile; 30 class TabContents; 31 32 namespace views { 33 class NativeButton; 34 class RadioButton; 35 } 36 37 class 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 |bubble_|, so we can close the bubble if needed. The caller owns 48 // the bubble and must keep it alive. set_bubble(Bubble * bubble)49 void set_bubble(Bubble* bubble) { bubble_ = 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 Bubble holding us. 88 Bubble* 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