diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 19:58:31 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 19:58:31 +0000 |
commit | 10c9340596534c8923c3bb04f0d39613c1ad7ee4 (patch) | |
tree | 3178ad2f61682c90ef4fc5b7fad052a03619d1d8 /chrome | |
parent | c14b4028b1e0a79827e27777e74d4e5281be1f78 (diff) | |
download | chromium_src-10c9340596534c8923c3bb04f0d39613c1ad7ee4.zip chromium_src-10c9340596534c8923c3bb04f0d39613c1ad7ee4.tar.gz chromium_src-10c9340596534c8923c3bb04f0d39613c1ad7ee4.tar.bz2 |
Some preliminary ground work for respecting the "Content Settings" in the appcache, and an implementation of the "ClearLocalState" function.
TEST=none
BUG=34344,32719
Review URL: http://codereview.chromium.org/565012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 3 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 9 | ||||
-rw-r--r-- | chrome/common/appcache/chrome_appcache_service.cc | 24 | ||||
-rw-r--r-- | chrome/common/appcache/chrome_appcache_service.h | 12 |
4 files changed, 33 insertions, 15 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index f96fd10..2e4d345 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -34,6 +34,7 @@ #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" +#include "chrome/common/appcache/chrome_appcache_service.h" #include "chrome/common/child_process_host.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -260,7 +261,7 @@ void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) { DOMStorageContext::ClearLocalState(profile_path, chrome::kExtensionScheme); webkit_database::DatabaseTracker::ClearLocalState(profile_path, chrome::kExtensionScheme); - // TODO(jochen): clear app cache local state. + ChromeAppCacheService::ClearLocalState(profile_path); } bool BrowserProcessImpl::ShouldClearLocalState(FilePath* profile_path) { diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index a8349e8..0fe660b 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -188,11 +188,9 @@ ChromeURLRequestContext* FactoryForOriginal::Create() { context->set_cookie_policy( new ChromeCookiePolicy(host_content_settings_map_)); - // Create a new AppCacheService (issues fetches through the - // main URLRequestContext that we just created). + // Create a new AppCacheService. context->set_appcache_service( - new ChromeAppCacheService(profile_dir_path_, false)); - context->appcache_service()->set_request_context(context); + new ChromeAppCacheService(profile_dir_path_, context)); #if defined(OS_LINUX) // TODO(ukai): find a better way to set the URLRequestContext for OCSP. @@ -280,8 +278,7 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() { // Create a separate AppCacheService for OTR mode. context->set_appcache_service( - new ChromeAppCacheService(profile_dir_path_, true)); - context->appcache_service()->set_request_context(context); + new ChromeAppCacheService(profile_dir_path_, context)); return context; } diff --git a/chrome/common/appcache/chrome_appcache_service.cc b/chrome/common/appcache/chrome_appcache_service.cc index cb1f7a3..68e30c7 100644 --- a/chrome/common/appcache/chrome_appcache_service.cc +++ b/chrome/common/appcache/chrome_appcache_service.cc @@ -1,35 +1,49 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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/common/appcache/chrome_appcache_service.h" #include "base/file_path.h" +#include "base/file_util.h" #include "chrome/browser/chrome_thread.h" +#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/notification_service.h" #include "webkit/appcache/appcache_thread.h" static bool has_initialized_thread_ids; -ChromeAppCacheService::ChromeAppCacheService(const FilePath& data_directory, - bool is_incognito) { +ChromeAppCacheService::ChromeAppCacheService( + const FilePath& profile_path, + ChromeURLRequestContext* request_context) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(request_context); + if (!has_initialized_thread_ids) { has_initialized_thread_ids = true; appcache::AppCacheThread::InitIDs(ChromeThread::DB, ChromeThread::IO); } - Initialize(is_incognito ? FilePath() - : data_directory.Append(chrome::kAppCacheDirname)); + host_contents_settings_map_ = request_context->host_content_settings_map(); registrar_.Add( this, NotificationType::PURGE_MEMORY, NotificationService::AllSources()); + + // Init our base class. + Initialize(request_context->is_off_the_record() ? + FilePath() : profile_path.Append(chrome::kAppCacheDirname)); + set_request_context(request_context); } ChromeAppCacheService::~ChromeAppCacheService() { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); } +// static +void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) { + file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true); +} + void ChromeAppCacheService::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { diff --git a/chrome/common/appcache/chrome_appcache_service.h b/chrome/common/appcache/chrome_appcache_service.h index a202601..ec7b0bd 100644 --- a/chrome/common/appcache/chrome_appcache_service.h +++ b/chrome/common/appcache/chrome_appcache_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -6,9 +6,11 @@ #define CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_ #include "base/ref_counted.h" +#include "chrome/browser/host_content_settings_map.h" #include "chrome/common/notification_registrar.h" #include "webkit/appcache/appcache_service.h" +class ChromeURLRequestContext; class FilePath; // An AppCacheService subclass used by the chrome. There is an instance @@ -24,8 +26,11 @@ class ChromeAppCacheService public appcache::AppCacheService, public NotificationObserver { public: - ChromeAppCacheService(const FilePath& data_directory, - bool is_incognito); + ChromeAppCacheService(const FilePath& profile_path, + ChromeURLRequestContext* request_context); + + static void ClearLocalState(const FilePath& profile_path); + private: friend class base::RefCounted<ChromeAppCacheService>; virtual ~ChromeAppCacheService(); @@ -35,6 +40,7 @@ class ChromeAppCacheService const NotificationSource& source, const NotificationDetails& details); + scoped_refptr<HostContentSettingsMap> host_contents_settings_map_; NotificationRegistrar registrar_; }; |