| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ | 6 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace content { | 27 namespace content { |
| 28 class WebContents; | 28 class WebContents; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // This model provides data for ContentSettingBubble, and also controls | 31 // This model provides data for ContentSettingBubble, and also controls |
| 32 // the action triggered when the allow / block radio buttons are triggered. | 32 // the action triggered when the allow / block radio buttons are triggered. |
| 33 class ContentSettingBubbleModel : public content::NotificationObserver { | 33 class ContentSettingBubbleModel : public content::NotificationObserver { |
| 34 public: | 34 public: |
| 35 typedef ContentSettingBubbleModelDelegate Delegate; | 35 typedef ContentSettingBubbleModelDelegate Delegate; |
| 36 | 36 |
| 37 struct PopupItem { | 37 struct ListItem { |
| 38 PopupItem(const gfx::Image& image, const std::string& title, int32 popup_id) | 38 ListItem(const gfx::Image& image, |
| 39 : image(image), title(title), popup_id(popup_id) {} | 39 const std::string& title, |
| 40 bool has_link, |
| 41 int32 item_id) |
| 42 : image(image), title(title), has_link(has_link), item_id(item_id) {} |
| 40 | 43 |
| 41 gfx::Image image; | 44 gfx::Image image; |
| 42 std::string title; | 45 std::string title; |
| 43 int32 popup_id; | 46 bool has_link; |
| 47 int32 item_id; |
| 44 }; | 48 }; |
| 45 typedef std::vector<PopupItem> PopupItems; | 49 typedef std::vector<ListItem> ListItems; |
| 46 | 50 |
| 47 typedef std::vector<std::string> RadioItems; | 51 typedef std::vector<std::string> RadioItems; |
| 48 struct RadioGroup { | 52 struct RadioGroup { |
| 49 RadioGroup(); | 53 RadioGroup(); |
| 50 ~RadioGroup(); | 54 ~RadioGroup(); |
| 51 | 55 |
| 52 GURL url; | 56 GURL url; |
| 53 std::string title; | 57 std::string title; |
| 54 RadioItems radio_items; | 58 RadioItems radio_items; |
| 55 int default_item; | 59 int default_item; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 72 content::MediaStreamDevice selected_device; | 76 content::MediaStreamDevice selected_device; |
| 73 bool disabled; | 77 bool disabled; |
| 74 }; | 78 }; |
| 75 typedef std::map<content::MediaStreamType, MediaMenu> MediaMenuMap; | 79 typedef std::map<content::MediaStreamType, MediaMenu> MediaMenuMap; |
| 76 | 80 |
| 77 struct BubbleContent { | 81 struct BubbleContent { |
| 78 BubbleContent(); | 82 BubbleContent(); |
| 79 ~BubbleContent(); | 83 ~BubbleContent(); |
| 80 | 84 |
| 81 std::string title; | 85 std::string title; |
| 82 base::string16 plugin_names; | 86 ListItems list_items; |
| 83 PopupItems popup_items; | |
| 84 RadioGroup radio_group; | 87 RadioGroup radio_group; |
| 85 bool radio_group_enabled; | 88 bool radio_group_enabled; |
| 86 std::vector<DomainList> domain_lists; | 89 std::vector<DomainList> domain_lists; |
| 87 std::string custom_link; | 90 std::string custom_link; |
| 88 bool custom_link_enabled; | 91 bool custom_link_enabled; |
| 89 std::string manage_link; | 92 std::string manage_link; |
| 90 MediaMenuMap media_menus; | 93 MediaMenuMap media_menus; |
| 91 std::string learn_more_link; | 94 std::string learn_more_link; |
| 92 | 95 |
| 93 private: | 96 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 105 ContentSettingsType content_type() const { return content_type_; } | 108 ContentSettingsType content_type() const { return content_type_; } |
| 106 | 109 |
| 107 const BubbleContent& bubble_content() const { return bubble_content_; } | 110 const BubbleContent& bubble_content() const { return bubble_content_; } |
| 108 | 111 |
| 109 // content::NotificationObserver: | 112 // content::NotificationObserver: |
| 110 void Observe(int type, | 113 void Observe(int type, |
| 111 const content::NotificationSource& source, | 114 const content::NotificationSource& source, |
| 112 const content::NotificationDetails& details) override; | 115 const content::NotificationDetails& details) override; |
| 113 | 116 |
| 114 virtual void OnRadioClicked(int radio_index) {} | 117 virtual void OnRadioClicked(int radio_index) {} |
| 115 virtual void OnPopupClicked(int index) {} | 118 virtual void OnListItemClicked(int index) {} |
| 116 virtual void OnCustomLinkClicked() {} | 119 virtual void OnCustomLinkClicked() {} |
| 117 virtual void OnManageLinkClicked() {} | 120 virtual void OnManageLinkClicked() {} |
| 118 virtual void OnLearnMoreLinkClicked() {} | 121 virtual void OnLearnMoreLinkClicked() {} |
| 119 virtual void OnMediaMenuClicked(content::MediaStreamType type, | 122 virtual void OnMediaMenuClicked(content::MediaStreamType type, |
| 120 const std::string& selected_device_id) {} | 123 const std::string& selected_device_id) {} |
| 121 | 124 |
| 122 // Called by the view code when the bubble is closed by the user using the | 125 // Called by the view code when the bubble is closed by the user using the |
| 123 // Done button. | 126 // Done button. |
| 124 virtual void OnDoneClicked() {} | 127 virtual void OnDoneClicked() {} |
| 125 | 128 |
| 126 protected: | 129 protected: |
| 127 ContentSettingBubbleModel( | 130 ContentSettingBubbleModel( |
| 128 content::WebContents* web_contents, | 131 content::WebContents* web_contents, |
| 129 Profile* profile, | 132 Profile* profile, |
| 130 ContentSettingsType content_type); | 133 ContentSettingsType content_type); |
| 131 | 134 |
| 132 content::WebContents* web_contents() const { return web_contents_; } | 135 content::WebContents* web_contents() const { return web_contents_; } |
| 133 Profile* profile() const { return profile_; } | 136 Profile* profile() const { return profile_; } |
| 134 | 137 |
| 135 void set_title(const std::string& title) { bubble_content_.title = title; } | 138 void set_title(const std::string& title) { bubble_content_.title = title; } |
| 136 void set_plugin_names(const base::string16& plugin_names) { | 139 void add_list_item(const ListItem& item) { |
| 137 bubble_content_.plugin_names = plugin_names; | 140 bubble_content_.list_items.push_back(item); |
| 138 } | |
| 139 void add_popup(const PopupItem& popup) { | |
| 140 bubble_content_.popup_items.push_back(popup); | |
| 141 } | 141 } |
| 142 void set_radio_group(const RadioGroup& radio_group) { | 142 void set_radio_group(const RadioGroup& radio_group) { |
| 143 bubble_content_.radio_group = radio_group; | 143 bubble_content_.radio_group = radio_group; |
| 144 } | 144 } |
| 145 void set_radio_group_enabled(bool enabled) { | 145 void set_radio_group_enabled(bool enabled) { |
| 146 bubble_content_.radio_group_enabled = enabled; | 146 bubble_content_.radio_group_enabled = enabled; |
| 147 } | 147 } |
| 148 void add_domain_list(const DomainList& domain_list) { | 148 void add_domain_list(const DomainList& domain_list) { |
| 149 bubble_content_.domain_lists.push_back(domain_list); | 149 bubble_content_.domain_lists.push_back(domain_list); |
| 150 } | 150 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 void OnLearnMoreLinkClicked() override; | 206 void OnLearnMoreLinkClicked() override; |
| 207 Delegate* delegate_; | 207 Delegate* delegate_; |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // RPH stands for Register Protocol Handler. | 210 // RPH stands for Register Protocol Handler. |
| 211 class ContentSettingRPHBubbleModel : public ContentSettingTitleAndLinkModel { | 211 class ContentSettingRPHBubbleModel : public ContentSettingTitleAndLinkModel { |
| 212 public: | 212 public: |
| 213 ContentSettingRPHBubbleModel(Delegate* delegate, | 213 ContentSettingRPHBubbleModel(Delegate* delegate, |
| 214 content::WebContents* web_contents, | 214 content::WebContents* web_contents, |
| 215 Profile* profile, | 215 Profile* profile, |
| 216 ProtocolHandlerRegistry* registry, | 216 ProtocolHandlerRegistry* registry); |
| 217 ContentSettingsType content_type); | |
| 218 | 217 |
| 219 void OnRadioClicked(int radio_index) override; | 218 void OnRadioClicked(int radio_index) override; |
| 220 void OnDoneClicked() override; | 219 void OnDoneClicked() override; |
| 221 | 220 |
| 222 private: | 221 private: |
| 223 void RegisterProtocolHandler(); | 222 void RegisterProtocolHandler(); |
| 224 void UnregisterProtocolHandler(); | 223 void UnregisterProtocolHandler(); |
| 225 void IgnoreProtocolHandler(); | 224 void IgnoreProtocolHandler(); |
| 226 void ClearOrSetPreviousHandler(); | 225 void ClearOrSetPreviousHandler(); |
| 227 | 226 |
| 228 int selected_item_; | 227 int selected_item_; |
| 229 ProtocolHandlerRegistry* registry_; | 228 ProtocolHandlerRegistry* registry_; |
| 230 ProtocolHandler pending_handler_; | 229 ProtocolHandler pending_handler_; |
| 231 ProtocolHandler previous_handler_; | 230 ProtocolHandler previous_handler_; |
| 232 }; | 231 }; |
| 233 | 232 |
| 234 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ | 233 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ |
| OLD | NEW |