summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc27
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h18
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_request_info.cc4
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_request_info.h20
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc48
-rw-r--r--chrome/browser/renderer_host/resource_request_details.h5
-rw-r--r--chrome/browser/renderer_host/sync_resource_handler.cc3
7 files changed, 49 insertions, 76 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 2301720..17bdf4e 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -150,14 +150,15 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
}
void PopulateResourceResponse(URLRequest* request,
- FilterPolicy::Type filter_policy,
+ bool replace_extension_localization_templates,
ResourceResponse* response) {
response->response_head.status = request->status();
response->response_head.request_time = request->request_time();
response->response_head.response_time = request->response_time();
response->response_head.headers = request->response_headers();
request->GetCharset(&response->response_head.charset);
- response->response_head.filter_policy = filter_policy;
+ response->response_head.replace_extension_localization_templates =
+ replace_extension_localization_templates;
response->response_head.content_length = request->GetExpectedContentSize();
request->GetMimeType(&response->response_head.mime_type);
response->response_head.was_fetched_via_spdy =
@@ -465,9 +466,8 @@ void ResourceDispatcherHost::BeginRequest(
ResourceType::IsFrame(request_data.resource_type), // allow_download
request_data.host_renderer_id,
request_data.host_render_view_id);
- ApplyExtensionMessageFilterPolicy(request_data.url,
- request_data.resource_type,
- extra_info);
+ ApplyExtensionLocalizationFilter(request_data.url, request_data.resource_type,
+ extra_info);
SetRequestInfo(request, extra_info); // Request takes ownership.
chrome_browser_net::SetOriginProcessUniqueIDForRequest(
request_data.origin_child_id, request);
@@ -934,7 +934,8 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request,
}
scoped_refptr<ResourceResponse> response = new ResourceResponse;
- PopulateResourceResponse(request, info->filter_policy(), response);
+ PopulateResourceResponse(request,
+ info->replace_extension_localization_templates(), response);
if (!info->resource_handler()->OnRequestRedirected(info->request_id(),
new_url,
response, defer_redirect))
@@ -1031,7 +1032,8 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) {
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
scoped_refptr<ResourceResponse> response = new ResourceResponse;
- PopulateResourceResponse(request, info->filter_policy(), response);
+ PopulateResourceResponse(request,
+ info->replace_extension_localization_templates(), response);
if (request->ssl_info().cert) {
int cert_id =
@@ -1757,17 +1759,14 @@ bool ResourceDispatcherHost::IsResourceDispatcherHostMessage(
}
// static
-void ResourceDispatcherHost::ApplyExtensionMessageFilterPolicy(
+void ResourceDispatcherHost::ApplyExtensionLocalizationFilter(
const GURL& url,
const ResourceType::Type& resource_type,
ResourceDispatcherHostRequestInfo* request_info) {
- // Apply filter only to chrome extension css files that don't have
- // security filter already set.
+ // Apply filter to chrome extension CSS files.
if (url.SchemeIs(chrome::kExtensionScheme) &&
- request_info->filter_policy() == FilterPolicy::DONT_FILTER &&
- resource_type == ResourceType::STYLESHEET) {
- request_info->set_filter_policy(FilterPolicy::FILTER_EXTENSION_MESSAGES);
- }
+ resource_type == ResourceType::STYLESHEET)
+ request_info->set_replace_extension_localization_templates();
}
// static
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 79bf277..bce21e8 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -274,14 +274,10 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
IncrementOutstandingRequestsMemoryCost);
FRIEND_TEST(ResourceDispatcherHostTest,
CalculateApproximateMemoryCost);
- FRIEND_TEST(ApplyExtensionMessageFilterPolicyTest, WrongScheme);
- FRIEND_TEST(ApplyExtensionMessageFilterPolicyTest, GoodScheme);
- FRIEND_TEST(ApplyExtensionMessageFilterPolicyTest,
- GoodSchemeWithSecurityFilter);
- FRIEND_TEST(ApplyExtensionMessageFilterPolicyTest,
+ FRIEND_TEST(ApplyExtensionLocalizationFilterTest, WrongScheme);
+ FRIEND_TEST(ApplyExtensionLocalizationFilterTest, GoodScheme);
+ FRIEND_TEST(ApplyExtensionLocalizationFilterTest,
GoodSchemeWrongResourceType);
- FRIEND_TEST(ApplyExtensionMessageFilterPolicyTest,
- WrongSchemeResourceAndFilter);
class ShutdownTask;
@@ -408,9 +404,9 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// Returns true if the message passed in is a resource related message.
static bool IsResourceDispatcherHostMessage(const IPC::Message&);
- // Applies FilterPolicy::FILTER_EXTENSION_MESSAGES to all text/css requests
- // that have "chrome-extension://" scheme.
- static void ApplyExtensionMessageFilterPolicy(
+ // Sets replace_extension_localization_templates on all text/css requests that
+ // have "chrome-extension://" scheme.
+ static void ApplyExtensionLocalizationFilter(
const GURL& url,
const ResourceType::Type& resource_type,
ResourceDispatcherHostRequestInfo* request_info);
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_request_info.cc b/chrome/browser/renderer_host/resource_dispatcher_host_request_info.cc
index 23ba684..67c8c96 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_request_info.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_request_info.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,7 +35,7 @@ ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo(
frame_origin_(frame_origin),
main_frame_origin_(main_frame_origin),
resource_type_(resource_type),
- filter_policy_(FilterPolicy::DONT_FILTER),
+ replace_extension_localization_templates_(false),
last_load_state_(net::LOAD_STATE_IDLE),
upload_size_(upload_size),
last_upload_position_(0),
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_request_info.h b/chrome/browser/renderer_host/resource_dispatcher_host_request_info.h
index affd32d..4630568 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_request_info.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_request_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,7 +10,6 @@
#include "base/basictypes.h"
#include "base/time.h"
#include "chrome/common/child_process_info.h"
-#include "chrome/common/filter_policy.h"
#include "net/base/load_states.h"
#include "net/url_request/url_request.h"
#include "webkit/glue/resource_type.h"
@@ -115,12 +114,15 @@ class ResourceDispatcherHostRequestInfo : public URLRequest::UserData {
// Identifies the type of resource, such as subframe, media, etc.
ResourceType::Type resource_type() const { return resource_type_; }
- // Whether the content for this request should be filtered (on the renderer
- // side) to make it more secure: images are stamped, frame content is
- // replaced with an error message and all other resources are entirely
- // filtered out.
- FilterPolicy::Type filter_policy() const { return filter_policy_; }
- void set_filter_policy(FilterPolicy::Type policy) { filter_policy_ = policy; }
+ // Whether we should apply a filter to this resource that replaces
+ // localization templates with the appropriate localized strings. This is set
+ // for CSS resources used by extensions.
+ bool replace_extension_localization_templates() const {
+ return replace_extension_localization_templates_;
+ }
+ void set_replace_extension_localization_templates() {
+ replace_extension_localization_templates_ = true;
+ }
// Returns the last updated state of the load. This is updated periodically
// by the ResourceDispatcherHost and tracked here so we don't send out
@@ -209,7 +211,7 @@ class ResourceDispatcherHostRequestInfo : public URLRequest::UserData {
std::string frame_origin_;
std::string main_frame_origin_;
ResourceType::Type resource_type_;
- FilterPolicy::Type filter_policy_;
+ bool replace_extension_localization_templates_;
net::LoadState last_load_state_;
uint64 upload_size_;
uint64 last_upload_position_;
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
index ef133b2..2af376e 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -984,7 +984,7 @@ class DummyResourceHandler : public ResourceHandler {
DISALLOW_COPY_AND_ASSIGN(DummyResourceHandler);
};
-class ApplyExtensionMessageFilterPolicyTest : public testing::Test {
+class ApplyExtensionLocalizationFilterTest : public testing::Test {
protected:
void SetUp() {
url_.reset(new GURL(
@@ -1007,45 +1007,25 @@ class ApplyExtensionMessageFilterPolicyTest : public testing::Test {
scoped_ptr<ResourceDispatcherHostRequestInfo> request_info_;
};
-TEST_F(ApplyExtensionMessageFilterPolicyTest, WrongScheme) {
+TEST_F(ApplyExtensionLocalizationFilterTest, WrongScheme) {
url_.reset(new GURL("html://behllobkkfkfnphdnhnkndlbkcpglgmj/popup.html"));
- ResourceDispatcherHost::ApplyExtensionMessageFilterPolicy(
- *url_, resource_type_, request_info_.get());
+ ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
+ resource_type_, request_info_.get());
- EXPECT_EQ(FilterPolicy::DONT_FILTER, request_info_->filter_policy());
+ EXPECT_FALSE(request_info_->replace_extension_localization_templates());
}
-TEST_F(ApplyExtensionMessageFilterPolicyTest, GoodScheme) {
- ResourceDispatcherHost::ApplyExtensionMessageFilterPolicy(
- *url_, resource_type_, request_info_.get());
+TEST_F(ApplyExtensionLocalizationFilterTest, GoodScheme) {
+ ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
+ resource_type_, request_info_.get());
- EXPECT_EQ(FilterPolicy::FILTER_EXTENSION_MESSAGES,
- request_info_->filter_policy());
+ EXPECT_TRUE(request_info_->replace_extension_localization_templates());
}
-TEST_F(ApplyExtensionMessageFilterPolicyTest, GoodSchemeWithSecurityFilter) {
- request_info_->set_filter_policy(FilterPolicy::FILTER_ALL_EXCEPT_IMAGES);
- ResourceDispatcherHost::ApplyExtensionMessageFilterPolicy(
- *url_, resource_type_, request_info_.get());
-
- EXPECT_EQ(FilterPolicy::FILTER_ALL_EXCEPT_IMAGES,
- request_info_->filter_policy());
-}
-
-TEST_F(ApplyExtensionMessageFilterPolicyTest, GoodSchemeWrongResourceType) {
+TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) {
resource_type_ = ResourceType::MAIN_FRAME;
- ResourceDispatcherHost::ApplyExtensionMessageFilterPolicy(
- *url_, resource_type_, request_info_.get());
-
- EXPECT_EQ(FilterPolicy::DONT_FILTER, request_info_->filter_policy());
-}
-
-TEST_F(ApplyExtensionMessageFilterPolicyTest, WrongSchemeResourceAndFilter) {
- url_.reset(new GURL("html://behllobkkfkfnphdnhnkndlbkcpglgmj/popup.html"));
- resource_type_ = ResourceType::MEDIA;
- request_info_->set_filter_policy(FilterPolicy::FILTER_ALL);
- ResourceDispatcherHost::ApplyExtensionMessageFilterPolicy(
- *url_, resource_type_, request_info_.get());
+ ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
+ resource_type_, request_info_.get());
- EXPECT_EQ(FilterPolicy::FILTER_ALL, request_info_->filter_policy());
+ EXPECT_FALSE(request_info_->replace_extension_localization_templates());
}
diff --git a/chrome/browser/renderer_host/resource_request_details.h b/chrome/browser/renderer_host/resource_request_details.h
index 600decd..5310b5b 100644
--- a/chrome/browser/renderer_host/resource_request_details.h
+++ b/chrome/browser/renderer_host/resource_request_details.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -39,7 +39,6 @@ class ResourceRequestDetails {
resource_type_ = info->resource_type();
frame_origin_ = info->frame_origin();
main_frame_origin_ = info->main_frame_origin();
- filter_policy_ = info->filter_policy();
// If request is from the worker process on behalf of a renderer, use
// the renderer process id, since it consumes the notification response
@@ -75,7 +74,6 @@ class ResourceRequestDetails {
int ssl_cert_id() const { return ssl_cert_id_; }
int ssl_cert_status() const { return ssl_cert_status_; }
ResourceType::Type resource_type() const { return resource_type_; }
- FilterPolicy::Type filter_policy() const { return filter_policy_; }
private:
GURL url_;
@@ -91,7 +89,6 @@ class ResourceRequestDetails {
int ssl_cert_id_;
int ssl_cert_status_;
ResourceType::Type resource_type_;
- FilterPolicy::Type filter_policy_;
};
// Details about a redirection of a resource request.
diff --git a/chrome/browser/renderer_host/sync_resource_handler.cc b/chrome/browser/renderer_host/sync_resource_handler.cc
index 11d776b..9674648 100644
--- a/chrome/browser/renderer_host/sync_resource_handler.cc
+++ b/chrome/browser/renderer_host/sync_resource_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,7 +14,6 @@ SyncResourceHandler::SyncResourceHandler(
receiver_(receiver),
result_message_(result_message) {
result_.final_url = url;
- result_.filter_policy = FilterPolicy::DONT_FILTER;
}
SyncResourceHandler::~SyncResourceHandler() {