summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 20:17:39 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 20:17:39 +0000
commitcbe89c9bfb51c1bf577584d32df5d8b7a3c83159 (patch)
tree354e107d246dab86da1aca3f79ef11a9b318ea9e
parent59c4dd56e427e29eb26e81512c3066fe3f8b13b8 (diff)
downloadchromium_src-cbe89c9bfb51c1bf577584d32df5d8b7a3c83159.zip
chromium_src-cbe89c9bfb51c1bf577584d32df5d8b7a3c83159.tar.gz
chromium_src-cbe89c9bfb51c1bf577584d32df5d8b7a3c83159.tar.bz2
Get rid of the extension dependency in ResourceDispatcher by calling out to a webkit_glue function that can update the peer. No point sending the boolean flag from the browser since the same check is done in the renderer.
Review URL: http://codereview.chromium.org/6628006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76957 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/render_messages.cc4
-rw-r--r--chrome/common/resource_dispatcher.cc13
-rw-r--r--chrome/common/resource_response.cc3
-rw-r--r--chrome/common/resource_response.h5
-rw-r--r--chrome/default_plugin/plugin_impl_gtk.cc1
-rw-r--r--chrome/renderer/renderer_glue.cc9
-rw-r--r--content/browser/renderer_host/render_message_filter.cc14
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.cc22
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.h7
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_request_info.cc1
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_request_info.h11
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_unittest.cc23
-rw-r--r--webkit/glue/webkit_glue.h8
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc1
-rw-r--r--webkit/support/webkit_support_glue.cc7
-rw-r--r--webkit/tools/test_shell/test_shell.cc7
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_gtk.cc1
17 files changed, 42 insertions, 95 deletions
diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc
index 300106a..3d1f767 100644
--- a/chrome/common/render_messages.cc
+++ b/chrome/common/render_messages.cc
@@ -516,7 +516,6 @@ void ParamTraits<webkit_glue::ResourceResponseInfo>::Log(
void ParamTraits<ResourceResponseHead>::Write(Message* m, const param_type& p) {
ParamTraits<webkit_glue::ResourceResponseInfo>::Write(m, p);
WriteParam(m, p.status);
- WriteParam(m, p.replace_extension_localization_templates);
}
bool ParamTraits<ResourceResponseHead>::Read(const Message* m,
@@ -524,8 +523,7 @@ bool ParamTraits<ResourceResponseHead>::Read(const Message* m,
param_type* r) {
return ParamTraits<webkit_glue::ResourceResponseInfo>::Read(
m, iter, r) &&
- ReadParam(m, iter, &r->status) &&
- ReadParam(m, iter, &r->replace_extension_localization_templates);
+ ReadParam(m, iter, &r->status);
}
void ParamTraits<ResourceResponseHead>::Log(const param_type& p,
diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc
index b179b45..18d0f68 100644
--- a/chrome/common/resource_dispatcher.cc
+++ b/chrome/common/resource_dispatcher.cc
@@ -12,7 +12,6 @@
#include "base/message_loop.h"
#include "base/shared_memory.h"
#include "base/string_util.h"
-#include "chrome/common/extensions/extension_localization_peer.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
#include "chrome/common/resource_response.h"
@@ -327,14 +326,10 @@ void ResourceDispatcher::OnReceivedResponse(
if (!request_info)
return;
- if (response_head.replace_extension_localization_templates) {
- webkit_glue::ResourceLoaderBridge::Peer* new_peer =
- ExtensionLocalizationPeer::CreateExtensionLocalizationPeer(
- request_info->peer, message_sender(), response_head.mime_type,
- request_info->url);
- if (new_peer)
- request_info->peer = new_peer;
- }
+ webkit_glue::ResourceLoaderBridge::Peer* new_peer = webkit_glue::ReplacePeer(
+ request_info->peer, response_head.mime_type, request_info->url);
+ if (new_peer)
+ request_info->peer = new_peer;
request_info->peer->OnReceivedResponse(response_head);
}
diff --git a/chrome/common/resource_response.cc b/chrome/common/resource_response.cc
index ad8f184..ab4bdfe 100644
--- a/chrome/common/resource_response.cc
+++ b/chrome/common/resource_response.cc
@@ -4,8 +4,7 @@
#include "chrome/common/resource_response.h"
-ResourceResponseHead::ResourceResponseHead()
- : replace_extension_localization_templates(false) {
+ResourceResponseHead::ResourceResponseHead() {
}
ResourceResponseHead::~ResourceResponseHead() {}
diff --git a/chrome/common/resource_response.h b/chrome/common/resource_response.h
index a5284df..c9cbada 100644
--- a/chrome/common/resource_response.h
+++ b/chrome/common/resource_response.h
@@ -22,11 +22,6 @@ struct ResourceResponseHead : webkit_glue::ResourceResponseInfo {
// The response status.
net::URLRequestStatus status;
-
- // 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;
};
// Parameters for a synchronous resource response.
diff --git a/chrome/default_plugin/plugin_impl_gtk.cc b/chrome/default_plugin/plugin_impl_gtk.cc
index b6dc38a..bca4b37 100644
--- a/chrome/default_plugin/plugin_impl_gtk.cc
+++ b/chrome/default_plugin/plugin_impl_gtk.cc
@@ -13,7 +13,6 @@
#include "googleurl/src/gurl.h"
#include "grit/webkit_strings.h"
#include "unicode/locid.h"
-#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/npapi/default_plugin_shared.h"
// TODO(thakis): Most methods in this class are stubbed out an need to be
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 7ba91ff..0671581 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -18,6 +18,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/extensions/extension_localization_peer.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/socket_stream_dispatcher.h"
#include "chrome/common/url_constants.h"
@@ -281,6 +282,14 @@ void UserMetricsRecordAction(const std::string& action) {
new ViewHostMsg_UserMetricsRecordAction(action));
}
+webkit_glue::ResourceLoaderBridge::Peer* ReplacePeer(
+ webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ const std::string& mime_type,
+ const GURL& url) {
+ return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer(
+ current_peer, RenderThread::current(), mime_type, url);
+}
+
#if !defined(DISABLE_NACL)
bool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles,
void* nacl_process_handle, int* nacl_process_id) {
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index e7262bb..dcda00c 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -693,9 +693,7 @@ void RenderMessageFilter::OnGetPluginsOnFileThread(
std::vector<webkit::npapi::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetEnabledPlugins(refresh, &plugins);
ViewHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins);
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &RenderMessageFilter::Send, reply_msg));
+ Send(reply_msg);
}
void RenderMessageFilter::OnGetPluginInfo(int routing_id,
@@ -1335,10 +1333,7 @@ void RenderMessageFilter::OnKeygenOnWorkerThread(
ViewHostMsg_Keygen::WriteReplyParams(
reply_msg,
keygen_handler.GenKeyAndSignChallenge());
-
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &RenderMessageFilter::Send, reply_msg));
+ Send(reply_msg);
}
#if defined(USE_TCMALLOC)
@@ -1393,10 +1388,7 @@ void RenderMessageFilter::OnGetExtensionMessageBundleOnFileThread(
ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams(
reply_msg, dictionary_map);
-
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &RenderMessageFilter::Send, reply_msg));
+ Send(reply_msg);
}
void RenderMessageFilter::OnAsyncOpenFile(const IPC::Message& msg,
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index d3ad489..869c92d 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -165,15 +165,12 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
}
void PopulateResourceResponse(net::URLRequest* request,
- 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.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 =
@@ -521,8 +518,6 @@ void ResourceDispatcherHost::BeginRequest(
request_data.has_user_gesture,
request_data.host_renderer_id,
request_data.host_render_view_id);
- ApplyExtensionLocalizationFilter(request_data.url, request_data.resource_type,
- extra_info);
SetRequestInfo(request, extra_info); // Request takes ownership.
chrome_browser_net::SetOriginPIDForRequest(
request_data.origin_pid, request);
@@ -1026,8 +1021,7 @@ void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request,
}
scoped_refptr<ResourceResponse> response(new ResourceResponse);
- PopulateResourceResponse(request,
- info->replace_extension_localization_templates(), response);
+ PopulateResourceResponse(request, response);
if (!info->resource_handler()->OnRequestRedirected(info->request_id(),
new_url,
response, defer_redirect))
@@ -1152,8 +1146,7 @@ bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) {
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
scoped_refptr<ResourceResponse> response(new ResourceResponse);
- PopulateResourceResponse(request,
- info->replace_extension_localization_templates(), response);
+ PopulateResourceResponse(request, response);
if (request->ssl_info().cert) {
int cert_id =
@@ -1875,17 +1868,6 @@ bool ResourceDispatcherHost::IsValidRequest(net::URLRequest* request) {
}
// static
-void ResourceDispatcherHost::ApplyExtensionLocalizationFilter(
- const GURL& url,
- const ResourceType::Type& resource_type,
- ResourceDispatcherHostRequestInfo* request_info) {
- // Apply filter to chrome extension CSS files.
- if (url.SchemeIs(chrome::kExtensionScheme) &&
- resource_type == ResourceType::STYLESHEET)
- request_info->set_replace_extension_localization_templates();
-}
-
-// static
net::RequestPriority ResourceDispatcherHost::DetermineRequestPriority(
ResourceType::Type type) {
// Determine request priority based on how critical this resource typically
diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h
index fb78dcc..47dcb22 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.h
+++ b/content/browser/renderer_host/resource_dispatcher_host.h
@@ -414,13 +414,6 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate {
// Returns true if |request| is in |pending_requests_|.
bool IsValidRequest(net::URLRequest* request);
- // 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);
-
// Determine request priority based on how critical this resource typically
// is to user-perceived page load performance.
static net::RequestPriority DetermineRequestPriority(ResourceType::Type type);
diff --git a/content/browser/renderer_host/resource_dispatcher_host_request_info.cc b/content/browser/renderer_host/resource_dispatcher_host_request_info.cc
index 695889e..14ff524 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_request_info.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_request_info.cc
@@ -34,7 +34,6 @@ ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo(
has_user_gesture_(has_user_gesture),
pause_count_(0),
resource_type_(resource_type),
- replace_extension_localization_templates_(false),
last_load_state_(net::LOAD_STATE_IDLE),
upload_size_(upload_size),
last_upload_position_(0),
diff --git a/content/browser/renderer_host/resource_dispatcher_host_request_info.h b/content/browser/renderer_host/resource_dispatcher_host_request_info.h
index c05c4f9..2322c43 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_request_info.h
+++ b/content/browser/renderer_host/resource_dispatcher_host_request_info.h
@@ -107,16 +107,6 @@ class ResourceDispatcherHostRequestInfo : public net::URLRequest::UserData {
// Identifies the type of resource, such as subframe, media, etc.
ResourceType::Type resource_type() const { return resource_type_; }
- // 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
// unnecessary state change notifications.
@@ -211,7 +201,6 @@ class ResourceDispatcherHostRequestInfo : public net::URLRequest::UserData {
bool has_user_gesture_;
int pause_count_;
ResourceType::Type resource_type_;
- bool replace_extension_localization_templates_;
net::LoadState last_load_state_;
uint64 upload_size_;
uint64 last_upload_position_;
diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
index 0199b11..6c3813e 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
@@ -1001,26 +1001,3 @@ class ApplyExtensionLocalizationFilterTest : public testing::Test {
scoped_ptr<DummyResourceHandler> resource_handler_;
scoped_ptr<ResourceDispatcherHostRequestInfo> request_info_;
};
-
-TEST_F(ApplyExtensionLocalizationFilterTest, WrongScheme) {
- url_.reset(new GURL("html://behllobkkfkfnphdnhnkndlbkcpglgmj/popup.html"));
- ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
- resource_type_, request_info_.get());
-
- EXPECT_FALSE(request_info_->replace_extension_localization_templates());
-}
-
-TEST_F(ApplyExtensionLocalizationFilterTest, GoodScheme) {
- ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
- resource_type_, request_info_.get());
-
- EXPECT_TRUE(request_info_->replace_extension_localization_templates());
-}
-
-TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) {
- resource_type_ = ResourceType::MAIN_FRAME;
- ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
- resource_type_, request_info_.get());
-
- EXPECT_FALSE(request_info_->replace_extension_localization_templates());
-}
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index d2cdd5f..8e318c3 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -20,6 +20,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h"
#include "ui/base/clipboard/clipboard.h"
+#include "webkit/glue/resource_loader_bridge.h"
class GURL;
class SkBitmap;
@@ -281,6 +282,13 @@ void EnableSpdy(bool enable);
// Notifies the browser that the given action has been performed.
void UserMetricsRecordAction(const std::string& action);
+// Allows the embedder to swap the peer for a request through the resource
+// loader. Return NULL to keep the existing peer.
+webkit_glue::ResourceLoaderBridge::Peer* ReplacePeer(
+ webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ const std::string& mime_type,
+ const GURL& url);
+
#if !defined(DISABLE_NACL)
// Launch NaCl's sel_ldr process.
bool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles,
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
index 8e6d766..726abc0 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
@@ -20,7 +20,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "ui/gfx/blit.h"
-#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/npapi/gtk_plugin_container.h"
#include "webkit/plugins/npapi/plugin_constants_win.h"
#include "webkit/plugins/npapi/plugin_instance.h"
diff --git a/webkit/support/webkit_support_glue.cc b/webkit/support/webkit_support_glue.cc
index 562b989..40e46f1 100644
--- a/webkit/support/webkit_support_glue.cc
+++ b/webkit/support/webkit_support_glue.cc
@@ -99,6 +99,13 @@ void EnableSpdy(bool enable) {
void UserMetricsRecordAction(const std::string& action) {
}
+webkit_glue::ResourceLoaderBridge::Peer* ReplacePeer(
+ webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ const std::string& mime_type,
+ const GURL& url) {
+ return NULL;
+}
+
#if defined(OS_LINUX)
int MatchFontWithFallback(const std::string& face, bool bold,
bool italic, int charset) {
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index f106c35..31f9e68 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -690,6 +690,13 @@ void EnableSpdy(bool enable) {
void UserMetricsRecordAction(const std::string& action) {
}
+webkit_glue::ResourceLoaderBridge::Peer* ReplacePeer(
+ webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ const std::string& mime_type,
+ const GURL& url) {
+ return NULL;
+}
+
std::string GetProductVersion() {
return std::string("Chrome/0.0.0.0");
}
diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
index 38e64cb..42372f3 100644
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -24,7 +24,6 @@
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webpreferences.h"
-#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/window_open_disposition.h"
#include "webkit/plugins/npapi/gtk_plugin_container_manager.h"
#include "webkit/plugins/npapi/plugin_list.h"