Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/renderer/content_settings_observer.cc

Issue 7631063: Prefix all IPC messages used by src\chrome with Chrome. For e.g ChromeViewMsg_, ChromeViewHostMsg... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/renderer/content_settings_observer.h" 5 #include "chrome/renderer/content_settings_observer.h"
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "content/common/database_messages.h" 9 #include "content/common/database_messages.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 void ContentSettingsObserver::DidBlockContentType( 85 void ContentSettingsObserver::DidBlockContentType(
86 ContentSettingsType settings_type, 86 ContentSettingsType settings_type,
87 const std::string& resource_identifier) { 87 const std::string& resource_identifier) {
88 // Always send a message when |resource_identifier| is not empty, to tell the 88 // Always send a message when |resource_identifier| is not empty, to tell the
89 // browser which resource was blocked (otherwise the browser will only show 89 // browser which resource was blocked (otherwise the browser will only show
90 // the first resource to be blocked, and none that are blocked at a later 90 // the first resource to be blocked, and none that are blocked at a later
91 // time). 91 // time).
92 if (!content_blocked_[settings_type] || !resource_identifier.empty()) { 92 if (!content_blocked_[settings_type] || !resource_identifier.empty()) {
93 content_blocked_[settings_type] = true; 93 content_blocked_[settings_type] = true;
94 Send(new ViewHostMsg_ContentBlocked(routing_id(), settings_type, 94 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type,
95 resource_identifier)); 95 resource_identifier));
96 } 96 }
97 } 97 }
98 98
99 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { 99 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) {
100 bool handled = true; 100 bool handled = true;
101 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) 101 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message)
102 // Don't swallow LoadBlockedPlugins messages, as they're sent to every 102 // Don't swallow LoadBlockedPlugins messages, as they're sent to every
103 // blocked plugin. 103 // blocked plugin.
104 IPC_MESSAGE_HANDLER_GENERIC(ViewMsg_LoadBlockedPlugins, 104 IPC_MESSAGE_HANDLER_GENERIC(ChromeViewMsg_LoadBlockedPlugins,
105 OnLoadBlockedPlugins(); handled = false) 105 OnLoadBlockedPlugins(); handled = false)
106 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, 106 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingsForLoadingURL,
107 OnSetContentSettingsForLoadingURL) 107 OnSetContentSettingsForLoadingURL)
108 IPC_MESSAGE_UNHANDLED(handled = false) 108 IPC_MESSAGE_UNHANDLED(handled = false)
109 IPC_END_MESSAGE_MAP() 109 IPC_END_MESSAGE_MAP()
110 return handled; 110 return handled;
111 } 111 }
112 112
113 void ContentSettingsObserver::DidCommitProvisionalLoad( 113 void ContentSettingsObserver::DidCommitProvisionalLoad(
114 WebFrame* frame, bool is_new_navigation) { 114 WebFrame* frame, bool is_new_navigation) {
115 if (frame->parent()) 115 if (frame->parent())
116 return; // Not a top-level navigation. 116 return; // Not a top-level navigation.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 bool ContentSettingsObserver::AllowDatabase(WebFrame* frame, 169 bool ContentSettingsObserver::AllowDatabase(WebFrame* frame,
170 const WebString& name, 170 const WebString& name,
171 const WebString& display_name, 171 const WebString& display_name,
172 unsigned long estimated_size) { 172 unsigned long estimated_size) {
173 if (frame->document().securityOrigin().isEmpty() || 173 if (frame->document().securityOrigin().isEmpty() ||
174 frame->top()->document().securityOrigin().isEmpty()) 174 frame->top()->document().securityOrigin().isEmpty())
175 return false; // Uninitialized document. 175 return false; // Uninitialized document.
176 176
177 bool result = false; 177 bool result = false;
178 Send(new ViewHostMsg_AllowDatabase( 178 Send(new ChromeViewHostMsg_AllowDatabase(
179 routing_id(), GURL(frame->document().securityOrigin().toString()), 179 routing_id(), GURL(frame->document().securityOrigin().toString()),
180 GURL(frame->top()->document().securityOrigin().toString()), 180 GURL(frame->top()->document().securityOrigin().toString()),
181 name, display_name, &result)); 181 name, display_name, &result));
182 return result; 182 return result;
183 } 183 }
184 184
185 bool ContentSettingsObserver::AllowFileSystem(WebFrame* frame) { 185 bool ContentSettingsObserver::AllowFileSystem(WebFrame* frame) {
186 if (frame->document().securityOrigin().isEmpty() || 186 if (frame->document().securityOrigin().isEmpty() ||
187 frame->top()->document().securityOrigin().isEmpty()) 187 frame->top()->document().securityOrigin().isEmpty())
188 return false; // Uninitialized document. 188 return false; // Uninitialized document.
189 189
190 bool result = false; 190 bool result = false;
191 Send(new ViewHostMsg_AllowFileSystem( 191 Send(new ChromeViewHostMsg_AllowFileSystem(
192 routing_id(), GURL(frame->document().securityOrigin().toString()), 192 routing_id(), GURL(frame->document().securityOrigin().toString()),
193 GURL(frame->top()->document().securityOrigin().toString()), &result)); 193 GURL(frame->top()->document().securityOrigin().toString()), &result));
194 return result; 194 return result;
195 } 195 }
196 196
197 bool ContentSettingsObserver::AllowImages(WebFrame* frame, 197 bool ContentSettingsObserver::AllowImages(WebFrame* frame,
198 bool enabled_per_settings) { 198 bool enabled_per_settings) {
199 if (enabled_per_settings && 199 if (enabled_per_settings &&
200 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) { 200 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) {
201 return true; 201 return true;
202 } 202 }
203 203
204 if (IsWhitelistedForContentSettings(frame)) 204 if (IsWhitelistedForContentSettings(frame))
205 return true; 205 return true;
206 206
207 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); 207 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
208 return false; // Other protocols fall through here. 208 return false; // Other protocols fall through here.
209 } 209 }
210 210
211 bool ContentSettingsObserver::AllowIndexedDB(WebFrame* frame, 211 bool ContentSettingsObserver::AllowIndexedDB(WebFrame* frame,
212 const WebString& name, 212 const WebString& name,
213 const WebSecurityOrigin& origin) { 213 const WebSecurityOrigin& origin) {
214 if (frame->document().securityOrigin().isEmpty() || 214 if (frame->document().securityOrigin().isEmpty() ||
215 frame->top()->document().securityOrigin().isEmpty()) 215 frame->top()->document().securityOrigin().isEmpty())
216 return false; // Uninitialized document. 216 return false; // Uninitialized document.
217 217
218 bool result = false; 218 bool result = false;
219 Send(new ViewHostMsg_AllowIndexedDB( 219 Send(new ChromeViewHostMsg_AllowIndexedDB(
220 routing_id(), GURL(frame->document().securityOrigin().toString()), 220 routing_id(), GURL(frame->document().securityOrigin().toString()),
221 GURL(frame->top()->document().securityOrigin().toString()), 221 GURL(frame->top()->document().securityOrigin().toString()),
222 name, &result)); 222 name, &result));
223 return result; 223 return result;
224 } 224 }
225 225
226 bool ContentSettingsObserver::AllowPlugins(WebFrame* frame, 226 bool ContentSettingsObserver::AllowPlugins(WebFrame* frame,
227 bool enabled_per_settings) { 227 bool enabled_per_settings) {
228 return enabled_per_settings; 228 return enabled_per_settings;
229 } 229 }
(...skipping 17 matching lines...) Expand all
247 return false; // Uninitialized document. 247 return false; // Uninitialized document.
248 bool result = false; 248 bool result = false;
249 249
250 StoragePermissionsKey key( 250 StoragePermissionsKey key(
251 GURL(frame->document().securityOrigin().toString()), local); 251 GURL(frame->document().securityOrigin().toString()), local);
252 std::map<StoragePermissionsKey, bool>::const_iterator permissions = 252 std::map<StoragePermissionsKey, bool>::const_iterator permissions =
253 cached_storage_permissions_.find(key); 253 cached_storage_permissions_.find(key);
254 if (permissions != cached_storage_permissions_.end()) 254 if (permissions != cached_storage_permissions_.end())
255 return permissions->second; 255 return permissions->second;
256 256
257 Send(new ViewHostMsg_AllowDOMStorage( 257 Send(new ChromeViewHostMsg_AllowDOMStorage(
258 routing_id(), GURL(frame->document().securityOrigin().toString()), 258 routing_id(), GURL(frame->document().securityOrigin().toString()),
259 GURL(frame->top()->document().securityOrigin().toString()), 259 GURL(frame->top()->document().securityOrigin().toString()),
260 local ? DOM_STORAGE_LOCAL : DOM_STORAGE_SESSION, 260 local ? DOM_STORAGE_LOCAL : DOM_STORAGE_SESSION,
261 &result)); 261 &result));
262 cached_storage_permissions_[key] = result; 262 cached_storage_permissions_[key] = result;
263 return result; 263 return result;
264 } 264 }
265 265
266 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) { 266 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) {
267 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); 267 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string());
(...skipping 18 matching lines...) Expand all
286 // CONTENT_SETTING_ASK is only valid for cookies. 286 // CONTENT_SETTING_ASK is only valid for cookies.
287 return current_content_settings_.settings[settings_type] != 287 return current_content_settings_.settings[settings_type] !=
288 CONTENT_SETTING_BLOCK; 288 CONTENT_SETTING_BLOCK;
289 } 289 }
290 290
291 void ContentSettingsObserver::ClearBlockedContentSettings() { 291 void ContentSettingsObserver::ClearBlockedContentSettings() {
292 for (size_t i = 0; i < arraysize(content_blocked_); ++i) 292 for (size_t i = 0; i < arraysize(content_blocked_); ++i)
293 content_blocked_[i] = false; 293 content_blocked_[i] = false;
294 cached_storage_permissions_.clear(); 294 cached_storage_permissions_.clear();
295 } 295 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.cc ('k') | chrome/renderer/content_settings_observer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698