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

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

Issue 2167513002: Remove InsecureContentInfobarDelegate, which has been broken for a while (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix AW? Created 4 years, 5 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 "chrome/common/ssl_insecure_content.h" 7 #include "chrome/common/ssl_insecure_content.h"
8 #include "components/content_settings/content/common/content_settings_messages.h " 8 #include "components/content_settings/content/common/content_settings_messages.h "
9 #include "content/public/common/url_constants.h" 9 #include "content/public/common/url_constants.h"
10 #include "content/public/renderer/document_state.h" 10 #include "content/public/renderer/document_state.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 ContentSettingsObserver::ContentSettingsObserver( 83 ContentSettingsObserver::ContentSettingsObserver(
84 content::RenderFrame* render_frame, 84 content::RenderFrame* render_frame,
85 extensions::Dispatcher* extension_dispatcher, 85 extensions::Dispatcher* extension_dispatcher,
86 bool should_whitelist) 86 bool should_whitelist)
87 : content::RenderFrameObserver(render_frame), 87 : content::RenderFrameObserver(render_frame),
88 content::RenderFrameObserverTracker<ContentSettingsObserver>( 88 content::RenderFrameObserverTracker<ContentSettingsObserver>(
89 render_frame), 89 render_frame),
90 #if defined(ENABLE_EXTENSIONS) 90 #if defined(ENABLE_EXTENSIONS)
91 extension_dispatcher_(extension_dispatcher), 91 extension_dispatcher_(extension_dispatcher),
92 #endif 92 #endif
93 allow_displaying_insecure_content_(false),
94 allow_running_insecure_content_(false), 93 allow_running_insecure_content_(false),
95 content_setting_rules_(NULL), 94 content_setting_rules_(NULL),
96 is_interstitial_page_(false), 95 is_interstitial_page_(false),
97 current_request_id_(0), 96 current_request_id_(0),
98 should_whitelist_(should_whitelist) { 97 should_whitelist_(should_whitelist) {
99 ClearBlockedContentSettings(); 98 ClearBlockedContentSettings();
100 render_frame->GetWebFrame()->setContentSettingsClient(this); 99 render_frame->GetWebFrame()->setContentSettingsClient(this);
101 100
102 content::RenderFrame* main_frame = 101 content::RenderFrame* main_frame =
103 render_frame->GetRenderView()->GetMainRenderFrame(); 102 render_frame->GetRenderView()->GetMainRenderFrame();
104 // TODO(nasko): The main frame is not guaranteed to be in the same process 103 // TODO(nasko): The main frame is not guaranteed to be in the same process
105 // with this frame with --site-per-process. This code needs to be updated 104 // with this frame with --site-per-process. This code needs to be updated
106 // to handle this case. See https://crbug.com/496670. 105 // to handle this case. See https://crbug.com/496670.
107 if (main_frame && main_frame != render_frame) { 106 if (main_frame && main_frame != render_frame) {
108 // Copy all the settings from the main render frame to avoid race conditions 107 // Copy all the settings from the main render frame to avoid race conditions
109 // when initializing this data. See https://crbug.com/333308. 108 // when initializing this data. See https://crbug.com/333308.
110 ContentSettingsObserver* parent = ContentSettingsObserver::Get(main_frame); 109 ContentSettingsObserver* parent = ContentSettingsObserver::Get(main_frame);
111 allow_displaying_insecure_content_ =
112 parent->allow_displaying_insecure_content_;
113 allow_running_insecure_content_ = parent->allow_running_insecure_content_; 110 allow_running_insecure_content_ = parent->allow_running_insecure_content_;
114 temporarily_allowed_plugins_ = parent->temporarily_allowed_plugins_; 111 temporarily_allowed_plugins_ = parent->temporarily_allowed_plugins_;
115 is_interstitial_page_ = parent->is_interstitial_page_; 112 is_interstitial_page_ = parent->is_interstitial_page_;
116 } 113 }
117 } 114 }
118 115
119 ContentSettingsObserver::~ContentSettingsObserver() { 116 ContentSettingsObserver::~ContentSettingsObserver() {
120 } 117 }
121 118
122 void ContentSettingsObserver::SetContentSettingRules( 119 void ContentSettingsObserver::SetContentSettingRules(
(...skipping 25 matching lines...) Expand all
148 blocked = true; 145 blocked = true;
149 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type, 146 Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type,
150 details)); 147 details));
151 } 148 }
152 } 149 }
153 150
154 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { 151 bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) {
155 bool handled = true; 152 bool handled = true;
156 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) 153 IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message)
157 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) 154 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial)
158 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent,
159 OnSetAllowDisplayingInsecureContent)
160 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, 155 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent,
161 OnSetAllowRunningInsecureContent) 156 OnSetAllowRunningInsecureContent)
162 IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame); 157 IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame);
163 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestFileSystemAccessAsyncResponse, 158 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestFileSystemAccessAsyncResponse,
164 OnRequestFileSystemAccessAsyncResponse) 159 OnRequestFileSystemAccessAsyncResponse)
165 IPC_MESSAGE_UNHANDLED(handled = false) 160 IPC_MESSAGE_UNHANDLED(handled = false)
166 IPC_END_MESSAGE_MAP() 161 IPC_END_MESSAGE_MAP()
167 if (handled) 162 if (handled)
168 return true; 163 return true;
169 164
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return allowed; 387 return allowed;
393 } 388 }
394 389
395 bool ContentSettingsObserver::allowMutationEvents(bool default_value) { 390 bool ContentSettingsObserver::allowMutationEvents(bool default_value) {
396 return IsPlatformApp() ? false : default_value; 391 return IsPlatformApp() ? false : default_value;
397 } 392 }
398 393
399 bool ContentSettingsObserver::allowDisplayingInsecureContent( 394 bool ContentSettingsObserver::allowDisplayingInsecureContent(
400 bool allowed_per_settings, 395 bool allowed_per_settings,
401 const blink::WebURL& resource_url) { 396 const blink::WebURL& resource_url) {
397 DCHECK(allowed_per_settings);
402 ReportInsecureContent(SslInsecureContentType::DISPLAY); 398 ReportInsecureContent(SslInsecureContentType::DISPLAY);
403 FilteredReportInsecureContentDisplayed(GURL(resource_url)); 399 FilteredReportInsecureContentDisplayed(GURL(resource_url));
404 400 return true;
405 if (allowed_per_settings || allow_displaying_insecure_content_)
406 return true;
407
408 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id()));
409
410 return false;
411 } 401 }
412 402
413 bool ContentSettingsObserver::allowRunningInsecureContent( 403 bool ContentSettingsObserver::allowRunningInsecureContent(
414 bool allowed_per_settings, 404 bool allowed_per_settings,
415 const blink::WebSecurityOrigin& origin, 405 const blink::WebSecurityOrigin& origin,
416 const blink::WebURL& resource_url) { 406 const blink::WebURL& resource_url) {
417 FilteredReportInsecureContentRan(GURL(resource_url)); 407 FilteredReportInsecureContentRan(GURL(resource_url));
418 408
419 if (!allow_running_insecure_content_ && !allowed_per_settings) { 409 if (!allow_running_insecure_content_ && !allowed_per_settings) {
420 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT); 410 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 443
454 void ContentSettingsObserver::OnLoadBlockedPlugins( 444 void ContentSettingsObserver::OnLoadBlockedPlugins(
455 const std::string& identifier) { 445 const std::string& identifier) {
456 temporarily_allowed_plugins_.insert(identifier); 446 temporarily_allowed_plugins_.insert(identifier);
457 } 447 }
458 448
459 void ContentSettingsObserver::OnSetAsInterstitial() { 449 void ContentSettingsObserver::OnSetAsInterstitial() {
460 is_interstitial_page_ = true; 450 is_interstitial_page_ = true;
461 } 451 }
462 452
463 void ContentSettingsObserver::OnSetAllowDisplayingInsecureContent(bool allow) {
464 allow_displaying_insecure_content_ = allow;
465 }
466
467 void ContentSettingsObserver::OnSetAllowRunningInsecureContent(bool allow) { 453 void ContentSettingsObserver::OnSetAllowRunningInsecureContent(bool allow) {
468 allow_running_insecure_content_ = allow; 454 allow_running_insecure_content_ = allow;
469 OnSetAllowDisplayingInsecureContent(allow);
470 } 455 }
471 456
472 void ContentSettingsObserver::OnReloadFrame() { 457 void ContentSettingsObserver::OnReloadFrame() {
473 DCHECK(!render_frame()->GetWebFrame()->parent()) << 458 DCHECK(!render_frame()->GetWebFrame()->parent()) <<
474 "Should only be called on the main frame"; 459 "Should only be called on the main frame";
475 render_frame()->GetWebFrame()->reload(); 460 render_frame()->GetWebFrame()->reload();
476 } 461 }
477 462
478 void ContentSettingsObserver::OnRequestFileSystemAccessAsyncResponse( 463 void ContentSettingsObserver::OnRequestFileSystemAccessAsyncResponse(
479 int request_id, 464 int request_id,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 546
562 // If the scheme is file:, an empty file name indicates a directory listing, 547 // If the scheme is file:, an empty file name indicates a directory listing,
563 // which requires JavaScript to function properly. 548 // which requires JavaScript to function properly.
564 if (base::EqualsASCII(protocol, url::kFileScheme)) { 549 if (base::EqualsASCII(protocol, url::kFileScheme)) {
565 return document_url.SchemeIs(url::kFileScheme) && 550 return document_url.SchemeIs(url::kFileScheme) &&
566 document_url.ExtractFileName().empty(); 551 document_url.ExtractFileName().empty();
567 } 552 }
568 553
569 return false; 554 return false;
570 } 555 }
OLDNEW
« no previous file with comments | « chrome/renderer/content_settings_observer.h ('k') | components/content_settings/content/common/content_settings_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698