diff options
author | shuais@opera.com <shuais@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-21 12:25:34 +0000 |
---|---|---|
committer | shuais@opera.com <shuais@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-21 12:25:34 +0000 |
commit | 22b2898cbb451c40e3b4b64ffd8b38e6a531b2c1 (patch) | |
tree | 8b0bde7549130053a74c68c32706354e377f54f5 | |
parent | 0d5e23f84a2f31714e606a74d5b1aac39a39ae51 (diff) | |
download | chromium_src-22b2898cbb451c40e3b4b64ffd8b38e6a531b2c1.zip chromium_src-22b2898cbb451c40e3b4b64ffd8b38e6a531b2c1.tar.gz chromium_src-22b2898cbb451c40e3b4b64ffd8b38e6a531b2c1.tar.bz2 |
Add WebUIDataSourceImpl::DisableReplaceExistingSource
Currently when using WebUIDataSource object returned by content::WebUIDataSource::Create,
there is no way to override ShouldReplaceExistingSource for the URLDataSource object that
will be created by WebUIDataSource internally. As a result when WebUIDataSource of the same
type is added repeatedly for different instances of WebUI, the previous pending request on the data
source will be cancelled, resulting in broken WebUI page.
The New Tab Page in chromium doesn't suffer because it doesn't use WebUIDataSource,
however it's convinient and less work to use it for some WebUIs. It's also possible to work around
by avoiding adding WebUIDataSource repeatedly in the first place, but that is much more complicated
as we'll have to track is a certain WebUIDataSource already added or not for a given profile.
The proposed fix simply add the api to override ShouldReplaceExistingSource.
BUG=
Review URL: https://chromiumcodereview.appspot.com/22150004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218710 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/webui/web_ui_data_source_impl.cc | 10 | ||||
-rw-r--r-- | content/browser/webui/web_ui_data_source_impl.h | 2 | ||||
-rw-r--r-- | content/public/browser/web_ui_data_source.h | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/content/browser/webui/web_ui_data_source_impl.cc b/content/browser/webui/web_ui_data_source_impl.cc index b564e57..63e08bc 100644 --- a/content/browser/webui/web_ui_data_source_impl.cc +++ b/content/browser/webui/web_ui_data_source_impl.cc @@ -49,6 +49,9 @@ class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { return parent_->StartDataRequest(path, render_process_id, render_view_id, callback); } + virtual bool ShouldReplaceExistingSource() const OVERRIDE { + return parent_->replace_existing_source_; + } virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { return parent_->add_csp_; } @@ -81,7 +84,8 @@ WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name) object_src_set_(false), frame_src_set_(false), deny_xframe_options_(true), - disable_set_font_strings_(false) { + disable_set_font_strings_(false), + replace_existing_source_(true) { } WebUIDataSourceImpl::~WebUIDataSourceImpl() { @@ -134,6 +138,10 @@ void WebUIDataSourceImpl::SetRequestFilter( filter_callback_ = callback; } +void WebUIDataSourceImpl::DisableReplaceExistingSource() { + replace_existing_source_ = false; +} + void WebUIDataSourceImpl::DisableContentSecurityPolicy() { add_csp_ = false; } diff --git a/content/browser/webui/web_ui_data_source_impl.h b/content/browser/webui/web_ui_data_source_impl.h index 0b6f8a3..1f81004 100644 --- a/content/browser/webui/web_ui_data_source_impl.h +++ b/content/browser/webui/web_ui_data_source_impl.h @@ -42,6 +42,7 @@ class CONTENT_EXPORT WebUIDataSourceImpl virtual void SetDefaultResource(int resource_id) OVERRIDE; virtual void SetRequestFilter( const WebUIDataSource::HandleRequestCallback& callback) OVERRIDE; + virtual void DisableReplaceExistingSource() OVERRIDE; virtual void DisableContentSecurityPolicy() OVERRIDE; virtual void OverrideContentSecurityPolicyObjectSrc( const std::string& data) OVERRIDE; @@ -99,6 +100,7 @@ class CONTENT_EXPORT WebUIDataSourceImpl std::string frame_src_; bool deny_xframe_options_; bool disable_set_font_strings_; + bool replace_existing_source_; DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl); }; diff --git a/content/public/browser/web_ui_data_source.h b/content/public/browser/web_ui_data_source.h index 76d0d7e..f3692b3 100644 --- a/content/public/browser/web_ui_data_source.h +++ b/content/public/browser/web_ui_data_source.h @@ -78,6 +78,11 @@ class WebUIDataSource { // NOTE: it's not acceptable to call DisableContentSecurityPolicy for new // pages, see URLDataSource::ShouldAddContentSecurityPolicy and talk to // tsepez. + + // Currently only used by embedders for WebUIs with multiple instances, could + // have been useful for NTP as well if it wasn't implementing URLDataSource + // itself. + virtual void DisableReplaceExistingSource() = 0; virtual void DisableContentSecurityPolicy() = 0; virtual void OverrideContentSecurityPolicyObjectSrc( const std::string& data) = 0; |