OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_CONTENT_SETTING_BUBBLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ |
7 | 7 |
| 8 #include <set> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
12 #include "chrome/common/notification_observer.h" | 13 #include "chrome/common/notification_observer.h" |
13 #include "chrome/common/notification_registrar.h" | 14 #include "chrome/common/notification_registrar.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
15 | 16 |
| 17 class GURL; |
16 class Profile; | 18 class Profile; |
17 class SkBitmap; | 19 class SkBitmap; |
18 class TabContents; | 20 class TabContents; |
19 | 21 |
20 // This model provides data for ContentSettingBubble, and also controls | 22 // This model provides data for ContentSettingBubble, and also controls |
21 // the action triggered when the allow / block radio buttons are triggered. | 23 // the action triggered when the allow / block radio buttons are triggered. |
22 class ContentSettingBubbleModel : public NotificationObserver { | 24 class ContentSettingBubbleModel : public NotificationObserver { |
23 public: | 25 public: |
24 virtual ~ContentSettingBubbleModel(); | 26 virtual ~ContentSettingBubbleModel(); |
25 | 27 |
(...skipping 13 matching lines...) Expand all Loading... |
39 | 41 |
40 typedef std::vector<std::string> RadioItems; | 42 typedef std::vector<std::string> RadioItems; |
41 struct RadioGroup { | 43 struct RadioGroup { |
42 std::string host; | 44 std::string host; |
43 std::string title; | 45 std::string title; |
44 RadioItems radio_items; | 46 RadioItems radio_items; |
45 int default_item; | 47 int default_item; |
46 }; | 48 }; |
47 typedef std::vector<RadioGroup> RadioGroups; | 49 typedef std::vector<RadioGroup> RadioGroups; |
48 | 50 |
| 51 struct DomainList { |
| 52 std::string title; |
| 53 std::set<std::string> hosts; |
| 54 }; |
| 55 |
49 struct BubbleContent { | 56 struct BubbleContent { |
50 std::string title; | 57 std::string title; |
51 PopupItems popup_items; | 58 PopupItems popup_items; |
52 RadioGroups radio_groups; | 59 RadioGroups radio_groups; |
| 60 std::vector<DomainList> domain_lists; |
53 std::string manage_link; | 61 std::string manage_link; |
| 62 std::string clear_link; |
54 }; | 63 }; |
55 | 64 |
56 const BubbleContent& bubble_content() const { return bubble_content_; } | 65 const BubbleContent& bubble_content() const { return bubble_content_; } |
57 | 66 |
58 // NotificationObserver: | 67 // NotificationObserver: |
59 virtual void Observe(NotificationType type, | 68 virtual void Observe(NotificationType type, |
60 const NotificationSource& source, | 69 const NotificationSource& source, |
61 const NotificationDetails& details); | 70 const NotificationDetails& details); |
62 | 71 |
63 virtual void OnRadioClicked(int radio_group, int radio_index) {} | 72 virtual void OnRadioClicked(int radio_group, int radio_index) {} |
64 virtual void OnPopupClicked(int index) {} | 73 virtual void OnPopupClicked(int index) {} |
65 virtual void OnManageLinkClicked() {} | 74 virtual void OnManageLinkClicked() {} |
| 75 virtual void OnClearLinkClicked() {} |
66 | 76 |
67 protected: | 77 protected: |
68 ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile, | 78 ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile, |
69 ContentSettingsType content_type); | 79 ContentSettingsType content_type); |
70 | 80 |
71 TabContents* tab_contents() const { return tab_contents_; } | 81 TabContents* tab_contents() const { return tab_contents_; } |
72 Profile* profile() const { return profile_; } | 82 Profile* profile() const { return profile_; } |
73 | 83 |
74 void set_title(const std::string& title) { bubble_content_.title = title; } | 84 void set_title(const std::string& title) { bubble_content_.title = title; } |
75 void add_popup(const PopupItem& popup) { | 85 void add_popup(const PopupItem& popup) { |
76 bubble_content_.popup_items.push_back(popup); | 86 bubble_content_.popup_items.push_back(popup); |
77 } | 87 } |
78 void add_radio_group(const RadioGroup& radio_group) { | 88 void add_radio_group(const RadioGroup& radio_group) { |
79 bubble_content_.radio_groups.push_back(radio_group); | 89 bubble_content_.radio_groups.push_back(radio_group); |
80 } | 90 } |
| 91 void add_domain_list(const DomainList& domain_list) { |
| 92 bubble_content_.domain_lists.push_back(domain_list); |
| 93 } |
81 void set_manage_link(const std::string& link) { | 94 void set_manage_link(const std::string& link) { |
82 bubble_content_.manage_link = link; | 95 bubble_content_.manage_link = link; |
83 } | 96 } |
| 97 void set_clear_link(const std::string& link) { |
| 98 bubble_content_.clear_link = link; |
| 99 } |
84 | 100 |
85 private: | 101 private: |
86 TabContents* tab_contents_; | 102 TabContents* tab_contents_; |
87 Profile* profile_; | 103 Profile* profile_; |
88 ContentSettingsType content_type_; | 104 ContentSettingsType content_type_; |
89 BubbleContent bubble_content_; | 105 BubbleContent bubble_content_; |
90 // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. | 106 // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. |
91 NotificationRegistrar registrar_; | 107 NotificationRegistrar registrar_; |
92 }; | 108 }; |
93 | 109 |
94 #endif // CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ | 110 #endif // CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ |
OLD | NEW |