| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/common/content_settings_types.h" | 12 #include "chrome/common/content_settings_types.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/common/media_stream_request.h" |
| 15 #include "ui/views/bubble/bubble_delegate.h" | 16 #include "ui/views/bubble/bubble_delegate.h" |
| 16 #include "ui/views/controls/button/button.h" | 17 #include "ui/views/controls/button/button.h" |
| 18 #include "ui/views/controls/button/menu_button_listener.h" |
| 17 #include "ui/views/controls/link_listener.h" | 19 #include "ui/views/controls/link_listener.h" |
| 18 | 20 |
| 19 class ContentSettingBubbleModel; | 21 class ContentSettingBubbleModel; |
| 22 class ContentSettingMediaMenuModel; |
| 23 class Profile; |
| 20 | 24 |
| 21 namespace content { | 25 namespace content { |
| 22 class WebContents; | 26 class WebContents; |
| 23 } | 27 } |
| 24 | 28 |
| 29 namespace ui { |
| 30 class SimpleMenuModel; |
| 31 } |
| 32 |
| 25 namespace views { | 33 namespace views { |
| 34 class MenuButton; |
| 35 class MenuRunner; |
| 26 class TextButton; | 36 class TextButton; |
| 27 class RadioButton; | 37 class RadioButton; |
| 28 } | 38 } |
| 29 | 39 |
| 30 // ContentSettingBubbleContents is used when the user turns on different kinds | 40 // ContentSettingBubbleContents is used when the user turns on different kinds |
| 31 // of content blocking (e.g. "block images"). When viewing a page with blocked | 41 // of content blocking (e.g. "block images"). When viewing a page with blocked |
| 32 // content, icons appear in the omnibox corresponding to the content types that | 42 // content, icons appear in the omnibox corresponding to the content types that |
| 33 // were blocked, and the user can click one to get a bubble hosting a few | 43 // were blocked, and the user can click one to get a bubble hosting a few |
| 34 // controls. This class provides the content of that bubble. In general, | 44 // controls. This class provides the content of that bubble. In general, |
| 35 // these bubbles typically have a title, a pair of radio buttons for toggling | 45 // these bubbles typically have a title, a pair of radio buttons for toggling |
| 36 // the blocking settings for the current site, a close button, and a link to | 46 // the blocking settings for the current site, a close button, and a link to |
| 37 // get to a more comprehensive settings management dialog. A few types have | 47 // get to a more comprehensive settings management dialog. A few types have |
| 38 // more or fewer controls than this. | 48 // more or fewer controls than this. |
| 39 class ContentSettingBubbleContents : public views::BubbleDelegateView, | 49 class ContentSettingBubbleContents : public content::NotificationObserver, |
| 50 public views::BubbleDelegateView, |
| 40 public views::ButtonListener, | 51 public views::ButtonListener, |
| 41 public views::LinkListener, | 52 public views::LinkListener, |
| 42 public content::NotificationObserver { | 53 public views::MenuButtonListener { |
| 43 public: | 54 public: |
| 44 ContentSettingBubbleContents( | 55 ContentSettingBubbleContents( |
| 45 ContentSettingBubbleModel* content_setting_bubble_model, | 56 ContentSettingBubbleModel* content_setting_bubble_model, |
| 46 content::WebContents* web_contents, | 57 content::WebContents* web_contents, |
| 47 views::View* anchor_view, | 58 views::View* anchor_view, |
| 48 views::BubbleBorder::ArrowLocation arrow_location); | 59 views::BubbleBorder::ArrowLocation arrow_location); |
| 49 virtual ~ContentSettingBubbleContents(); | 60 virtual ~ContentSettingBubbleContents(); |
| 50 | 61 |
| 51 virtual gfx::Size GetPreferredSize() OVERRIDE; | 62 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 52 | 63 |
| 64 // Callback to allow ContentSettingMediaMenuModel to update the menu label. |
| 65 void UpdateMenuLabel(content::MediaStreamType type, |
| 66 const std::string& label); |
| 67 |
| 53 protected: | 68 protected: |
| 54 // views::BubbleDelegateView: | 69 // views::BubbleDelegateView: |
| 55 virtual void Init() OVERRIDE; | 70 virtual void Init() OVERRIDE; |
| 56 | 71 |
| 57 private: | 72 private: |
| 58 class Favicon; | 73 class Favicon; |
| 74 struct MediaMenuParts; |
| 59 | 75 |
| 60 typedef std::map<views::Link*, int> PopupLinks; | 76 typedef std::map<views::Link*, int> PopupLinks; |
| 77 typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap; |
| 61 | 78 |
| 62 // views::ButtonListener: | 79 // views::ButtonListener: |
| 63 virtual void ButtonPressed(views::Button* sender, | 80 virtual void ButtonPressed(views::Button* sender, |
| 64 const ui::Event& event) OVERRIDE; | 81 const ui::Event& event) OVERRIDE; |
| 65 | 82 |
| 66 // views::LinkListener: | 83 // views::LinkListener: |
| 67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 84 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 68 | 85 |
| 86 // views::MenuButtonListener: |
| 87 virtual void OnMenuButtonClicked(views::View* source, |
| 88 const gfx::Point& point) OVERRIDE; |
| 89 |
| 69 // content::NotificationObserver: | 90 // content::NotificationObserver: |
| 70 virtual void Observe(int type, | 91 virtual void Observe(int type, |
| 71 const content::NotificationSource& source, | 92 const content::NotificationSource& source, |
| 72 const content::NotificationDetails& details) OVERRIDE; | 93 const content::NotificationDetails& details) OVERRIDE; |
| 73 | 94 |
| 95 // Helper to get the preferred width of the media menu. |
| 96 int GetPreferredMediaMenuWidth(views::MenuButton* button, |
| 97 ui::SimpleMenuModel* menu_model); |
| 98 |
| 74 // Provides data for this bubble. | 99 // Provides data for this bubble. |
| 75 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; | 100 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model_; |
| 76 | 101 |
| 77 // The active web contents. | 102 // The active web contents. |
| 78 content::WebContents* web_contents_; | 103 content::WebContents* web_contents_; |
| 79 | 104 |
| 80 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. | 105 // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. |
| 81 content::NotificationRegistrar registrar_; | 106 content::NotificationRegistrar registrar_; |
| 82 | 107 |
| 83 // Some of our controls, so we can tell what's been clicked when we get a | 108 // Some of our controls, so we can tell what's been clicked when we get a |
| 84 // message. | 109 // message. |
| 85 PopupLinks popup_links_; | 110 PopupLinks popup_links_; |
| 86 typedef std::vector<views::RadioButton*> RadioGroup; | 111 typedef std::vector<views::RadioButton*> RadioGroup; |
| 87 RadioGroup radio_group_; | 112 RadioGroup radio_group_; |
| 88 views::Link* custom_link_; | 113 views::Link* custom_link_; |
| 89 views::Link* manage_link_; | 114 views::Link* manage_link_; |
| 90 views::TextButton* close_button_; | 115 views::TextButton* close_button_; |
| 116 scoped_ptr<views::MenuRunner> menu_runner_; |
| 117 MediaMenuPartsMap media_menus_; |
| 91 | 118 |
| 92 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); | 119 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); |
| 93 }; | 120 }; |
| 94 | 121 |
| 95 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ | 122 #endif // CHROME_BROWSER_UI_VIEWS_CONTENT_SETTING_BUBBLE_CONTENTS_H_ |
| OLD | NEW |