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_COOKIES_TREE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
6 #define CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 6 #define CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); | 105 DISALLOW_COPY_AND_ASSIGN(CookieTreeNode); |
106 }; | 106 }; |
107 | 107 |
108 // CookieTreeRootNode --------------------------------------------------------- | 108 // CookieTreeRootNode --------------------------------------------------------- |
109 // The node at the root of the CookieTree that gets inserted into the view. | 109 // The node at the root of the CookieTree that gets inserted into the view. |
110 class CookieTreeRootNode : public CookieTreeNode { | 110 class CookieTreeRootNode : public CookieTreeNode { |
111 public: | 111 public: |
112 explicit CookieTreeRootNode(CookiesTreeModel* model) : model_(model) {} | 112 explicit CookieTreeRootNode(CookiesTreeModel* model) : model_(model) {} |
113 virtual ~CookieTreeRootNode() {} | 113 virtual ~CookieTreeRootNode() {} |
114 | 114 |
115 CookieTreeOriginNode* GetOrCreateOriginNode(const std::wstring& origin); | 115 CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); |
116 | 116 |
117 // CookieTreeNode methods: | 117 // CookieTreeNode methods: |
118 virtual CookiesTreeModel* GetModel() const { return model_; } | 118 virtual CookiesTreeModel* GetModel() const { return model_; } |
119 virtual DetailedInfo GetDetailedInfo() const { | 119 virtual DetailedInfo GetDetailedInfo() const { |
120 return DetailedInfo(std::wstring(), DetailedInfo::TYPE_ROOT, NULL, NULL, | 120 return DetailedInfo(std::wstring(), DetailedInfo::TYPE_ROOT, NULL, NULL, |
121 NULL, NULL); | 121 NULL, NULL); |
122 } | 122 } |
123 private: | 123 private: |
124 | 124 |
125 CookiesTreeModel* model_; | 125 CookiesTreeModel* model_; |
126 | 126 |
127 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); | 127 DISALLOW_COPY_AND_ASSIGN(CookieTreeRootNode); |
128 }; | 128 }; |
129 | 129 |
130 // CookieTreeOriginNode ------------------------------------------------------- | 130 // CookieTreeOriginNode ------------------------------------------------------- |
131 class CookieTreeOriginNode : public CookieTreeNode { | 131 class CookieTreeOriginNode : public CookieTreeNode { |
132 public: | 132 public: |
133 explicit CookieTreeOriginNode(const std::wstring& origin) | 133 // Returns the origin node's title to use for a given URL. |
134 : CookieTreeNode(origin), | 134 static std::wstring TitleForUrl(const GURL& url); |
135 cookies_child_(NULL), | 135 |
136 databases_child_(NULL), | 136 explicit CookieTreeOriginNode(const GURL& url); |
137 local_storages_child_(NULL), | |
138 appcaches_child_(NULL) {} | |
139 virtual ~CookieTreeOriginNode() {} | 137 virtual ~CookieTreeOriginNode() {} |
140 | 138 |
141 // CookieTreeNode methods: | 139 // CookieTreeNode methods: |
142 virtual DetailedInfo GetDetailedInfo() const { | 140 virtual DetailedInfo GetDetailedInfo() const { |
143 return DetailedInfo(GetTitle(), DetailedInfo::TYPE_ORIGIN, NULL, NULL, | 141 return DetailedInfo(GetTitle(), DetailedInfo::TYPE_ORIGIN, NULL, NULL, |
144 NULL, NULL); | 142 NULL, NULL); |
145 } | 143 } |
146 | 144 |
147 // CookieTreeOriginNode methods: | 145 // CookieTreeOriginNode methods: |
148 CookieTreeCookiesNode* GetOrCreateCookiesNode(); | 146 CookieTreeCookiesNode* GetOrCreateCookiesNode(); |
149 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); | 147 CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); |
150 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); | 148 CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); |
151 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); | 149 CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); |
| 150 |
| 151 // Creates an content exception for this origin of type |
| 152 // CONTENT_SETTINGS_TYPE_COOKIES. |
152 void CreateContentException(HostContentSettingsMap* content_settings, | 153 void CreateContentException(HostContentSettingsMap* content_settings, |
153 ContentSetting setting); | 154 ContentSetting setting) const; |
| 155 |
| 156 // True if a content exception can be created for this origin. |
| 157 bool CanCreateContentException() const; |
154 | 158 |
155 private: | 159 private: |
156 // Pointers to the cookies, databases, local storage and appcache nodes. | 160 // Pointers to the cookies, databases, local storage and appcache nodes. |
157 // When we build up the tree we need to quickly get a reference to the COOKIES | 161 // When we build up the tree we need to quickly get a reference to the COOKIES |
158 // node to add children. Checking each child and interrogating them to see if | 162 // node to add children. Checking each child and interrogating them to see if |
159 // they are a COOKIES, APPCACHES, DATABASES etc node seems less preferable | 163 // they are a COOKIES, APPCACHES, DATABASES etc node seems less preferable |
160 // than storing an extra pointer per origin. | 164 // than storing an extra pointer per origin. |
161 CookieTreeCookiesNode* cookies_child_; | 165 CookieTreeCookiesNode* cookies_child_; |
162 CookieTreeDatabasesNode* databases_child_; | 166 CookieTreeDatabasesNode* databases_child_; |
163 CookieTreeLocalStoragesNode* local_storages_child_; | 167 CookieTreeLocalStoragesNode* local_storages_child_; |
164 CookieTreeAppCachesNode* appcaches_child_; | 168 CookieTreeAppCachesNode* appcaches_child_; |
165 | 169 |
| 170 // The URL for which this node was initially created. |
| 171 GURL url_; |
| 172 |
166 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); | 173 DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); |
167 }; | 174 }; |
168 | 175 |
169 // CookieTreeCookieNode ------------------------------------------------------ | 176 // CookieTreeCookieNode ------------------------------------------------------ |
170 class CookieTreeCookieNode : public CookieTreeNode { | 177 class CookieTreeCookieNode : public CookieTreeNode { |
171 public: | 178 public: |
172 friend class CookieTreeCookiesNode; | 179 friend class CookieTreeCookiesNode; |
173 | 180 |
174 // Does not take ownership of cookie, and cookie should remain valid at least | 181 // Does not take ownership of cookie, and cookie should remain valid at least |
175 // as long as the CookieTreeCookieNode is valid. | 182 // as long as the CookieTreeCookieNode is valid. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 446 |
440 friend class CookieTreeAppCacheNode; | 447 friend class CookieTreeAppCacheNode; |
441 friend class CookieTreeCookieNode; | 448 friend class CookieTreeCookieNode; |
442 friend class CookieTreeDatabaseNode; | 449 friend class CookieTreeDatabaseNode; |
443 friend class CookieTreeLocalStorageNode; | 450 friend class CookieTreeLocalStorageNode; |
444 | 451 |
445 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); | 452 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); |
446 }; | 453 }; |
447 | 454 |
448 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ | 455 #endif // CHROME_BROWSER_COOKIES_TREE_MODEL_H_ |
OLD | NEW |