summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-08 19:30:49 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-08 19:30:49 +0000
commita2176798cd1bd8a69b4bb8fd5b94e13423a3a345 (patch)
tree13a6421d8a965296f6b5554c0a6e65d01b18b2e2 /content/browser
parent6488b19f2122c1b1817f0852ea6b47e9c19e9488 (diff)
downloadchromium_src-a2176798cd1bd8a69b4bb8fd5b94e13423a3a345.zip
chromium_src-a2176798cd1bd8a69b4bb8fd5b94e13423a3a345.tar.gz
chromium_src-a2176798cd1bd8a69b4bb8fd5b94e13423a3a345.tar.bz2
Have AppCache code go through the content embedder API for content settings checks.
BUG=76793 Review URL: http://codereview.chromium.org/6951008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84586 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc20
-rw-r--r--content/browser/appcache/chrome_appcache_service.h10
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc6
-rw-r--r--content/browser/content_browser_client.cc5
-rw-r--r--content/browser/content_browser_client.h6
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);