| OLD | NEW |
| 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/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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { | 98 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { |
| 99 bool handled = true; | 99 bool handled = true; |
| 100 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) | 100 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) |
| 101 // Don't swallow LoadBlockedPlugins messages, as they're sent to every | 101 // Don't swallow LoadBlockedPlugins messages, as they're sent to every |
| 102 // blocked plugin. | 102 // blocked plugin. |
| 103 IPC_MESSAGE_HANDLER_GENERIC(ChromeViewMsg_LoadBlockedPlugins, | 103 IPC_MESSAGE_HANDLER_GENERIC(ChromeViewMsg_LoadBlockedPlugins, |
| 104 OnLoadBlockedPlugins(); handled = false) | 104 OnLoadBlockedPlugins(); handled = false) |
| 105 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) |
| 105 IPC_MESSAGE_UNHANDLED(handled = false) | 106 IPC_MESSAGE_UNHANDLED(handled = false) |
| 106 IPC_END_MESSAGE_MAP() | 107 IPC_END_MESSAGE_MAP() |
| 107 return handled; | 108 return handled; |
| 108 } | 109 } |
| 109 | 110 |
| 110 void ContentSettingsObserver::DidCommitProvisionalLoad( | 111 void ContentSettingsObserver::DidCommitProvisionalLoad( |
| 111 WebFrame* frame, bool is_new_navigation) { | 112 WebFrame* frame, bool is_new_navigation) { |
| 112 if (frame->parent()) | 113 if (frame->parent()) |
| 113 return; // Not a top-level navigation. | 114 return; // Not a top-level navigation. |
| 114 | 115 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 274 } |
| 274 | 275 |
| 275 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) { | 276 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) { |
| 276 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); | 277 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
| 277 } | 278 } |
| 278 | 279 |
| 279 void ContentSettingsObserver::DidNotAllowScript(WebFrame* frame) { | 280 void ContentSettingsObserver::DidNotAllowScript(WebFrame* frame) { |
| 280 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); | 281 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); |
| 281 } | 282 } |
| 282 | 283 |
| 283 void ContentSettingsObserver::SetAsInterstitial() { | |
| 284 is_interstitial_page_ = true; | |
| 285 } | |
| 286 | |
| 287 void ContentSettingsObserver::OnLoadBlockedPlugins() { | 284 void ContentSettingsObserver::OnLoadBlockedPlugins() { |
| 288 plugins_temporarily_allowed_ = true; | 285 plugins_temporarily_allowed_ = true; |
| 289 } | 286 } |
| 290 | 287 |
| 288 void ContentSettingsObserver::OnSetAsInterstitial() { |
| 289 is_interstitial_page_ = true; |
| 290 } |
| 291 |
| 291 void ContentSettingsObserver::ClearBlockedContentSettings() { | 292 void ContentSettingsObserver::ClearBlockedContentSettings() { |
| 292 for (size_t i = 0; i < arraysize(content_blocked_); ++i) | 293 for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
| 293 content_blocked_[i] = false; | 294 content_blocked_[i] = false; |
| 294 cached_storage_permissions_.clear(); | 295 cached_storage_permissions_.clear(); |
| 295 cached_script_permissions_.clear(); | 296 cached_script_permissions_.clear(); |
| 296 } | 297 } |
| 297 | 298 |
| 298 bool ContentSettingsObserver::IsWhitelistedForContentSettings(WebFrame* frame) { | 299 bool ContentSettingsObserver::IsWhitelistedForContentSettings(WebFrame* frame) { |
| 299 return IsWhitelistedForContentSettings(frame->document().securityOrigin(), | 300 return IsWhitelistedForContentSettings(frame->document().securityOrigin(), |
| 300 frame->document().url()); | 301 frame->document().url()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 323 const char* kDirProtocols[] = { chrome::kFtpScheme, chrome::kFileScheme }; | 324 const char* kDirProtocols[] = { chrome::kFtpScheme, chrome::kFileScheme }; |
| 324 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { | 325 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { |
| 325 if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { | 326 if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { |
| 326 return document_url.SchemeIs(kDirProtocols[i]) && | 327 return document_url.SchemeIs(kDirProtocols[i]) && |
| 327 document_url.ExtractFileName().empty(); | 328 document_url.ExtractFileName().empty(); |
| 328 } | 329 } |
| 329 } | 330 } |
| 330 | 331 |
| 331 return false; | 332 return false; |
| 332 } | 333 } |
| OLD | NEW |