summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-31 23:25:33 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-31 23:25:33 +0000
commitf1a63d5f6bef794c761447e7dc7b1415b133bdb3 (patch)
tree297e66d439d262c54a22b0360aa6241082018d2e
parentc1443d84cafab2dc81650715b102afe4d28cb27b (diff)
downloadchromium_src-f1a63d5f6bef794c761447e7dc7b1415b133bdb3.zip
chromium_src-f1a63d5f6bef794c761447e7dc7b1415b133bdb3.tar.gz
chromium_src-f1a63d5f6bef794c761447e7dc7b1415b133bdb3.tar.bz2
Revert "First steps towards webRequest extension API."
Seems to have broken the sync_integration_tests. This reverts commit d6f8d16cd6a5ebdf019c4755e7d42aee8136abf1. TBR=aa BUG=60101 TEST=no Review URL: http://codereview.chromium.org/6287029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73219 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/browser/extensions/extension_io_event_router.cc38
-rwxr-xr-xchrome/browser/extensions/extension_io_event_router.h40
-rwxr-xr-xchrome/browser/extensions/extension_webrequest_api.cc43
-rwxr-xr-xchrome/browser/extensions/extension_webrequest_api.h35
-rw-r--r--chrome/browser/extensions/extension_webrequest_apitest.cc7
-rw-r--r--chrome/browser/io_thread.cc1
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc21
-rw-r--r--chrome/browser/net/chrome_network_delegate.h5
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc6
-rw-r--r--chrome/browser/net/chrome_url_request_context.h13
-rw-r--r--chrome/browser/profiles/profile.cc4
-rw-r--r--chrome/browser/profiles/profile.h4
-rw-r--r--chrome/browser/profiles/profile_impl.cc10
-rw-r--r--chrome/browser/profiles/profile_impl.h2
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/renderer/extensions/event_bindings.cc55
-rw-r--r--chrome/renderer/resources/event_bindings.js67
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/events/complexLoad/a.html1
-rwxr-xr-xchrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.html1
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.jpg0
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/events/manifest.json7
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/events/simpleLoad/a.html1
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/events/test.html101
-rw-r--r--chrome/test/testing_profile.h1
-rw-r--r--net/http/http_network_delegate.h4
-rw-r--r--net/url_request/url_request.cc6
-rw-r--r--net/url_request/url_request_context.h5
27 files changed, 9 insertions, 473 deletions
diff --git a/chrome/browser/extensions/extension_io_event_router.cc b/chrome/browser/extensions/extension_io_event_router.cc
deleted file mode 100755
index c6b4d3e..0000000
--- a/chrome/browser/extensions/extension_io_event_router.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "chrome/browser/extensions/extension_io_event_router.h"
-
-#include "googleurl/src/gurl.h"
-#include "chrome/browser/browser_thread.h"
-#include "chrome/browser/extensions/extension_event_router.h"
-#include "chrome/browser/profiles/profile.h"
-
-ExtensionIOEventRouter::ExtensionIOEventRouter(Profile* profile)
- : profile_(profile) {
-}
-
-ExtensionIOEventRouter::~ExtensionIOEventRouter() {
-}
-
-void ExtensionIOEventRouter::DispatchEvent(
- const std::string& event_name, const std::string& event_args) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &ExtensionIOEventRouter::DispatchEventOnUIThread,
- event_name, event_args));
-}
-
-void ExtensionIOEventRouter::DispatchEventOnUIThread(
- const std::string& event_name, const std::string& event_args) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // If the profile has gone away, we're shutting down.
- if (!profile_)
- return;
-
- profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
- event_name, event_args, profile_, GURL());
-}
diff --git a/chrome/browser/extensions/extension_io_event_router.h b/chrome/browser/extensions/extension_io_event_router.h
deleted file mode 100755
index 1a27890..0000000
--- a/chrome/browser/extensions/extension_io_event_router.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_
-#pragma once
-
-#include <string>
-
-#include "base/ref_counted.h"
-
-class Profile;
-
-// For now, this just forwards events from the IO thread to the
-// ExtensionEventRouter on the UI thread.
-// TODO(mpcomplete): eventually I want this to have its own copy of the event
-// listeners so it can bypass the jump to the UI thread.
-class ExtensionIOEventRouter
- : public base::RefCountedThreadSafe<ExtensionIOEventRouter> {
- public:
- explicit ExtensionIOEventRouter(Profile* profile);
- ~ExtensionIOEventRouter();
-
- void DestroyingProfile() { profile_ = NULL; }
-
- // Dispatch the named event to every extension listening to that event.
- void DispatchEvent(const std::string& event_name,
- const std::string& event_args) const;
-
- private:
- Profile* profile_;
-
- void DispatchEventOnUIThread(const std::string& event_name,
- const std::string& event_args) const;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionIOEventRouter);
-};
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_IO_EVENT_ROUTER_H_
diff --git a/chrome/browser/extensions/extension_webrequest_api.cc b/chrome/browser/extensions/extension_webrequest_api.cc
deleted file mode 100755
index 3ca3fca..0000000
--- a/chrome/browser/extensions/extension_webrequest_api.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "chrome/browser/extensions/extension_webrequest_api.h"
-
-#include "base/json/json_writer.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/extension_io_event_router.h"
-#include "chrome/browser/extensions/extension_webrequest_api_constants.h"
-#include "googleurl/src/gurl.h"
-
-namespace keys = extension_webrequest_api_constants;
-
-// static
-ExtensionWebRequestEventRouter* ExtensionWebRequestEventRouter::GetInstance() {
- return Singleton<ExtensionWebRequestEventRouter>::get();
-}
-
-ExtensionWebRequestEventRouter::ExtensionWebRequestEventRouter() {
-}
-
-ExtensionWebRequestEventRouter::~ExtensionWebRequestEventRouter() {
-}
-
-void ExtensionWebRequestEventRouter::OnBeforeRequest(
- const ExtensionIOEventRouter* event_router, const GURL& url,
- const std::string& method) {
- ListValue args;
- DictionaryValue* dict = new DictionaryValue();
- dict->SetString(keys::kUrlKey, url.spec());
- dict->SetString(keys::kMethodKey, method);
- // TODO(mpcomplete): implement
- dict->SetInteger(keys::kTabIdKey, 0);
- dict->SetInteger(keys::kRequestIdKey, 0);
- dict->SetString(keys::kTypeKey, "main_frame");
- dict->SetInteger(keys::kTimeStampKey, 1);
- args.Append(dict);
-
- std::string json_args;
- base::JSONWriter::Write(&args, false, &json_args);
- event_router->DispatchEvent(keys::kOnBeforeRequest, json_args);
-}
diff --git a/chrome/browser/extensions/extension_webrequest_api.h b/chrome/browser/extensions/extension_webrequest_api.h
deleted file mode 100755
index 1945627..0000000
--- a/chrome/browser/extensions/extension_webrequest_api.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_
-#pragma once
-
-#include <string>
-
-#include "base/singleton.h"
-
-class ExtensionIOEventRouter;
-class GURL;
-
-// IO thread
-class ExtensionWebRequestEventRouter {
- public:
- static ExtensionWebRequestEventRouter* GetInstance();
-
- // TODO(mpcomplete): additional params
- void OnBeforeRequest(const ExtensionIOEventRouter* event_router,
- const GURL& url, const std::string& method);
-
- private:
- friend struct DefaultSingletonTraits<ExtensionWebRequestEventRouter>;
-
- ExtensionWebRequestEventRouter();
- ~ExtensionWebRequestEventRouter();
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
-};
-
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_
diff --git a/chrome/browser/extensions/extension_webrequest_apitest.cc b/chrome/browser/extensions/extension_webrequest_apitest.cc
index 7c25be8..833312f 100644
--- a/chrome/browser/extensions/extension_webrequest_apitest.cc
+++ b/chrome/browser/extensions/extension_webrequest_apitest.cc
@@ -12,10 +12,3 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebRequest) {
ASSERT_TRUE(RunExtensionTest("webrequest/api")) << message_;
}
-
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebRequestEvents) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExperimentalExtensionApis);
-
- ASSERT_TRUE(RunExtensionTest("webrequest/events")) << message_;
-}
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 127f53e..d5af8f0 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -193,7 +193,6 @@ ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
globals->proxy_script_fetcher_http_transaction_factory.get());
// In-memory cookie store.
context->set_cookie_store(new net::CookieMonster(NULL, NULL));
- // TODO(mpcomplete): give it a SystemNetworkDelegate.
return context;
}
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 0c92721..a657b26 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -5,32 +5,11 @@
#include "chrome/browser/net/chrome_network_delegate.h"
#include "base/logging.h"
-#include "chrome/browser/extensions/extension_webrequest_api.h"
-#include "chrome/browser/net/chrome_url_request_context.h"
#include "net/http/http_request_headers.h"
-#include "net/url_request/url_request.h"
-
-namespace {
-
-// Get the event router from the request context. Currently only
-// ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to
-// work.
-const ExtensionIOEventRouter* GetIOEventRouter(
- net::URLRequestContext* context) {
- return static_cast<ChromeURLRequestContext*>(context)->
- extension_io_event_router();
-}
-
-} // namespace
ChromeNetworkDelegate::ChromeNetworkDelegate() {}
ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
-void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
- ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
- GetIOEventRouter(request->context()), request->url(), request->method());
-}
-
void ChromeNetworkDelegate::OnSendHttpRequest(
net::HttpRequestHeaders* headers) {
DCHECK(headers);
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
index 8bff160..55336d6 100644
--- a/chrome/browser/net/chrome_network_delegate.h
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -10,14 +10,15 @@
#include "net/http/http_network_delegate.h"
// ChromeNetworkDelegate is the central point from within the chrome code to
-// add hooks into the network stack.
+// add hooks into the network stack. In the future, we can use this for
+// extensions to register hooks for the network stack.
class ChromeNetworkDelegate : public net::HttpNetworkDelegate {
public:
ChromeNetworkDelegate();
~ChromeNetworkDelegate();
// net::HttpNetworkDelegate methods:
- virtual void OnBeforeURLRequest(net::URLRequest* request);
+
virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers);
// TODO(willchan): Add functions for consumers to register ways to
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 81e0474..dc6853a 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -263,7 +263,6 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
context->set_host_resolver(io_thread_globals->host_resolver.get());
context->set_cert_verifier(io_thread_globals->cert_verifier.get());
context->set_dnsrr_resolver(io_thread_globals->dnsrr_resolver.get());
- context->set_network_delegate(&io_thread_globals->network_delegate);
context->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
@@ -369,7 +368,6 @@ ChromeURLRequestContext* FactoryForExtensions::Create() {
chrome::kExtensionScheme};
cookie_monster->SetCookieableSchemes(schemes, 2);
context->set_cookie_store(cookie_monster);
- context->set_network_delegate(&io_thread_globals->network_delegate);
// TODO(cbentzel): How should extensions handle HTTP Authentication?
context->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
@@ -404,7 +402,6 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() {
context->set_cert_verifier(io_thread_globals->cert_verifier.get());
context->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
- context->set_network_delegate(&io_thread_globals->network_delegate);
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
context->set_proxy_service(
@@ -480,7 +477,6 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
// TODO(willchan): Make a global ProxyService available in IOThread::Globals.
context->set_proxy_service(main_context->proxy_service());
- context->set_network_delegate(main_context->network_delegate());
// Also share the cookie store of the common profile.
context->set_cookie_store(main_context->cookie_store());
@@ -859,7 +855,6 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile)
blob_storage_context_ = profile->GetBlobStorageContext();
file_system_context_ = profile->GetFileSystemContext();
extension_info_map_ = profile->GetExtensionInfoMap();
- extension_io_event_router_ = profile->GetExtensionIOEventRouter();
prerender_manager_ = profile->GetPrerenderManager();
}
@@ -886,6 +881,5 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext(
context->set_blob_storage_context(blob_storage_context_);
context->set_file_system_context(file_system_context_);
context->set_extension_info_map(extension_info_map_);
- context->set_extension_io_event_router(extension_io_event_router_);
context->set_prerender_manager(prerender_manager_);
}
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 50f2d66..f65f63c 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -14,8 +14,6 @@
#include "chrome/browser/chrome_blob_storage_context.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/extensions/extension_io_event_router.h"
-#include "chrome/browser/extensions/extension_webrequest_api.h"
#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_cookie_policy.h"
@@ -93,10 +91,6 @@ class ChromeURLRequestContext : public net::URLRequestContext {
return extension_info_map_;
}
- const ExtensionIOEventRouter* extension_io_event_router() const {
- return extension_io_event_router_;
- }
-
PrerenderManager* prerender_manager() {
return prerender_manager_.get();
}
@@ -161,8 +155,9 @@ class ChromeURLRequestContext : public net::URLRequestContext {
void set_extension_info_map(ExtensionInfoMap* map) {
extension_info_map_ = map;
}
- void set_extension_io_event_router(ExtensionIOEventRouter* router) {
- extension_io_event_router_ = router;
+ void set_network_delegate(
+ net::HttpNetworkDelegate* network_delegate) {
+ network_delegate_ = network_delegate;
}
void set_prerender_manager(PrerenderManager* prerender_manager) {
prerender_manager_ = prerender_manager;
@@ -188,7 +183,6 @@ class ChromeURLRequestContext : public net::URLRequestContext {
scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_;
// TODO(aa): This should use chrome/common/extensions/extension_set.h.
scoped_refptr<ExtensionInfoMap> extension_info_map_;
- scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_;
scoped_refptr<PrerenderManager> prerender_manager_;
bool is_off_the_record_;
@@ -359,7 +353,6 @@ class ChromeURLRequestContextFactory {
scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_;
scoped_refptr<ExtensionInfoMap> extension_info_map_;
- scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_;
scoped_refptr<PrerenderManager> prerender_manager_;
FilePath profile_dir_path_;
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 1eb4077..c16e3bc 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -261,10 +261,6 @@ class OffTheRecordProfileImpl : public Profile,
return GetOriginalProfile()->GetExtensionEventRouter();
}
- virtual ExtensionIOEventRouter* GetExtensionIOEventRouter() {
- return GetOriginalProfile()->GetExtensionIOEventRouter();
- }
-
virtual SSLHostState* GetSSLHostState() {
if (!ssl_host_state_.get())
ssl_host_state_.reset(new SSLHostState());
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 618d44b..8af0983 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -58,7 +58,6 @@ class Extension;
class ExtensionDevToolsManager;
class ExtensionEventRouter;
class ExtensionInfoMap;
-class ExtensionIOEventRouter;
class ExtensionMessageService;
class ExtensionPrefValueMap;
class ExtensionProcessManager;
@@ -219,9 +218,6 @@ class Profile {
// Accessor. The instance is created at startup.
virtual ExtensionEventRouter* GetExtensionEventRouter() = 0;
- // Accessor. The instance is created at startup.
- virtual ExtensionIOEventRouter* GetExtensionIOEventRouter() = 0;
-
// Retrieves a pointer to the SSLHostState associated with this profile.
// The SSLHostState is lazily created the first time that this method is
// called.
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 5998652..0363424 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -33,7 +33,6 @@
#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/extension_event_router.h"
#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/extensions/extension_io_event_router.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_pref_store.h"
#include "chrome/browser/extensions/extension_process_manager.h"
@@ -344,7 +343,6 @@ void ProfileImpl::InitExtensions() {
extension_process_manager_.reset(ExtensionProcessManager::Create(this));
extension_event_router_.reset(new ExtensionEventRouter(this));
- extension_io_event_router_ = new ExtensionIOEventRouter(this);
extension_message_service_ = new ExtensionMessageService(this);
ExtensionErrorReporter::Init(true); // allow noisy errors.
@@ -528,7 +526,6 @@ ProfileImpl::~ProfileImpl() {
if (default_request_context_ == request_context_)
default_request_context_ = NULL;
-
CleanupRequestContext(request_context_);
CleanupRequestContext(media_request_context_);
CleanupRequestContext(extensions_request_context_);
@@ -545,9 +542,6 @@ ProfileImpl::~ProfileImpl() {
// HistoryService first.
favicon_service_ = NULL;
- if (extension_io_event_router_)
- extension_io_event_router_->DestroyingProfile();
-
if (extension_message_service_)
extension_message_service_->DestroyingProfile();
@@ -666,10 +660,6 @@ ExtensionEventRouter* ProfileImpl::GetExtensionEventRouter() {
return extension_event_router_.get();
}
-ExtensionIOEventRouter* ProfileImpl::GetExtensionIOEventRouter() {
- return extension_io_event_router_.get();
-}
-
SSLHostState* ProfileImpl::GetSSLHostState() {
if (!ssl_host_state_.get())
ssl_host_state_.reset(new SSLHostState());
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index d455bb9..6eb1597 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -61,7 +61,6 @@ class ProfileImpl : public Profile,
virtual ExtensionProcessManager* GetExtensionProcessManager();
virtual ExtensionMessageService* GetExtensionMessageService();
virtual ExtensionEventRouter* GetExtensionEventRouter();
- virtual ExtensionIOEventRouter* GetExtensionIOEventRouter();
virtual FaviconService* GetFaviconService(ServiceAccessType sat);
virtual HistoryService* GetHistoryService(ServiceAccessType sat);
virtual HistoryService* GetHistoryServiceWithoutCreating();
@@ -194,7 +193,6 @@ class ProfileImpl : public Profile,
scoped_ptr<ExtensionProcessManager> extension_process_manager_;
scoped_refptr<ExtensionMessageService> extension_message_service_;
scoped_ptr<ExtensionEventRouter> extension_event_router_;
- scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_;
scoped_ptr<SSLHostState> ssl_host_state_;
scoped_refptr<net::TransportSecurityState>
transport_security_state_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 7d6103a..bf19b71 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1135,8 +1135,6 @@
'browser/extensions/extension_input_api.h',
'browser/extensions/extension_install_ui.cc',
'browser/extensions/extension_install_ui.h',
- 'browser/extensions/extension_io_event_router.cc',
- 'browser/extensions/extension_io_event_router.h',
'browser/extensions/extension_management_api.cc',
'browser/extensions/extension_management_api.h',
'browser/extensions/extension_menu_manager.cc',
@@ -1195,8 +1193,6 @@
'browser/extensions/extension_toolbar_model.h',
'browser/extensions/extension_updater.cc',
'browser/extensions/extension_updater.h',
- 'browser/extensions/extension_webrequest_api.cc',
- 'browser/extensions/extension_webrequest_api.h',
'browser/extensions/extension_webrequest_api_constants.cc',
'browser/extensions/extension_webrequest_api_constants.h',
'browser/extensions/extension_webnavigation_api.cc',
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index f1b66ab..49f2fea 100644
--- a/chrome/renderer/extensions/event_bindings.cc
+++ b/chrome/renderer/extensions/event_bindings.cc
@@ -6,7 +6,6 @@
#include "base/basictypes.h"
#include "base/lazy_instance.h"
-#include "base/string_number_conversions.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
@@ -60,8 +59,6 @@ typedef std::map<std::string, int> EventListenerCounts;
struct SingletonData {
// A map of extension IDs to listener counts for that extension.
std::map<std::string, EventListenerCounts> listener_counts_;
- // @@@MP
- int unique_event_counter_;
};
static base::LazyInstance<SingletonData> g_singleton_data(
@@ -84,10 +81,6 @@ class ExtensionImpl : public ExtensionBase {
v8::Handle<v8::String> name) {
if (name->Equals(v8::String::New("AttachEvent"))) {
return v8::FunctionTemplate::New(AttachEvent);
- } else if (name->Equals(v8::String::New("GetUniqueComplexEventName"))) {
- return v8::FunctionTemplate::New(GetUniqueComplexEventName);
- } else if (name->Equals(v8::String::New("AttachComplexEvent"))) {
- return v8::FunctionTemplate::New(AttachComplexEvent);
} else if (name->Equals(v8::String::New("DetachEvent"))) {
return v8::FunctionTemplate::New(DetachEvent);
}
@@ -127,54 +120,6 @@ class ExtensionImpl : public ExtensionBase {
return v8::Undefined();
}
- // Attach an event name to an object.
- static v8::Handle<v8::Value> GetUniqueComplexEventName(
- const v8::Arguments& args) {
- DCHECK(args.Length() == 1);
- DCHECK(args[0]->IsString());
- std::string event_name(*v8::String::AsciiValue(args[0]));
- int unique_event_id = ++g_singleton_data.Get().unique_event_counter_;
- std::string unique_event_name =
- event_name + base::IntToString(unique_event_id);
- return v8::String::New(unique_event_name.c_str());
- }
-
- // Attach an event name to an object.
- static v8::Handle<v8::Value> AttachComplexEvent(const v8::Arguments& args) {
- DCHECK(args.Length() == 4);
- DCHECK(args[0]->IsString());
- DCHECK(args[1]->IsString());
- DCHECK(args[2]->IsString() || args[2]->IsUndefined());
- DCHECK(args[3]->IsString() || args[3]->IsUndefined());
-
- std::string event_name(*v8::String::AsciiValue(args[0]));
- std::string sub_event_name(*v8::String::AsciiValue(args[1]));
- std::string filter_str = *v8::String::Utf8Value(args[2]);
- std::string extra_info_str = *v8::String::Utf8Value(args[3]);
-
- ContextInfo* context_info = GetInfoForCurrentContext();
- EventListenerCounts& listener_counts =
- GetListenerCounts(context_info->extension_id);
- bool has_permission =
- ExtensionProcessBindings::CurrentContextHasPermission(event_name);
-
- if (!has_permission) {
- return ExtensionProcessBindings::ThrowPermissionDeniedException(
- event_name);
- }
-
- if (++listener_counts[event_name] == 1) {
- EventBindings::GetRenderThread()->Send(
- new ViewHostMsg_ExtensionAddListener(context_info->extension_id,
- event_name));
- }
-
- if (++context_info->num_connected_events == 1)
- context_info->context.ClearWeak();
-
- return v8::Undefined();
- }
-
static v8::Handle<v8::Value> DetachEvent(const v8::Arguments& args) {
DCHECK(args.Length() == 1);
// TODO(erikkay) should enforce that event name is a string in the bindings
diff --git a/chrome/renderer/resources/event_bindings.js b/chrome/renderer/resources/event_bindings.js
index 9d82800..2b8cce8 100644
--- a/chrome/renderer/resources/event_bindings.js
+++ b/chrome/renderer/resources/event_bindings.js
@@ -6,8 +6,6 @@ var chrome = chrome || {};
(function () {
native function GetChromeHidden();
native function AttachEvent(eventName);
- native function AttachComplexEvent(eventName, subEventName,
- filter, extraInfo);
native function DetachEvent(eventName);
var chromeHidden = GetChromeHidden();
@@ -55,9 +53,8 @@ var chrome = chrome || {};
// chrome.tabs.onChanged.addListener(function(data) { alert(data); });
// chromeHidden.Event.dispatch("tab-changed", "hi");
// will result in an alert dialog that says 'hi'.
- chrome.Event = function(opt_eventName, opt_argSchemas, opt_isSubEvent) {
+ chrome.Event = function(opt_eventName, opt_argSchemas) {
this.eventName_ = opt_eventName;
- this.isSubEvent_ = opt_isSubEvent;
this.listeners_ = [];
// Validate event parameters if we are in debug.
@@ -112,7 +109,7 @@ var chrome = chrome || {};
}
// Registers a callback to be called when this event is dispatched.
- chrome.Event.prototype.addListener = function(cb, opt_filter, opt_extraInfo) {
+ chrome.Event.prototype.addListener = function(cb) {
if (this.listeners_.length == 0) {
this.attach_();
}
@@ -176,8 +173,7 @@ var chrome = chrome || {};
// Attaches this event object to its name. Only one object can have a given
// name.
chrome.Event.prototype.attach_ = function() {
- if (!this.isSubEvent_)
- AttachEvent(this.eventName_);
+ AttachEvent(this.eventName_);
allAttachedEvents[allAttachedEvents.length] = this;
if (!this.eventName_)
return;
@@ -207,63 +203,6 @@ var chrome = chrome || {};
delete attachedNamedEvents[this.eventName_];
};
- // ComplexEvent object. This is used for special events with extra parameters.
- // Each invocation of addListener creates a new named sub-event. That
- // sub-event is associated with the extra parameters in the browser process,
- // so that only it is dispatched when the main event occurs matching the extra
- // parameters.
- //
- // Example:
- // chrome.webRequest.onBeforeRequest.addListener(
- // callback, {urls: "http://*.google.com/*"});
- // ^ callback will only be called for onBeforeRequests matching the filter.
- chrome.ComplexEvent = function(eventName, opt_argSchemas) {
- if (typeof eventName != "string")
- throw new Error("chrome.ComplexEvent requires an event name.");
-
- this.eventName_ = eventName;
- this.argSchemas_ = opt_argSchemas;
- this.subEvents_ = [];
- };
-
- // Registers a callback to be called when this event is dispatched. If
- // opt_filter is specified, then the callback is only called for events that
- // match the given filters. If opt_extraInfo is specified, the given optional
- // info is sent to the callback.
- chrome.ComplexEvent.prototype.addListener =
- function(cb, opt_filter, opt_extraInfo) {
- var subevent = new chrome.Event(this.eventName_ + this.subEvents_.length,
- this.argSchemas_, true);
- this.subEvents_[this.subEvents_.length] = subevent;
- subevent.addListener(cb, opt_filter, opt_extraInfo);
- AttachComplexEvent(this.eventName_, subevent.eventName_,
- chromeHidden.JSON.stringify(opt_filter),
- chromeHidden.JSON.stringify(opt_extraInfo));
- };
-
- // Unregisters a callback.
- chrome.ComplexEvent.prototype.removeListener = function(cb) {
- var idx = this.findListener_(cb);
- if (!idx) {
- return;
- }
-
- this.subEvents_[idx].removeListener(cb);
- if (!this.subEvents_[idx].hasListeners())
- delete this.subEvents_[idx];
- };
-
- chrome.ComplexEvent.prototype.findListener_ = function(cb) {
- for (var i = 0; i < this.subEvents_.length; i++) {
- if (this.subEvents_[i].findListener_(cb) > -1)
- return i;
- }
-
- return -1;
- };
-
- chrome.ch = chromeHidden;
-
// Special load events: we don't use the DOM unload because that slows
// down tab shutdown. On the other hand, onUnload might not always fire,
// since Chrome will terminate renderers on shutdown (SuddenTermination).
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/a.html b/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/a.html
deleted file mode 100644
index eabe7b8..0000000
--- a/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/a.html
+++ /dev/null
@@ -1 +0,0 @@
-<iframe src="b.html"></iframe>
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.html b/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.html
deleted file mode 100755
index 4ef22cc..0000000
--- a/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.html
+++ /dev/null
@@ -1 +0,0 @@
-<img src="b.jpg"></a>
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.jpg b/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.jpg
deleted file mode 100644
index e69de29..0000000
--- a/chrome/test/data/extensions/api_test/webrequest/events/complexLoad/b.jpg
+++ /dev/null
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/manifest.json b/chrome/test/data/extensions/api_test/webrequest/events/manifest.json
deleted file mode 100644
index 1511d09..0000000
--- a/chrome/test/data/extensions/api_test/webrequest/events/manifest.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "request",
- "version": "1.0",
- "description": "Tests the webRequest API events.",
- "permissions": ["experimental", "tabs"],
- "background_page": "test.html"
-}
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/simpleLoad/a.html b/chrome/test/data/extensions/api_test/webrequest/events/simpleLoad/a.html
deleted file mode 100644
index 18ecdcb..0000000
--- a/chrome/test/data/extensions/api_test/webrequest/events/simpleLoad/a.html
+++ /dev/null
@@ -1 +0,0 @@
-<html></html>
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/test.html b/chrome/test/data/extensions/api_test/webrequest/events/test.html
deleted file mode 100644
index 9d4203b..0000000
--- a/chrome/test/data/extensions/api_test/webrequest/events/test.html
+++ /dev/null
@@ -1,101 +0,0 @@
-<script>
-var expectedEventData;
-var capturedEventData;
-
-function expect(data) {
- expectedEventData = data;
- capturedEventData = [];
-}
-
-function checkExpectations() {
- if (capturedEventData.length < expectedEventData.length) {
- return;
- }
- // TODO(mpcomplete): allow partial ordering of events
- chrome.test.assertEq(JSON.stringify(expectedEventData),
- JSON.stringify(capturedEventData));
- chrome.test.succeed();
-}
-
-function captureEvent(name, details) {
- // TODO(mpcomplete): implement the rest of the parameters.
- delete details.requestId;
- delete details.tabId;
- delete details.timeStamp;
- delete details.type;
- capturedEventData.push([name, details]);
- checkExpectations();
-}
-
-chrome.experimental.webRequest.onBeforeRequest.addListener(
- function(details) {
- captureEvent("onBeforeRequest", details);
-});
-chrome.experimental.webRequest.onRequestSent.addListener(
- function(details) {
- captureEvent("onRequestSent", details);
-});
-chrome.experimental.webRequest.onHeadersReceived.addListener(
- function(details) {
- captureEvent("onHeadersReceived", details);
-});
-chrome.experimental.webRequest.onBeforeRedirect.addListener(
- function(details) {
- captureEvent("onBeforeRedirect", details);
-});
-chrome.experimental.webRequest.onCompleted.addListener(
- function(details) {
- captureEvent("onCompleted", details);
-});
-chrome.experimental.webRequest.onErrorOccurred.addListener(
- function(details) {
- captureEvent("onErrorOccurred", details);
-});
-
-var getURL = chrome.extension.getURL;
-chrome.tabs.getSelected(null, function(tab) {
- var tabId = tab.id;
-
- chrome.test.runTests([
- // Navigates to a blank page.
- function simpleLoad() {
- expect([
- [ "onBeforeRequest",
- {
- method: "GET",
- url: getURL("simpleLoad/a.html")
- }
- ],
- ]);
- chrome.tabs.update(tabId, { url: getURL("simpleLoad/a.html") });
- },
-
- // Navigates to a page with subresources.
- // TODO(mpcomplete): add multiple subresources; requires support for
- // recognizing partial ordering.
- function simpleLoad() {
- expect([
- [ "onBeforeRequest",
- {
- method: "GET",
- url: getURL("complexLoad/a.html")
- }
- ],
- [ "onBeforeRequest",
- {
- method: "GET",
- url: getURL("complexLoad/b.html")
- }
- ],
- [ "onBeforeRequest",
- {
- method: "GET",
- url: getURL("complexLoad/b.jpg")
- }
- ],
- ]);
- chrome.tabs.update(tabId, { url: getURL("complexLoad/a.html") });
- },
- ]);
-});
-</script>
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index a9244b7..eaa77e8 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -150,7 +150,6 @@ class TestingProfile : public Profile {
virtual ExtensionProcessManager* GetExtensionProcessManager() { return NULL; }
virtual ExtensionMessageService* GetExtensionMessageService() { return NULL; }
virtual ExtensionEventRouter* GetExtensionEventRouter() { return NULL; }
- virtual ExtensionIOEventRouter* GetExtensionIOEventRouter() { return NULL; }
virtual SSLHostState* GetSSLHostState() { return NULL; }
virtual net::TransportSecurityState* GetTransportSecurityState() {
return NULL;
diff --git a/net/http/http_network_delegate.h b/net/http/http_network_delegate.h
index 1533bc3..6b60aba 100644
--- a/net/http/http_network_delegate.h
+++ b/net/http/http_network_delegate.h
@@ -9,13 +9,9 @@
namespace net {
class HttpRequestHeaders;
-class URLRequest;
class HttpNetworkDelegate {
public:
- // Called before a request is sent.
- virtual void OnBeforeURLRequest(net::URLRequest* request) = 0;
-
// Called right before the HTTP headers are sent. Allows the delegate to
// read/write |headers| before they get sent out.
virtual void OnSendHttpRequest(HttpRequestHeaders* headers) = 0;
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index c2d0f4f..300c9c6 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -13,7 +13,6 @@
#include "net/base/net_log.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/upload_data.h"
-#include "net/http/http_network_delegate.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request_context.h"
@@ -347,11 +346,6 @@ void URLRequest::StartJob(URLRequestJob* job) {
DCHECK(!is_pending_);
DCHECK(!job_);
- // TODO(mpcomplete): pass in request ID?
- // TODO(mpcomplete): allow delegate to potentially delay/cancel request.
- if (context_ && context_->network_delegate())
- context_->network_delegate()->OnBeforeURLRequest(this);
-
net_log_.BeginEvent(
net::NetLog::TYPE_URL_REQUEST_START_JOB,
make_scoped_refptr(new URLRequestStartEventParameters(
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 18315dc..2c737ca 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -115,11 +115,6 @@ class URLRequestContext
return ftp_transaction_factory_;
}
- void set_network_delegate(HttpNetworkDelegate* network_delegate) {
- network_delegate_ = network_delegate;
- }
- HttpNetworkDelegate* network_delegate() { return network_delegate_; }
-
// Gets the cookie store for this context (may be null, in which case
// cookies are not stored).
CookieStore* cookie_store() { return cookie_store_.get(); }