diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/appcache/chrome_appcache_service.cc | 20 | ||||
-rw-r--r-- | content/browser/appcache/chrome_appcache_service.h | 10 | ||||
-rw-r--r-- | content/browser/appcache/chrome_appcache_service_unittest.cc | 6 | ||||
-rw-r--r-- | content/browser/content_browser_client.cc | 5 | ||||
-rw-r--r-- | content/browser/content_browser_client.h | 6 |
5 files changed, 30 insertions, 17 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc index 0e8a0f0..b829a92 100644 --- a/content/browser/appcache/chrome_appcache_service.cc +++ b/content/browser/appcache/chrome_appcache_service.cc @@ -6,6 +6,7 @@ #include "base/file_path.h" #include "base/file_util.h" +#include "content/browser/content_browser_client.h" #include "content/common/notification_service.h" #include "net/base/net_errors.h" #include "webkit/appcache/appcache_thread.h" @@ -29,12 +30,12 @@ void DeleteLocalStateOnIOThread(FilePath cache_path) { // ---------------------------------------------------------------------------- ChromeAppCacheService::ChromeAppCacheService() - : clear_local_state_on_exit_(false) { + : resource_context_(NULL), clear_local_state_on_exit_(false) { } void ChromeAppCacheService::InitializeOnIOThread( const FilePath& cache_path, - scoped_refptr<HostContentSettingsMap> content_settings_map, + const content::ResourceContext* resource_context, scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, bool clear_local_state_on_exit) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -45,7 +46,7 @@ void ChromeAppCacheService::InitializeOnIOThread( } cache_path_ = cache_path; - host_contents_settings_map_ = content_settings_map; + resource_context_ = resource_context; registrar_.Add( this, NotificationType::PURGE_MEMORY, NotificationService::AllSources()); SetClearLocalStateOnExit(clear_local_state_on_exit); @@ -82,21 +83,16 @@ void ChromeAppCacheService::SetClearLocalStateOnExit(bool clear_local_state) { bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - ContentSetting setting = host_contents_settings_map_->GetContentSetting( - manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); - DCHECK(setting != CONTENT_SETTING_DEFAULT); // We don't prompt for read access. - return setting != CONTENT_SETTING_BLOCK; + return content::GetContentClient()->browser()->AllowAppCache( + manifest_url, resource_context_); } int ChromeAppCacheService::CanCreateAppCache( const GURL& manifest_url, net::CompletionCallback* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - ContentSetting setting = host_contents_settings_map_->GetContentSetting( - manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); - DCHECK(setting != CONTENT_SETTING_DEFAULT); - return (setting != CONTENT_SETTING_BLOCK) ? net::OK : - net::ERR_ACCESS_DENIED; + return content::GetContentClient()->browser()->AllowAppCache( + manifest_url, resource_context_) ? net::OK : net::ERR_ACCESS_DENIED; } void ChromeAppCacheService::Observe(NotificationType type, diff --git a/content/browser/appcache/chrome_appcache_service.h b/content/browser/appcache/chrome_appcache_service.h index 6b0c1e9..a56d31c 100644 --- a/content/browser/appcache/chrome_appcache_service.h +++ b/content/browser/appcache/chrome_appcache_service.h @@ -7,8 +7,8 @@ #pragma once #include "base/memory/ref_counted.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" #include "content/browser/browser_thread.h" +#include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" #include "webkit/appcache/appcache_policy.h" #include "webkit/appcache/appcache_service.h" @@ -16,6 +16,10 @@ class FilePath; +namespace content { +class ResourceContext; +} + // An AppCacheService subclass used by the chrome. There is an instance // associated with each Profile. This derivation adds refcounting semantics // since a profile has multiple URLRequestContexts which refer to the same @@ -35,7 +39,7 @@ class ChromeAppCacheService void InitializeOnIOThread( const FilePath& cache_path, // may be empty to use in-memory structures - scoped_refptr<HostContentSettingsMap> content_settings_map, + const content::ResourceContext* resource_context, scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, bool clear_local_state_on_exit); @@ -57,7 +61,7 @@ class ChromeAppCacheService const NotificationSource& source, const NotificationDetails& details); - scoped_refptr<HostContentSettingsMap> host_contents_settings_map_; + const content::ResourceContext* resource_context_; NotificationRegistrar registrar_; bool clear_local_state_on_exit_; FilePath cache_path_; diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc index 3e4a975..475bf5c 100644 --- a/content/browser/appcache/chrome_appcache_service_unittest.cc +++ b/content/browser/appcache/chrome_appcache_service_unittest.cc @@ -43,12 +43,13 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) { FilePath appcache_path = temp_dir_.path().Append(chrome::kAppCacheDirname); scoped_refptr<ChromeAppCacheService> appcache_service = new ChromeAppCacheService; + const content::ResourceContext* resource_context = NULL; BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableMethod(appcache_service.get(), &ChromeAppCacheService::InitializeOnIOThread, appcache_path, - scoped_refptr<HostContentSettingsMap>(NULL), + resource_context, scoped_refptr<quota::SpecialStoragePolicy>(NULL), false)); // Make the steps needed to initialize the storage of AppCache data. @@ -74,12 +75,13 @@ TEST_F(ChromeAppCacheServiceTest, RemoveOnDestruction) { FilePath appcache_path = temp_dir_.path().Append(chrome::kAppCacheDirname); scoped_refptr<ChromeAppCacheService> appcache_service = new ChromeAppCacheService; + const content::ResourceContext* resource_context = NULL; BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableMethod(appcache_service.get(), &ChromeAppCacheService::InitializeOnIOThread, appcache_path, - scoped_refptr<HostContentSettingsMap>(NULL), + resource_context, scoped_refptr<quota::SpecialStoragePolicy>(NULL), true)); // Make the steps needed to initialize the storage of AppCache data. diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc index 9cb40e8..2f6d597 100644 --- a/content/browser/content_browser_client.cc +++ b/content/browser/content_browser_client.cc @@ -52,6 +52,11 @@ std::string ContentBrowserClient::GetApplicationLocale() { return std::string(); } +bool ContentBrowserClient::AllowAppCache( + const GURL& manifest_url, const content::ResourceContext* context) { + return true; +} + #if defined(OS_LINUX) 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 2bc9537..145952b 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -20,6 +20,7 @@ class WorkerProcessHost; namespace content { +class ResourceContext; class WebUIFactory; // Embedder API for participating in browser logic. @@ -61,6 +62,11 @@ class ContentBrowserClient { // Returns the locale used by the application. virtual std::string GetApplicationLocale(); + // Allow the embedder to control if an AppCache can be used for the given url. + // This is called on the IO thread. + virtual bool AllowAppCache(const GURL& manifest_url, + const content::ResourceContext* context); + #if defined(OS_LINUX) // Can return an optional fd for crash handling, otherwise returns -1. virtual int GetCrashSignalFD(const std::string& process_type); |