blob: 49af1b29bad1b2e13d5d081bf10b1439b074a063 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
#define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
#pragma once
#include <set>
#include <string>
#include <vector>
#include "chrome/common/content_settings.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
class Profile;
class SkBitmap;
class TabContents;
// This model provides data for ContentSettingBubble, and also controls
// the action triggered when the allow / block radio buttons are triggered.
class ContentSettingBubbleModel : public NotificationObserver {
public:
virtual ~ContentSettingBubbleModel();
static ContentSettingBubbleModel* CreateContentSettingBubbleModel(
TabContents* tab_contents,
Profile* profile,
ContentSettingsType content_type);
ContentSettingsType content_type() const { return content_type_; }
struct PopupItem {
SkBitmap bitmap;
std::string title;
TabContents* tab_contents;
};
typedef std::vector<PopupItem> PopupItems;
typedef std::vector<std::string> RadioItems;
struct RadioGroup {
RadioGroup();
~RadioGroup();
GURL url;
std::string title;
RadioItems radio_items;
int default_item;
};
struct DomainList {
DomainList();
~DomainList();
std::string title;
std::set<std::string> hosts;
};
struct BubbleContent {
BubbleContent();
~BubbleContent();
std::string title;
PopupItems popup_items;
RadioGroup radio_group;
std::vector<DomainList> domain_lists;
std::set<std::string> resource_identifiers;
std::string manage_link;
std::string clear_link;
std::string info_link;
std::string load_plugins_link_title;
bool load_plugins_link_enabled;
private:
DISALLOW_COPY_AND_ASSIGN(BubbleContent);
};
const BubbleContent& bubble_content() const { return bubble_content_; }
// NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
virtual void OnRadioClicked(int radio_index) {}
virtual void OnPopupClicked(int index) {}
virtual void OnManageLinkClicked() {}
virtual void OnClearLinkClicked() {}
virtual void OnInfoLinkClicked() {}
virtual void OnLoadPluginsLinkClicked() {}
protected:
ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile,
ContentSettingsType content_type);
TabContents* tab_contents() const { return tab_contents_; }
Profile* profile() const { return profile_; }
void set_title(const std::string& title) { bubble_content_.title = title; }
void add_popup(const PopupItem& popup) {
bubble_content_.popup_items.push_back(popup);
}
void set_radio_group(const RadioGroup& radio_group) {
bubble_content_.radio_group = radio_group;
}
void add_domain_list(const DomainList& domain_list) {
bubble_content_.domain_lists.push_back(domain_list);
}
void set_manage_link(const std::string& link) {
bubble_content_.manage_link = link;
}
void set_clear_link(const std::string& link) {
bubble_content_.clear_link = link;
}
void set_info_link(const std::string& link) {
bubble_content_.info_link = link;
}
void set_load_plugins_link_title(const std::string& title) {
bubble_content_.load_plugins_link_title = title;
}
void set_load_plugins_link_enabled(bool enabled) {
bubble_content_.load_plugins_link_enabled = enabled;
}
void AddBlockedResource(const std::string& resource_identifier);
private:
TabContents* tab_contents_;
Profile* profile_;
ContentSettingsType content_type_;
BubbleContent bubble_content_;
// A registrar for listening for TAB_CONTENTS_DESTROYED notifications.
NotificationRegistrar registrar_;
};
#endif // CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
|