| 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_CONTENT_SETTING_BUBBLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ | 6 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "chrome/common/content_settings.h" | 13 #include "chrome/common/content_settings.h" |
| 14 #include "content/common/notification_observer.h" | 14 #include "content/common/notification_observer.h" |
| 15 #include "content/common/notification_registrar.h" | 15 #include "content/common/notification_registrar.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 | 18 |
| 19 class Profile; | 19 class Profile; |
| 20 class SkBitmap; | 20 class SkBitmap; |
| 21 class TabContents; | 21 class TabContentsWrapper; |
| 22 | 22 |
| 23 // This model provides data for ContentSettingBubble, and also controls | 23 // This model provides data for ContentSettingBubble, and also controls |
| 24 // the action triggered when the allow / block radio buttons are triggered. | 24 // the action triggered when the allow / block radio buttons are triggered. |
| 25 class ContentSettingBubbleModel : public NotificationObserver { | 25 class ContentSettingBubbleModel : public NotificationObserver { |
| 26 public: | 26 public: |
| 27 virtual ~ContentSettingBubbleModel(); | 27 virtual ~ContentSettingBubbleModel(); |
| 28 | 28 |
| 29 static ContentSettingBubbleModel* CreateContentSettingBubbleModel( | 29 static ContentSettingBubbleModel* CreateContentSettingBubbleModel( |
| 30 TabContents* tab_contents, | 30 TabContentsWrapper* tab_contents, |
| 31 Profile* profile, | 31 Profile* profile, |
| 32 ContentSettingsType content_type); | 32 ContentSettingsType content_type); |
| 33 | 33 |
| 34 ContentSettingsType content_type() const { return content_type_; } | 34 ContentSettingsType content_type() const { return content_type_; } |
| 35 | 35 |
| 36 struct PopupItem { | 36 struct PopupItem { |
| 37 SkBitmap bitmap; | 37 SkBitmap bitmap; |
| 38 std::string title; | 38 std::string title; |
| 39 TabContents* tab_contents; | 39 TabContentsWrapper* tab_contents; |
| 40 }; | 40 }; |
| 41 typedef std::vector<PopupItem> PopupItems; | 41 typedef std::vector<PopupItem> PopupItems; |
| 42 | 42 |
| 43 typedef std::vector<std::string> RadioItems; | 43 typedef std::vector<std::string> RadioItems; |
| 44 struct RadioGroup { | 44 struct RadioGroup { |
| 45 RadioGroup(); | 45 RadioGroup(); |
| 46 ~RadioGroup(); | 46 ~RadioGroup(); |
| 47 | 47 |
| 48 GURL url; | 48 GURL url; |
| 49 std::string title; | 49 std::string title; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual void Observe(NotificationType type, | 82 virtual void Observe(NotificationType type, |
| 83 const NotificationSource& source, | 83 const NotificationSource& source, |
| 84 const NotificationDetails& details); | 84 const NotificationDetails& details); |
| 85 | 85 |
| 86 virtual void OnRadioClicked(int radio_index) {} | 86 virtual void OnRadioClicked(int radio_index) {} |
| 87 virtual void OnPopupClicked(int index) {} | 87 virtual void OnPopupClicked(int index) {} |
| 88 virtual void OnCustomLinkClicked() {} | 88 virtual void OnCustomLinkClicked() {} |
| 89 virtual void OnManageLinkClicked() {} | 89 virtual void OnManageLinkClicked() {} |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile, | 92 ContentSettingBubbleModel(TabContentsWrapper* tab_contents, Profile* profile, |
| 93 ContentSettingsType content_type); | 93 ContentSettingsType content_type); |
| 94 | 94 |
| 95 TabContents* tab_contents() const { return tab_contents_; } | 95 TabContentsWrapper* tab_contents() const { return tab_contents_; } |
| 96 Profile* profile() const { return profile_; } | 96 Profile* profile() const { return profile_; } |
| 97 | 97 |
| 98 void set_title(const std::string& title) { bubble_content_.title = title; } | 98 void set_title(const std::string& title) { bubble_content_.title = title; } |
| 99 void add_popup(const PopupItem& popup) { | 99 void add_popup(const PopupItem& popup) { |
| 100 bubble_content_.popup_items.push_back(popup); | 100 bubble_content_.popup_items.push_back(popup); |
| 101 } | 101 } |
| 102 void set_radio_group(const RadioGroup& radio_group) { | 102 void set_radio_group(const RadioGroup& radio_group) { |
| 103 bubble_content_.radio_group = radio_group; | 103 bubble_content_.radio_group = radio_group; |
| 104 } | 104 } |
| 105 void add_domain_list(const DomainList& domain_list) { | 105 void add_domain_list(const DomainList& domain_list) { |
| 106 bubble_content_.domain_lists.push_back(domain_list); | 106 bubble_content_.domain_lists.push_back(domain_list); |
| 107 } | 107 } |
| 108 void set_custom_link(const std::string& link) { | 108 void set_custom_link(const std::string& link) { |
| 109 bubble_content_.custom_link = link; | 109 bubble_content_.custom_link = link; |
| 110 } | 110 } |
| 111 void set_custom_link_enabled(bool enabled) { | 111 void set_custom_link_enabled(bool enabled) { |
| 112 bubble_content_.custom_link_enabled = enabled; | 112 bubble_content_.custom_link_enabled = enabled; |
| 113 } | 113 } |
| 114 void set_manage_link(const std::string& link) { | 114 void set_manage_link(const std::string& link) { |
| 115 bubble_content_.manage_link = link; | 115 bubble_content_.manage_link = link; |
| 116 } | 116 } |
| 117 void AddBlockedResource(const std::string& resource_identifier); | 117 void AddBlockedResource(const std::string& resource_identifier); |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 TabContents* tab_contents_; | 120 TabContentsWrapper* tab_contents_; |
| 121 Profile* profile_; | 121 Profile* profile_; |
| 122 ContentSettingsType content_type_; | 122 ContentSettingsType content_type_; |
| 123 BubbleContent bubble_content_; | 123 BubbleContent bubble_content_; |
| 124 // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. | 124 // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. |
| 125 NotificationRegistrar registrar_; | 125 NotificationRegistrar registrar_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 #endif // CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ | 128 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_ |
| OLD | NEW |