| 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 "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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 allow_displaying_insecure_content_(false), | 163 allow_displaying_insecure_content_(false), |
| 164 allow_running_insecure_content_(false), | 164 allow_running_insecure_content_(false), |
| 165 content_setting_rules_(NULL), | 165 content_setting_rules_(NULL), |
| 166 is_interstitial_page_(false), | 166 is_interstitial_page_(false), |
| 167 npapi_plugins_blocked_(false), | 167 npapi_plugins_blocked_(false), |
| 168 current_request_id_(0), | 168 current_request_id_(0), |
| 169 should_whitelist_(should_whitelist) { | 169 should_whitelist_(should_whitelist) { |
| 170 ClearBlockedContentSettings(); | 170 ClearBlockedContentSettings(); |
| 171 render_frame->GetWebFrame()->setContentSettingsClient(this); | 171 render_frame->GetWebFrame()->setContentSettingsClient(this); |
| 172 | 172 |
| 173 if (render_frame->GetRenderView()->GetMainRenderFrame() != render_frame) { | 173 content::RenderFrame* main_frame = |
| 174 render_frame->GetRenderView()->GetMainRenderFrame(); |
| 175 // TODO(nasko): The main frame is not guaranteed to be in the same process |
| 176 // with this frame with --site-per-process. This code needs to be updated |
| 177 // to handle this case. See https://crbug.com/496670. |
| 178 if (main_frame && main_frame != render_frame) { |
| 174 // Copy all the settings from the main render frame to avoid race conditions | 179 // Copy all the settings from the main render frame to avoid race conditions |
| 175 // when initializing this data. See http://crbug.com/333308. | 180 // when initializing this data. See https://crbug.com/333308. |
| 176 ContentSettingsObserver* parent = ContentSettingsObserver::Get( | 181 ContentSettingsObserver* parent = ContentSettingsObserver::Get(main_frame); |
| 177 render_frame->GetRenderView()->GetMainRenderFrame()); | |
| 178 allow_displaying_insecure_content_ = | 182 allow_displaying_insecure_content_ = |
| 179 parent->allow_displaying_insecure_content_; | 183 parent->allow_displaying_insecure_content_; |
| 180 allow_running_insecure_content_ = parent->allow_running_insecure_content_; | 184 allow_running_insecure_content_ = parent->allow_running_insecure_content_; |
| 181 temporarily_allowed_plugins_ = parent->temporarily_allowed_plugins_; | 185 temporarily_allowed_plugins_ = parent->temporarily_allowed_plugins_; |
| 182 is_interstitial_page_ = parent->is_interstitial_page_; | 186 is_interstitial_page_ = parent->is_interstitial_page_; |
| 183 npapi_plugins_blocked_ = parent->npapi_plugins_blocked_; | 187 npapi_plugins_blocked_ = parent->npapi_plugins_blocked_; |
| 184 } | 188 } |
| 185 } | 189 } |
| 186 | 190 |
| 187 ContentSettingsObserver::~ContentSettingsObserver() { | 191 ContentSettingsObserver::~ContentSettingsObserver() { |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 715 |
| 712 // If the scheme is file:, an empty file name indicates a directory listing, | 716 // If the scheme is file:, an empty file name indicates a directory listing, |
| 713 // which requires JavaScript to function properly. | 717 // which requires JavaScript to function properly. |
| 714 if (EqualsASCII(origin.protocol(), url::kFileScheme)) { | 718 if (EqualsASCII(origin.protocol(), url::kFileScheme)) { |
| 715 return document_url.SchemeIs(url::kFileScheme) && | 719 return document_url.SchemeIs(url::kFileScheme) && |
| 716 document_url.ExtractFileName().empty(); | 720 document_url.ExtractFileName().empty(); |
| 717 } | 721 } |
| 718 | 722 |
| 719 return false; | 723 return false; |
| 720 } | 724 } |
| OLD | NEW |