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