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