diff options
Diffstat (limited to 'chrome/browser')
-rwxr-xr-x | chrome/browser/extensions/extension_io_event_router.cc | 38 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_io_event_router.h | 40 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_webrequest_api.cc | 43 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_webrequest_api.h | 35 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_webrequest_apitest.cc | 7 | ||||
-rw-r--r-- | chrome/browser/io_thread.cc | 1 | ||||
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.cc | 21 | ||||
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.h | 5 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 6 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 13 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.h | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 10 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.h | 2 |
14 files changed, 6 insertions, 223 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_; |