| OLD | NEW |
| 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 "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/public/renderer/document_state.h" | 9 #include "content/public/renderer/document_state.h" |
| 10 #include "content/public/renderer/navigation_state.h" | 10 #include "content/public/renderer/navigation_state.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void ContentSettingsObserver::DidBlockContentType( | 94 void ContentSettingsObserver::DidBlockContentType( |
| 95 ContentSettingsType settings_type, | 95 ContentSettingsType settings_type, |
| 96 const std::string& resource_identifier) { | 96 const std::string& resource_identifier) { |
| 97 // Always send a message when |resource_identifier| is not empty, to tell the | 97 // Always send a message when |resource_identifier| is not empty, to tell the |
| 98 // browser which resource was blocked (otherwise the browser will only show | 98 // browser which resource was blocked (otherwise the browser will only show |
| 99 // the first resource to be blocked, and none that are blocked at a later | 99 // the first resource to be blocked, and none that are blocked at a later |
| 100 // time). | 100 // time). |
| 101 if (!content_blocked_[settings_type] || !resource_identifier.empty()) { | 101 if (!content_blocked_[settings_type] || !resource_identifier.empty()) { |
| 102 content_blocked_[settings_type] = true; | 102 content_blocked_[settings_type] = true; |
| 103 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type, | 103 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type, |
| 104 resource_identifier)); | 104 resource_identifier)); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { | 108 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { |
| 109 bool handled = true; | 109 bool handled = true; |
| 110 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) | 110 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) |
| 111 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) | 111 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) |
| 112 IPC_MESSAGE_UNHANDLED(handled = false) | 112 IPC_MESSAGE_UNHANDLED(handled = false) |
| 113 IPC_END_MESSAGE_MAP() | 113 IPC_END_MESSAGE_MAP() |
| 114 if (handled) | 114 if (handled) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 return permissions->second; | 281 return permissions->second; |
| 282 | 282 |
| 283 Send(new ChromeViewHostMsg_AllowDOMStorage( | 283 Send(new ChromeViewHostMsg_AllowDOMStorage( |
| 284 routing_id(), GURL(frame->document().securityOrigin().toString()), | 284 routing_id(), GURL(frame->document().securityOrigin().toString()), |
| 285 GURL(frame->top()->document().securityOrigin().toString()), | 285 GURL(frame->top()->document().securityOrigin().toString()), |
| 286 local, &result)); | 286 local, &result)); |
| 287 cached_storage_permissions_[key] = result; | 287 cached_storage_permissions_[key] = result; |
| 288 return result; | 288 return result; |
| 289 } | 289 } |
| 290 | 290 |
| 291 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) { | 291 void ContentSettingsObserver::DidNotAllowPlugins() { |
| 292 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); | 292 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void ContentSettingsObserver::DidNotAllowScript(WebFrame* frame) { | 295 void ContentSettingsObserver::DidNotAllowScript() { |
| 296 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); | 296 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void ContentSettingsObserver::DidNotAllowMixedScript() { |
| 300 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, std::string()); |
| 301 } |
| 302 |
| 299 void ContentSettingsObserver::OnLoadBlockedPlugins( | 303 void ContentSettingsObserver::OnLoadBlockedPlugins( |
| 300 const std::string& identifier) { | 304 const std::string& identifier) { |
| 301 temporarily_allowed_plugins_.insert(identifier); | 305 temporarily_allowed_plugins_.insert(identifier); |
| 302 } | 306 } |
| 303 | 307 |
| 304 void ContentSettingsObserver::OnSetAsInterstitial() { | 308 void ContentSettingsObserver::OnSetAsInterstitial() { |
| 305 is_interstitial_page_ = true; | 309 is_interstitial_page_ = true; |
| 306 } | 310 } |
| 307 | 311 |
| 308 void ContentSettingsObserver::ClearBlockedContentSettings() { | 312 void ContentSettingsObserver::ClearBlockedContentSettings() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 351 |
| 348 // If the scheme is file:, an empty file name indicates a directory listing, | 352 // If the scheme is file:, an empty file name indicates a directory listing, |
| 349 // which requires JavaScript to function properly. | 353 // which requires JavaScript to function properly. |
| 350 if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) { | 354 if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) { |
| 351 return document_url.SchemeIs(chrome::kFileScheme) && | 355 return document_url.SchemeIs(chrome::kFileScheme) && |
| 352 document_url.ExtractFileName().empty(); | 356 document_url.ExtractFileName().empty(); |
| 353 } | 357 } |
| 354 | 358 |
| 355 return false; | 359 return false; |
| 356 } | 360 } |
| OLD | NEW |