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

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

Issue 1862513003: Remove NPAPI from browser and utility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
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 "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "components/content_settings/content/common/content_settings_messages.h " 9 #include "components/content_settings/content/common/content_settings_messages.h "
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 : content::RenderFrameObserver(render_frame), 135 : content::RenderFrameObserver(render_frame),
136 content::RenderFrameObserverTracker<ContentSettingsObserver>( 136 content::RenderFrameObserverTracker<ContentSettingsObserver>(
137 render_frame), 137 render_frame),
138 #if defined(ENABLE_EXTENSIONS) 138 #if defined(ENABLE_EXTENSIONS)
139 extension_dispatcher_(extension_dispatcher), 139 extension_dispatcher_(extension_dispatcher),
140 #endif 140 #endif
141 allow_displaying_insecure_content_(false), 141 allow_displaying_insecure_content_(false),
142 allow_running_insecure_content_(false), 142 allow_running_insecure_content_(false),
143 content_setting_rules_(NULL), 143 content_setting_rules_(NULL),
144 is_interstitial_page_(false), 144 is_interstitial_page_(false),
145 npapi_plugins_blocked_(false),
146 current_request_id_(0), 145 current_request_id_(0),
147 should_whitelist_(should_whitelist) { 146 should_whitelist_(should_whitelist) {
148 ClearBlockedContentSettings(); 147 ClearBlockedContentSettings();
149 render_frame->GetWebFrame()->setContentSettingsClient(this); 148 render_frame->GetWebFrame()->setContentSettingsClient(this);
150 149
151 content::RenderFrame* main_frame = 150 content::RenderFrame* main_frame =
152 render_frame->GetRenderView()->GetMainRenderFrame(); 151 render_frame->GetRenderView()->GetMainRenderFrame();
153 // TODO(nasko): The main frame is not guaranteed to be in the same process 152 // TODO(nasko): The main frame is not guaranteed to be in the same process
154 // with this frame with --site-per-process. This code needs to be updated 153 // with this frame with --site-per-process. This code needs to be updated
155 // to handle this case. See https://crbug.com/496670. 154 // to handle this case. See https://crbug.com/496670.
156 if (main_frame && main_frame != render_frame) { 155 if (main_frame && main_frame != render_frame) {
157 // Copy all the settings from the main render frame to avoid race conditions 156 // Copy all the settings from the main render frame to avoid race conditions
158 // when initializing this data. See https://crbug.com/333308. 157 // when initializing this data. See https://crbug.com/333308.
159 ContentSettingsObserver* parent = ContentSettingsObserver::Get(main_frame); 158 ContentSettingsObserver* parent = ContentSettingsObserver::Get(main_frame);
160 allow_displaying_insecure_content_ = 159 allow_displaying_insecure_content_ =
161 parent->allow_displaying_insecure_content_; 160 parent->allow_displaying_insecure_content_;
162 allow_running_insecure_content_ = parent->allow_running_insecure_content_; 161 allow_running_insecure_content_ = parent->allow_running_insecure_content_;
163 temporarily_allowed_plugins_ = parent->temporarily_allowed_plugins_; 162 temporarily_allowed_plugins_ = parent->temporarily_allowed_plugins_;
164 is_interstitial_page_ = parent->is_interstitial_page_; 163 is_interstitial_page_ = parent->is_interstitial_page_;
165 npapi_plugins_blocked_ = parent->npapi_plugins_blocked_;
166 } 164 }
167 } 165 }
168 166
169 ContentSettingsObserver::~ContentSettingsObserver() { 167 ContentSettingsObserver::~ContentSettingsObserver() {
170 } 168 }
171 169
172 void ContentSettingsObserver::SetContentSettingRules( 170 void ContentSettingsObserver::SetContentSettingRules(
173 const RendererContentSettingRules* content_setting_rules) { 171 const RendererContentSettingRules* content_setting_rules) {
174 content_setting_rules_ = content_setting_rules; 172 content_setting_rules_ = content_setting_rules;
175 } 173 }
(...skipping 22 matching lines...) Expand all
198 blocked = true; 196 blocked = true;
199 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type, 197 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type,
200 details)); 198 details));
201 } 199 }
202 } 200 }
203 201
204 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { 202 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) {
205 bool handled = true; 203 bool handled = true;
206 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) 204 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message)
207 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) 205 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial)
208 IPC_MESSAGE_HANDLER(ChromeViewMsg_NPAPINotSupported, OnNPAPINotSupported)
209 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent, 206 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent,
210 OnSetAllowDisplayingInsecureContent) 207 OnSetAllowDisplayingInsecureContent)
211 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, 208 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent,
212 OnSetAllowRunningInsecureContent) 209 OnSetAllowRunningInsecureContent)
213 IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame); 210 IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame);
214 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestFileSystemAccessAsyncResponse, 211 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestFileSystemAccessAsyncResponse,
215 OnRequestFileSystemAccessAsyncResponse) 212 OnRequestFileSystemAccessAsyncResponse)
216 IPC_MESSAGE_UNHANDLED(handled = false) 213 IPC_MESSAGE_UNHANDLED(handled = false)
217 IPC_END_MESSAGE_MAP() 214 IPC_END_MESSAGE_MAP()
218 if (handled) 215 if (handled)
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 494 }
498 495
499 void ContentSettingsObserver::didNotAllowPlugins() { 496 void ContentSettingsObserver::didNotAllowPlugins() {
500 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); 497 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS);
501 } 498 }
502 499
503 void ContentSettingsObserver::didNotAllowScript() { 500 void ContentSettingsObserver::didNotAllowScript() {
504 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); 501 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
505 } 502 }
506 503
507 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const {
508 return npapi_plugins_blocked_;
509 }
510
511 void ContentSettingsObserver::OnLoadBlockedPlugins( 504 void ContentSettingsObserver::OnLoadBlockedPlugins(
512 const std::string& identifier) { 505 const std::string& identifier) {
513 temporarily_allowed_plugins_.insert(identifier); 506 temporarily_allowed_plugins_.insert(identifier);
514 } 507 }
515 508
516 void ContentSettingsObserver::OnSetAsInterstitial() { 509 void ContentSettingsObserver::OnSetAsInterstitial() {
517 is_interstitial_page_ = true; 510 is_interstitial_page_ = true;
518 } 511 }
519 512
520 void ContentSettingsObserver::OnNPAPINotSupported() {
521 npapi_plugins_blocked_ = true;
522 }
523
524 void ContentSettingsObserver::OnSetAllowDisplayingInsecureContent(bool allow) { 513 void ContentSettingsObserver::OnSetAllowDisplayingInsecureContent(bool allow) {
525 allow_displaying_insecure_content_ = allow; 514 allow_displaying_insecure_content_ = allow;
526 } 515 }
527 516
528 void ContentSettingsObserver::OnSetAllowRunningInsecureContent(bool allow) { 517 void ContentSettingsObserver::OnSetAllowRunningInsecureContent(bool allow) {
529 allow_running_insecure_content_ = allow; 518 allow_running_insecure_content_ = allow;
530 OnSetAllowDisplayingInsecureContent(allow); 519 OnSetAllowDisplayingInsecureContent(allow);
531 } 520 }
532 521
533 void ContentSettingsObserver::OnReloadFrame() { 522 void ContentSettingsObserver::OnReloadFrame() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 611
623 // If the scheme is file:, an empty file name indicates a directory listing, 612 // If the scheme is file:, an empty file name indicates a directory listing,
624 // which requires JavaScript to function properly. 613 // which requires JavaScript to function properly.
625 if (base::EqualsASCII(protocol, url::kFileScheme)) { 614 if (base::EqualsASCII(protocol, url::kFileScheme)) {
626 return document_url.SchemeIs(url::kFileScheme) && 615 return document_url.SchemeIs(url::kFileScheme) &&
627 document_url.ExtractFileName().empty(); 616 document_url.ExtractFileName().empty();
628 } 617 }
629 618
630 return false; 619 return false;
631 } 620 }
OLDNEW
« no previous file with comments | « chrome/renderer/content_settings_observer.h ('k') | chrome/test/data/extensions/uitest/plugins/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698