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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 : content::RenderFrameObserver(render_frame), | 148 : content::RenderFrameObserver(render_frame), |
149 content::RenderFrameObserverTracker<ContentSettingsObserver>( | 149 content::RenderFrameObserverTracker<ContentSettingsObserver>( |
150 render_frame), | 150 render_frame), |
151 extension_dispatcher_(extension_dispatcher), | 151 extension_dispatcher_(extension_dispatcher), |
152 allow_displaying_insecure_content_(false), | 152 allow_displaying_insecure_content_(false), |
153 allow_running_insecure_content_(false), | 153 allow_running_insecure_content_(false), |
154 content_setting_rules_(NULL), | 154 content_setting_rules_(NULL), |
155 is_interstitial_page_(false), | 155 is_interstitial_page_(false), |
156 npapi_plugins_blocked_(false) { | 156 npapi_plugins_blocked_(false) { |
157 ClearBlockedContentSettings(); | 157 ClearBlockedContentSettings(); |
| 158 render_frame->GetWebFrame()->setPermissionClient(this); |
158 } | 159 } |
159 | 160 |
160 ContentSettingsObserver::~ContentSettingsObserver() { | 161 ContentSettingsObserver::~ContentSettingsObserver() { |
161 } | 162 } |
162 | 163 |
163 void ContentSettingsObserver::SetContentSettingRules( | 164 void ContentSettingsObserver::SetContentSettingRules( |
164 const RendererContentSettingRules* content_setting_rules) { | 165 const RendererContentSettingRules* content_setting_rules) { |
165 content_setting_rules_ = content_setting_rules; | 166 content_setting_rules_ = content_setting_rules; |
166 } | 167 } |
167 | 168 |
168 bool ContentSettingsObserver::IsPluginTemporarilyAllowed( | 169 bool ContentSettingsObserver::IsPluginTemporarilyAllowed( |
169 const std::string& identifier) { | 170 const std::string& identifier) { |
170 // If the empty string is in here, it means all plug-ins are allowed. | 171 // If the empty string is in here, it means all plug-ins are allowed. |
171 // TODO(bauerb): Remove this once we only pass in explicit identifiers. | 172 // TODO(bauerb): Remove this once we only pass in explicit identifiers. |
172 return (temporarily_allowed_plugins_.find(identifier) != | 173 return (temporarily_allowed_plugins_.find(identifier) != |
173 temporarily_allowed_plugins_.end()) || | 174 temporarily_allowed_plugins_.end()) || |
174 (temporarily_allowed_plugins_.find(std::string()) != | 175 (temporarily_allowed_plugins_.find(std::string()) != |
175 temporarily_allowed_plugins_.end()); | 176 temporarily_allowed_plugins_.end()); |
176 } | 177 } |
177 | 178 |
178 void ContentSettingsObserver::DidBlockContentType( | 179 void ContentSettingsObserver::DidBlockContentType( |
179 ContentSettingsType settings_type) { | 180 ContentSettingsType settings_type) { |
180 if (!content_blocked_[settings_type]) { | 181 if (!content_blocked_[settings_type]) { |
181 content_blocked_[settings_type] = true; | 182 content_blocked_[settings_type] = true; |
182 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type)); | 183 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type)); |
183 } | 184 } |
184 } | 185 } |
185 | 186 |
186 void ContentSettingsObserver::WebFrameCreated(blink::WebFrame* frame) { | |
187 frame->setPermissionClient(this); | |
188 } | |
189 | |
190 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { | 187 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { |
191 bool handled = true; | 188 bool handled = true; |
192 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) | 189 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) |
193 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) | 190 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) |
194 IPC_MESSAGE_HANDLER(ChromeViewMsg_NPAPINotSupported, OnNPAPINotSupported) | 191 IPC_MESSAGE_HANDLER(ChromeViewMsg_NPAPINotSupported, OnNPAPINotSupported) |
195 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent, | 192 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent, |
196 OnSetAllowDisplayingInsecureContent) | 193 OnSetAllowDisplayingInsecureContent) |
197 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, | 194 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, |
198 OnSetAllowRunningInsecureContent) | 195 OnSetAllowRunningInsecureContent) |
199 IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame); | 196 IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 | 660 |
664 // If the scheme is file:, an empty file name indicates a directory listing, | 661 // If the scheme is file:, an empty file name indicates a directory listing, |
665 // which requires JavaScript to function properly. | 662 // which requires JavaScript to function properly. |
666 if (EqualsASCII(origin.protocol(), content::kFileScheme)) { | 663 if (EqualsASCII(origin.protocol(), content::kFileScheme)) { |
667 return document_url.SchemeIs(content::kFileScheme) && | 664 return document_url.SchemeIs(content::kFileScheme) && |
668 document_url.ExtractFileName().empty(); | 665 document_url.ExtractFileName().empty(); |
669 } | 666 } |
670 | 667 |
671 return false; | 668 return false; |
672 } | 669 } |
OLD | NEW |