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

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

Issue 106713004: Remove kEnableResourceContentSettings and all the code that uses it since it's been behind a flag f… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 7 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const std::string& identifier) { 89 const std::string& identifier) {
90 // If the empty string is in here, it means all plug-ins are allowed. 90 // If the empty string is in here, it means all plug-ins are allowed.
91 // TODO(bauerb): Remove this once we only pass in explicit identifiers. 91 // TODO(bauerb): Remove this once we only pass in explicit identifiers.
92 return (temporarily_allowed_plugins_.find(identifier) != 92 return (temporarily_allowed_plugins_.find(identifier) !=
93 temporarily_allowed_plugins_.end()) || 93 temporarily_allowed_plugins_.end()) ||
94 (temporarily_allowed_plugins_.find(std::string()) != 94 (temporarily_allowed_plugins_.find(std::string()) !=
95 temporarily_allowed_plugins_.end()); 95 temporarily_allowed_plugins_.end());
96 } 96 }
97 97
98 void ContentSettingsObserver::DidBlockContentType( 98 void ContentSettingsObserver::DidBlockContentType(
99 ContentSettingsType settings_type, 99 ContentSettingsType settings_type) {
100 const std::string& resource_identifier) { 100 if (!content_blocked_[settings_type]) {
101 // Always send a message when |resource_identifier| is not empty, to tell the
102 // browser which resource was blocked (otherwise the browser will only show
103 // the first resource to be blocked, and none that are blocked at a later
104 // time).
105 if (!content_blocked_[settings_type] || !resource_identifier.empty()) {
106 content_blocked_[settings_type] = true; 101 content_blocked_[settings_type] = true;
107 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type, 102 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type));
108 resource_identifier));
109 } 103 }
110 } 104 }
111 105
112 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { 106 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) {
113 bool handled = true; 107 bool handled = true;
114 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) 108 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message)
115 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) 109 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial)
116 IPC_MESSAGE_UNHANDLED(handled = false) 110 IPC_MESSAGE_UNHANDLED(handled = false)
117 IPC_END_MESSAGE_MAP() 111 IPC_END_MESSAGE_MAP()
118 if (handled) 112 if (handled)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return true; 185 return true;
192 186
193 if (content_setting_rules_) { 187 if (content_setting_rules_) {
194 GURL secondary_url(image_url); 188 GURL secondary_url(image_url);
195 allow = GetContentSettingFromRules( 189 allow = GetContentSettingFromRules(
196 content_setting_rules_->image_rules, 190 content_setting_rules_->image_rules,
197 frame, secondary_url) != CONTENT_SETTING_BLOCK; 191 frame, secondary_url) != CONTENT_SETTING_BLOCK;
198 } 192 }
199 } 193 }
200 if (!allow) 194 if (!allow)
201 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); 195 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES);
202 return allow; 196 return allow;
203 } 197 }
204 198
205 bool ContentSettingsObserver::AllowIndexedDB(WebFrame* frame, 199 bool ContentSettingsObserver::AllowIndexedDB(WebFrame* frame,
206 const WebString& name, 200 const WebString& name,
207 const WebSecurityOrigin& origin) { 201 const WebSecurityOrigin& origin) {
208 if (frame->document().securityOrigin().isUnique() || 202 if (frame->document().securityOrigin().isUnique() ||
209 frame->top()->document().securityOrigin().isUnique()) 203 frame->top()->document().securityOrigin().isUnique())
210 return false; 204 return false;
211 205
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 280
287 Send(new ChromeViewHostMsg_AllowDOMStorage( 281 Send(new ChromeViewHostMsg_AllowDOMStorage(
288 routing_id(), GURL(frame->document().securityOrigin().toString()), 282 routing_id(), GURL(frame->document().securityOrigin().toString()),
289 GURL(frame->top()->document().securityOrigin().toString()), 283 GURL(frame->top()->document().securityOrigin().toString()),
290 local, &result)); 284 local, &result));
291 cached_storage_permissions_[key] = result; 285 cached_storage_permissions_[key] = result;
292 return result; 286 return result;
293 } 287 }
294 288
295 void ContentSettingsObserver::DidNotAllowPlugins() { 289 void ContentSettingsObserver::DidNotAllowPlugins() {
296 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); 290 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS);
297 } 291 }
298 292
299 void ContentSettingsObserver::DidNotAllowScript() { 293 void ContentSettingsObserver::DidNotAllowScript() {
300 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); 294 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
301 } 295 }
302 296
303 void ContentSettingsObserver::DidNotAllowMixedScript() { 297 void ContentSettingsObserver::DidNotAllowMixedScript() {
304 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, std::string()); 298 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT);
305 } 299 }
306 300
307 void ContentSettingsObserver::BlockNPAPIPlugins() { 301 void ContentSettingsObserver::BlockNPAPIPlugins() {
308 npapi_plugins_blocked_ = true; 302 npapi_plugins_blocked_ = true;
309 } 303 }
310 304
311 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const { 305 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const {
312 return npapi_plugins_blocked_; 306 return npapi_plugins_blocked_;
313 } 307 }
314 308
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 366
373 // If the scheme is file:, an empty file name indicates a directory listing, 367 // If the scheme is file:, an empty file name indicates a directory listing,
374 // which requires JavaScript to function properly. 368 // which requires JavaScript to function properly.
375 if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) { 369 if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) {
376 return document_url.SchemeIs(chrome::kFileScheme) && 370 return document_url.SchemeIs(chrome::kFileScheme) &&
377 document_url.ExtractFileName().empty(); 371 document_url.ExtractFileName().empty();
378 } 372 }
379 373
380 return false; 374 return false;
381 } 375 }
OLDNEW
« no previous file with comments | « chrome/renderer/content_settings_observer.h ('k') | chrome/renderer/content_settings_observer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698