diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 20:37:19 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 20:37:19 +0000 |
commit | 9f3fba5755542d0f9ac5f39540e771713dd666bb (patch) | |
tree | fc5fd4b8c4f9399213f038394267ca969ab9761c /content | |
parent | b42a9f62685ff25438ec0fd689e4b8952b70dd70 (diff) | |
download | chromium_src-9f3fba5755542d0f9ac5f39540e771713dd666bb.zip chromium_src-9f3fba5755542d0f9ac5f39540e771713dd666bb.tar.gz chromium_src-9f3fba5755542d0f9ac5f39540e771713dd666bb.tar.bz2 |
Remove last extension dependencies from content.
- UserScript reference from BufferedResourceHandler.
- ExtensionInfoMap references from RenderMessageFilter and WorkerProcessHost
and ResourceContext.
BUG=76697
Review URL: http://codereview.chromium.org/7135003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/DEPS | 5 | ||||
-rw-r--r-- | content/browser/content_browser_client.cc | 12 | ||||
-rw-r--r-- | content/browser/content_browser_client.h | 14 | ||||
-rw-r--r-- | content/browser/renderer_host/buffered_resource_handler.cc | 7 | ||||
-rw-r--r-- | content/browser/renderer_host/render_message_filter.cc | 15 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.cc | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.h | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host_delegate.cc | 5 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host_delegate.h | 5 | ||||
-rw-r--r-- | content/browser/resource_context.cc | 12 | ||||
-rw-r--r-- | content/browser/resource_context.h | 5 | ||||
-rw-r--r-- | content/browser/worker_host/worker_process_host.cc | 22 |
12 files changed, 56 insertions, 51 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS index 533d414..6883eef 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS @@ -25,11 +25,6 @@ include_rules = [ "+chrome/browser/renderer_host/download_throttling_resource_handler.h", "+chrome/browser/renderer_host/save_file_resource_handler.h", - # http://crbug.com/76789 - "+chrome/browser/extensions/extension_info_map.h", - "+chrome/common/extensions/extension.h", - "+chrome/common/extensions/user_script.h", - "+chrome/browser/load_from_memory_cache_details.h", "+chrome/browser/mach_broker_mac.h", diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc index 86b6d53..f3b9d94 100644 --- a/content/browser/content_browser_client.cc +++ b/content/browser/content_browser_client.cc @@ -137,6 +137,18 @@ void ContentBrowserClient::CancelDesktopNotification( int notification_id) { } +bool ContentBrowserClient::CanCreateWindow( + const GURL& source_url, + WindowContainerType container_type, + const content::ResourceContext& context) { + return false; +} + +std::string ContentBrowserClient::GetWorkerProcessTitle( + const GURL& url, const content::ResourceContext& context) { + return std::string(); +} + #if defined(OS_POSIX) && !defined(OS_MACOSX) int ContentBrowserClient::GetCrashSignalFD(const std::string& process_type) { return -1; diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index 46b854d..4d1220a 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -10,6 +10,7 @@ #include "base/callback_old.h" #include "content/common/content_client.h" +#include "content/common/window_container_type.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h" class BrowserRenderProcessHost; @@ -172,6 +173,19 @@ class ContentBrowserClient { int render_view_id, int notification_id); + // Returns true if the given page is allowed to open a window of the given + // type. This is called on the IO thread. + virtual bool CanCreateWindow( + const GURL& source_url, + WindowContainerType container_type, + const content::ResourceContext& context); + + // Returns a title string to use in the task manager for a process host with + // the given URL, or the empty string to fall back to the default logic. + // This is called on the IO thread. + virtual std::string GetWorkerProcessTitle( + const GURL& url, const content::ResourceContext& context); + #if defined(OS_POSIX) && !defined(OS_MACOSX) // Can return an optional fd for crash handling, otherwise returns -1. virtual int GetCrashSignalFD(const std::string& process_type); diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index 64c8c6a..3e1b6e9 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -10,9 +10,10 @@ #include "base/metrics/histogram.h" #include "base/string_util.h" #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" -#include "chrome/common/extensions/user_script.h" #include "content/browser/browser_thread.h" +#include "content/browser/content_browser_client.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" +#include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" #include "content/common/resource_response.h" @@ -377,8 +378,8 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { return true; } - // Special-case user scripts to get downloaded instead of viewed. - if (UserScript::IsURLUserScript(request_->url(), type)) + if (host_->delegate() && + host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) return true; // MIME type checking. diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index a20698a..fa7aa90 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -15,7 +15,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_types.h" #include "chrome/browser/download/download_util.h" -#include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" @@ -385,16 +384,10 @@ void RenderMessageFilter::OnDestruct() const { void RenderMessageFilter::OnMsgCreateWindow( const ViewHostMsg_CreateWindow_Params& params, int* route_id, int64* cloned_session_storage_namespace_id) { - // If the opener is trying to create a background window but doesn't have - // the appropriate permission, fail the attempt. - if (params.window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { - const Extension* extension = - extension_info_map_->extensions().GetByURL(params.opener_url); - if (!extension || - !extension->HasApiPermission(Extension::kBackgroundPermission)) { - *route_id = MSG_ROUTING_NONE; - return; - } + if (!content::GetContentClient()->browser()->CanCreateWindow( + params.opener_url, params.window_container_type, resource_context_)) { + *route_id = MSG_ROUTING_NONE; + return; } *cloned_session_storage_namespace_id = diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index e6f4191..6c19527 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -2012,5 +2012,3 @@ bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { allow_cross_origin_auth_prompt_ = value; } - - diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h index 9448684..ee476d0 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.h +++ b/content/browser/renderer_host/resource_dispatcher_host.h @@ -250,6 +250,9 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate { void set_delegate(ResourceDispatcherHostDelegate* delegate) { delegate_ = delegate; } + ResourceDispatcherHostDelegate* delegate() { + return delegate_; + } private: FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, diff --git a/content/browser/renderer_host/resource_dispatcher_host_delegate.cc b/content/browser/renderer_host/resource_dispatcher_host_delegate.cc index 79d08dd..c10f999 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_delegate.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_delegate.cc @@ -61,3 +61,8 @@ void ResourceDispatcherHostDelegate::HandleExternalProtocol(const GURL& url, int child_id, int route_id) { } + +bool ResourceDispatcherHostDelegate::ShouldForceDownloadResource( + const GURL& url, const std::string& mime_type) { + return false; +} diff --git a/content/browser/renderer_host/resource_dispatcher_host_delegate.h b/content/browser/renderer_host/resource_dispatcher_host_delegate.h index 4e1e00c..0aee39a 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_delegate.h +++ b/content/browser/renderer_host/resource_dispatcher_host_delegate.h @@ -83,6 +83,11 @@ class ResourceDispatcherHostDelegate { int child_id, int route_id); + // Returns true if we should force the given resource to be downloaded. + // Otherwise, the content layer decides. + virtual bool ShouldForceDownloadResource( + const GURL& url, const std::string& mime_type); + protected: ResourceDispatcherHostDelegate(); virtual ~ResourceDispatcherHostDelegate(); diff --git a/content/browser/resource_context.cc b/content/browser/resource_context.cc index e918585..4e1b977 100644 --- a/content/browser/resource_context.cc +++ b/content/browser/resource_context.cc @@ -131,18 +131,6 @@ void ResourceContext::set_host_zoom_map(HostZoomMap* host_zoom_map) { host_zoom_map_ = host_zoom_map; } -const ExtensionInfoMap* ResourceContext::extension_info_map() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - EnsureInitialized(); - return extension_info_map_; -} - -void ResourceContext::set_extension_info_map( - ExtensionInfoMap* extension_info_map) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - extension_info_map_ = extension_info_map; -} - const base::WeakPtr<prerender::PrerenderManager>& ResourceContext::prerender_manager() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); diff --git a/content/browser/resource_context.h b/content/browser/resource_context.h index 3e71ef4..04ad849 100644 --- a/content/browser/resource_context.h +++ b/content/browser/resource_context.h @@ -74,10 +74,6 @@ class ResourceContext { // ======================================================================= // TODO(willchan): These don't belong in content/. Remove them eventually. - // TODO(mpcomplete): Kill this one. - const ExtensionInfoMap* extension_info_map() const; - void set_extension_info_map(ExtensionInfoMap* extension_info_map); - // TODO(cbentzel): Kill this one. const base::WeakPtr<prerender::PrerenderManager>& prerender_manager() const; void set_prerender_manager( @@ -106,7 +102,6 @@ class ResourceContext { // ======================================================================= // TODO(willchan): These don't belong in content/. Remove them eventually. - ExtensionInfoMap* extension_info_map_; base::WeakPtr<prerender::PrerenderManager> prerender_manager_; DISALLOW_COPY_AND_ASSIGN(ResourceContext); diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index 83ec00b..8dc2e1a 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -12,7 +12,6 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/extensions/extension_info_map.h" #include "content/browser/appcache/appcache_dispatcher_host.h" #include "content/browser/browser_thread.h" #include "content/browser/child_process_security_policy.h" @@ -457,22 +456,19 @@ bool WorkerProcessHost::CanShutdown() { void WorkerProcessHost::UpdateTitle() { std::set<std::string> titles; for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - std::string title = - net::RegistryControlledDomainService::GetDomainAndRegistry(i->url()); + // Allow the embedder first crack at special casing the title. + std::string title = content::GetContentClient()->browser()-> + GetWorkerProcessTitle(i->url(), *resource_context_); + + if (title.empty()) { + title = net::RegistryControlledDomainService::GetDomainAndRegistry( + i->url()); + } + // Use the host name if the domain is empty, i.e. localhost or IP address. if (title.empty()) title = i->url().host(); - // Check if it's an extension-created worker, in which case we want to use - // the name of the extension. - // TODO(mpcomplete): move out of content. http:://crbug.com/76789 - const Extension* extension = - resource_context_->extension_info_map()->extensions().GetByID(title); - if (extension) { - titles.insert(extension->name()); - continue; - } - // If the host name is empty, i.e. file url, use the path. if (title.empty()) title = i->url().path(); |