summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 14:39:08 +0000
committerearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 14:39:08 +0000
commit33ad6ce948e24e01ec1634af63001dda4ac0506a (patch)
tree71daec231014a7b05e1a213e2ac0a9a41f4ca52a
parentd0a60eea5c90a5b594604c91654859a493e1b5cb (diff)
downloadchromium_src-33ad6ce948e24e01ec1634af63001dda4ac0506a.zip
chromium_src-33ad6ce948e24e01ec1634af63001dda4ac0506a.tar.gz
chromium_src-33ad6ce948e24e01ec1634af63001dda4ac0506a.tar.bz2
Revert 219709 "Remove the Extensions URLRequestContext."
Reverted due to crashes under memory tools. BUG=280138 > Remove the Extensions URLRequestContext. > > Though chrome-extension: scheme URLs support cookies, they do not share > a namespace with http: and https:. In particular, chrome-extension://a and > http://a should not have the same set of cookies. > > To enforce this, previously the code created a completely separate > URLRequestContext for servicing chrome-extension: schemes. However, > the code really only used this object as a method for conveying the > correct cookie jar from Profile creation to a few spots where cookies > were accessed; the rest of the URLRequestContext functionality was unused. > > This CL removes the Extensions URLRequestContext code and replaces it > with APIs that directly expose the needed net::CookieStore. > > Lastly, CookieMonster::EnableFileScheme() is removed and > CookieMonster::Delegate is renamed CookieMonsterDelegate. > > EnableFileScheme is an inherently racy API because > CookieMonsters are creatable on all threads and this > function sets an unprotected global flag. CookieMonsterDelegate > is preferable to the nested interface because it can now be > forward declared. > > TBRing darin and sky to cover the rest of the mechanical unittest changes. > > TBR=darin,sky > BUG=158386,159193,57884 > > Review URL: https://chromiumcodereview.appspot.com/12546016 TBR=ajwong@chromium.org Review URL: https://codereview.chromium.org/23551005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219787 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/aw_browser_context.cc32
-rw-r--r--android_webview/browser/aw_browser_context.h5
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc6
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.h4
-rw-r--r--android_webview/native/aw_quota_manager_bridge_impl.cc3
-rw-r--r--apps/shell_window_geometry_cache_unittest.cc10
-rw-r--r--chrome/browser/autocomplete/bookmark_provider_unittest.cc3
-rw-r--r--chrome/browser/background/background_contents_service_unittest.cc153
-rw-r--r--chrome/browser/background/background_mode_manager_unittest.cc31
-rw-r--r--chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc29
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover_unittest.cc14
-rw-r--r--chrome/browser/chrome_content_browser_client.cc15
-rw-r--r--chrome/browser/chrome_content_browser_client.h2
-rw-r--r--chrome/browser/diagnostics/sqlite_diagnostics.cc2
-rw-r--r--chrome/browser/download/download_request_limiter_unittest.cc8
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc14
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_unittest.cc3
-rw-r--r--chrome/browser/extensions/api/storage/settings_frontend_unittest.cc22
-rw-r--r--chrome/browser/extensions/api/storage/settings_sync_unittest.cc15
-rw-r--r--chrome/browser/extensions/data_deleter.cc34
-rw-r--r--chrome/browser/extensions/error_console/error_console_unittest.cc9
-rw-r--r--chrome/browser/extensions/extension_process_manager_unittest.cc2
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc11
-rw-r--r--chrome/browser/extensions/extension_warning_badge_service_unittest.cc2
-rw-r--r--chrome/browser/extensions/extension_warning_service_unittest.cc3
-rw-r--r--chrome/browser/extensions/menu_manager_unittest.cc16
-rw-r--r--chrome/browser/history/shortcuts_backend_unittest.cc19
-rw-r--r--chrome/browser/history/shortcuts_database_unittest.cc3
-rw-r--r--chrome/browser/history/thumbnail_database_unittest.cc16
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service_unittest.cc3
-rw-r--r--chrome/browser/io_thread.cc11
-rw-r--r--chrome/browser/managed_mode/managed_user_sync_service_unittest.cc2
-rw-r--r--chrome/browser/net/chrome_cookie_notification_details.h2
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc32
-rw-r--r--chrome/browser/net/chrome_url_request_context.h10
-rw-r--r--chrome/browser/net/cookie_store_util.cc141
-rw-r--r--chrome/browser/net/cookie_store_util.h45
-rw-r--r--chrome/browser/password_manager/password_form_manager_unittest.cc16
-rw-r--r--chrome/browser/predictors/autocomplete_action_predictor_table_unittest.cc29
-rw-r--r--chrome/browser/prefs/pref_model_associator_unittest.cc2
-rw-r--r--chrome/browser/prerender/prerender_unittest.cc10
-rw-r--r--chrome/browser/printing/print_dialog_cloud_unittest.cc37
-rw-r--r--chrome/browser/profile_resetter/profile_resetter_unittest.cc10
-rw-r--r--chrome/browser/profiles/avatar_menu_model_unittest.cc2
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc25
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h8
-rw-r--r--chrome/browser/profiles/off_the_record_profile_io_data.cc66
-rw-r--r--chrome/browser/profiles/off_the_record_profile_io_data.h7
-rw-r--r--chrome/browser/profiles/profile.h4
-rw-r--r--chrome/browser/profiles/profile_impl.cc64
-rw-r--r--chrome/browser/profiles/profile_impl.h9
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc141
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.h12
-rw-r--r--chrome/browser/profiles/profile_io_data.cc75
-rw-r--r--chrome/browser/profiles/profile_io_data.h12
-rw-r--r--chrome/browser/profiles/profile_loader_unittest.cc43
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc11
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc5
-rw-r--r--chrome/browser/signin/signin_manager_unittest.cc28
-rw-r--r--chrome/browser/spellchecker/feedback_sender_unittest.cc7
-rw-r--r--chrome/browser/sync/sync_global_error_unittest.cc1
-rw-r--r--chrome/browser/thumbnails/thumbnail_service_unittest.cc6
-rw-r--r--chrome/browser/ui/autofill/account_chooser_model_unittest.cc2
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_ui_utils_unittest.cc2
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service_unittest.cc2
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_view_gtk_unittest.cc11
-rw-r--r--chrome/browser/ui/omnibox/omnibox_controller_unittest.cc2
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_unittest.cc2
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper_unittest.cc4
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc13
-rw-r--r--chrome/browser/ui/sync/sync_promo_ui_unittest.cc26
-rw-r--r--chrome/browser/ui/webui/net_internals/net_internals_ui.cc1
-rw-r--r--chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc34
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/chrome_constants.cc1
-rw-r--r--chrome/common/chrome_constants.h1
-rw-r--r--chrome/common/chrome_switches.cc4
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/test/base/testing_profile.cc59
-rw-r--r--chrome/test/base/testing_profile.h10
-rw-r--r--components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc9
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc67
-rw-r--r--content/browser/browser_context.cc7
-rw-r--r--content/browser/fileapi/fileapi_message_filter_unittest.cc28
-rw-r--r--content/browser/loader/resource_dispatcher_host_unittest.cc38
-rw-r--r--content/browser/loader/resource_message_filter.h1
-rw-r--r--content/browser/net/cookie_store_map.cc104
-rw-r--r--content/browser/net/cookie_store_map.h62
-rw-r--r--content/browser/net/sqlite_persistent_cookie_store.cc50
-rw-r--r--content/browser/renderer_host/render_message_filter.cc73
-rw-r--r--content/browser/renderer_host/render_message_filter.h14
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc3
-rw-r--r--content/browser/storage_partition_impl.cc81
-rw-r--r--content/browser/storage_partition_impl.h22
-rw-r--r--content/browser/storage_partition_impl_map.cc90
-rw-r--r--content/browser/storage_partition_impl_map.h5
-rw-r--r--content/browser/storage_partition_impl_unittest.cc5
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/public/browser/browser_context.h27
-rw-r--r--content/public/browser/content_browser_client.cc5
-rw-r--r--content/public/browser/content_browser_client.h10
-rw-r--r--content/public/browser/cookie_store_factory.h40
-rw-r--r--content/public/browser/storage_partition.h15
-rw-r--r--content/public/common/content_constants.cc3
-rw-r--r--content/public/common/content_constants.h2
-rw-r--r--content/public/common/content_switches.cc4
-rw-r--r--content/public/common/content_switches.h1
-rw-r--r--content/public/test/mock_resource_context.cc10
-rw-r--r--content/public/test/mock_resource_context.h4
-rw-r--r--content/public/test/test_browser_context.cc10
-rw-r--r--content/shell/app/shell_main_delegate.cc2
-rw-r--r--content/shell/browser/shell_browser_context.cc1
-rw-r--r--content/shell/browser/shell_url_request_context_getter.cc4
-rw-r--r--content/test/test_content_browser_client.cc9
-rw-r--r--content/test/test_content_browser_client.h7
-rw-r--r--net/cookies/cookie_monster.cc53
-rw-r--r--net/cookies/cookie_monster.h34
-rw-r--r--net/cookies/cookie_monster_store_test.h6
-rw-r--r--net/cookies/cookie_monster_unittest.cc2
-rw-r--r--net/cookies/cookie_store.h1
-rw-r--r--webkit/support/test_webkit_platform_support.cc2
121 files changed, 1150 insertions, 1302 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index 20b73913..9700645 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -21,9 +21,6 @@
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/content_constants.h"
-#include "content/public/common/url_constants.h"
-#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request_context.h"
namespace android_webview {
@@ -98,11 +95,16 @@ AwBrowserContext* AwBrowserContext::FromWebContents(
}
void AwBrowserContext::PreMainMessageLoopRun() {
- url_request_context_getter_ = new AwURLRequestContextGetter(GetPath());
+ cookie_store_ = content::CreatePersistentCookieStore(
+ GetPath().Append(FILE_PATH_LITERAL("Cookies")),
+ true,
+ NULL,
+ NULL);
+ cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true);
+ url_request_context_getter_ =
+ new AwURLRequestContextGetter(GetPath(), cookie_store_.get());
- DidCreateCookieMonster(
- GetDefaultStoragePartition(this)->GetCookieStoreForScheme(
- chrome::kHttpScheme)->GetCookieMonster());
+ DidCreateCookieMonster(cookie_store_->GetCookieMonster());
visitedlink_master_.reset(
new visitedlink::VisitedLinkMaster(this, this, false));
@@ -180,22 +182,6 @@ base::FilePath AwBrowserContext::GetPath() const {
return context_storage_path_;
}
-void AwBrowserContext::OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) {
- using content::CookieStoreConfig;
- configs->clear();
- // By default session cookies are always restored. An Android application can
- // control this policy by calling CookieManager.removeSessionCookie() when
- // Activity.onCreate() is called with savedInstanceState == null.
- (*configs)[content::BrowserContext::kDefaultCookieScheme] =
- CookieStoreConfig(partition_path.Append(content::kCookieFilename),
- CookieStoreConfig::RESTORED_SESSION_COOKIES,
- NULL, NULL);
-}
-
bool AwBrowserContext::IsOffTheRecord() const {
// Android WebView does not support off the record profile yet.
return false;
diff --git a/android_webview/browser/aw_browser_context.h b/android_webview/browser/aw_browser_context.h
index bca66d7..1654d9a 100644
--- a/android_webview/browser/aw_browser_context.h
+++ b/android_webview/browser/aw_browser_context.h
@@ -77,11 +77,6 @@ class AwBrowserContext : public content::BrowserContext,
// content::BrowserContext implementation.
virtual base::FilePath GetPath() const OVERRIDE;
- virtual void OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) OVERRIDE;
virtual bool IsOffTheRecord() const OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index 069d194..4a5ea41 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -16,8 +16,8 @@
#include "base/threading/sequenced_worker_pool.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/content_client.h"
-#include "content/public/common/content_constants.h"
#include "content/public/common/url_constants.h"
#include "net/base/cache_type.h"
#include "net/cookies/cookie_store.h"
@@ -121,8 +121,9 @@ scoped_ptr<net::URLRequestJobFactory> CreateJobFactory(
} // namespace
AwURLRequestContextGetter::AwURLRequestContextGetter(
- const base::FilePath& partition_path)
+ const base::FilePath& partition_path, net::CookieStore* cookie_store)
: partition_path_(partition_path),
+ cookie_store_(cookie_store),
proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService(
GetNetworkTaskRunner(),
NULL /* Ignored on Android */)) {
@@ -168,6 +169,7 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)));
main_http_factory_.reset(main_cache);
url_request_context_->set_http_transaction_factory(main_cache);
+ url_request_context_->set_cookie_store(cookie_store_);
job_factory_ = CreateJobFactory(&protocol_handlers_);
url_request_context_->set_job_factory(job_factory_.get());
diff --git a/android_webview/browser/net/aw_url_request_context_getter.h b/android_webview/browser/net/aw_url_request_context_getter.h
index 40a8395..c16098e 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.h
+++ b/android_webview/browser/net/aw_url_request_context_getter.h
@@ -28,7 +28,8 @@ class AwNetworkDelegate;
class AwURLRequestContextGetter : public net::URLRequestContextGetter {
public:
- AwURLRequestContextGetter(const base::FilePath& partition_path);
+ AwURLRequestContextGetter(const base::FilePath& partition_path,
+ net::CookieStore* cookie_store);
void InitializeOnNetworkThread();
@@ -52,6 +53,7 @@ class AwURLRequestContextGetter : public net::URLRequestContextGetter {
void InitializeURLRequestContext();
const base::FilePath partition_path_;
+ scoped_refptr<net::CookieStore> cookie_store_;
scoped_ptr<net::URLRequestContext> url_request_context_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::URLRequestJobFactory> job_factory_;
diff --git a/android_webview/native/aw_quota_manager_bridge_impl.cc b/android_webview/native/aw_quota_manager_bridge_impl.cc
index 368a2f4..b105c27 100644
--- a/android_webview/native/aw_quota_manager_bridge_impl.cc
+++ b/android_webview/native/aw_quota_manager_bridge_impl.cc
@@ -208,7 +208,8 @@ void AwQuotaManagerBridgeImpl::DeleteOrigin(
StoragePartition::REMOVE_DATA_MASK_INDEXEDDB |
StoragePartition::REMOVE_DATA_MASK_WEBSQL,
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_TEMPORARY,
- GURL(base::android::ConvertJavaStringToUTF16(env, origin)));
+ GURL(base::android::ConvertJavaStringToUTF16(env, origin)),
+ storage_partition->GetURLRequestContext());
}
void AwQuotaManagerBridgeImpl::GetOrigins(
diff --git a/apps/shell_window_geometry_cache_unittest.cc b/apps/shell_window_geometry_cache_unittest.cc
index 0d6e6e4..2b42d48 100644
--- a/apps/shell_window_geometry_cache_unittest.cc
+++ b/apps/shell_window_geometry_cache_unittest.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/test_extension_prefs.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -27,9 +27,10 @@ namespace apps {
// Base class for tests.
class ShellWindowGeometryCacheTest : public testing::Test {
public:
- ShellWindowGeometryCacheTest() {
+ ShellWindowGeometryCacheTest() :
+ ui_thread_(BrowserThread::UI, &ui_message_loop_) {
prefs_.reset(new extensions::TestExtensionPrefs(
- base::MessageLoopForUI::current()->message_loop_proxy().get()));
+ ui_message_loop_.message_loop_proxy().get()));
cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs()));
cache_->SetSyncDelayForTests(0);
}
@@ -49,8 +50,9 @@ class ShellWindowGeometryCacheTest : public testing::Test {
void UnloadExtension(const std::string& extension_id);
protected:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
+ base::MessageLoopForUI ui_message_loop_;
+ content::TestBrowserThread ui_thread_;
scoped_ptr<extensions::TestExtensionPrefs> prefs_;
scoped_ptr<ShellWindowGeometryCache> cache_;
};
diff --git a/chrome/browser/autocomplete/bookmark_provider_unittest.cc b/chrome/browser/autocomplete/bookmark_provider_unittest.cc
index 71ee42b..b48bf39 100644
--- a/chrome/browser/autocomplete/bookmark_provider_unittest.cc
+++ b/chrome/browser/autocomplete/bookmark_provider_unittest.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
// The bookmark corpus against which we will simulate searches.
@@ -63,7 +62,6 @@ class BookmarkProviderTest : public testing::Test,
protected:
virtual void SetUp() OVERRIDE;
- scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
scoped_ptr<TestingProfile> profile_;
scoped_ptr<BookmarkModel> model_;
scoped_refptr<BookmarkProvider> provider_;
@@ -73,7 +71,6 @@ class BookmarkProviderTest : public testing::Test,
};
void BookmarkProviderTest::SetUp() {
- thread_bundle_.reset(new content::TestBrowserThreadBundle());
profile_.reset(new TestingProfile());
DCHECK(profile_.get());
provider_ = new BookmarkProvider(this, profile_.get());
diff --git a/chrome/browser/background/background_contents_service_unittest.cc b/chrome/browser/background/background_contents_service_unittest.cc
index f739fda..a58cfbc 100644
--- a/chrome/browser/background/background_contents_service_unittest.cc
+++ b/chrome/browser/background/background_contents_service_unittest.cc
@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
-#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/background/background_contents_service.h"
#include "chrome/browser/background/background_contents_service_factory.h"
@@ -17,39 +16,19 @@
#include "chrome/browser/tab_contents/background_contents.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/pref_names.h"
-#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/browser/notification_service.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
-#include "ui/message_center/message_center.h"
#include "url/gurl.h"
class BackgroundContentsServiceTest : public testing::Test {
- protected:
- BackgroundContentsServiceTest()
- : command_line_(CommandLine::NO_PROGRAM),
- profile_manager_(TestingBrowserProcess::GetGlobal()),
- profile_(NULL) {
- CHECK(profile_manager_.SetUp());
- profile_ = profile_manager_.CreateTestingProfile("TestProfile");
- service_.reset(new BackgroundContentsService(profile_, &command_line_));
- BackgroundContentsServiceFactory::GetInstance()->
- RegisterUserPrefsOnBrowserContext(profile_);
- }
-
- virtual ~BackgroundContentsServiceTest() {
- base::RunLoop().RunUntilIdle();
- }
-
- static void SetUpTestCase() {
- message_center::MessageCenter::Initialize();
- }
- static void TearDownTestCase() {
- message_center::MessageCenter::Shutdown();
+ public:
+ BackgroundContentsServiceTest() {}
+ virtual ~BackgroundContentsServiceTest() {}
+ virtual void SetUp() {
+ command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM));
}
const DictionaryValue* GetPrefs(Profile* profile) {
@@ -68,11 +47,7 @@ class BackgroundContentsServiceTest : public testing::Test {
return url;
}
- content::TestBrowserThreadBundle thread_bundle;
- CommandLine command_line_;
- TestingProfileManager profile_manager_;
- TestingProfile* profile_; // Not owned.
- scoped_ptr<BackgroundContentsService> service_;
+ scoped_ptr<CommandLine> command_line_;
};
class MockBackgroundContents : public BackgroundContents {
@@ -122,87 +97,104 @@ class MockBackgroundContents : public BackgroundContents {
private:
GURL url_;
- // The ID of our parent application.
+ // The ID of our parent application
string16 appid_;
- // Parent profile. Not owned.
+ // Parent profile
Profile* profile_;
};
TEST_F(BackgroundContentsServiceTest, Create) {
- // Check for creation and leaks when the basic objects in the
- // fixtures are created/destructed.
+ // Check for creation and leaks.
+ TestingProfile profile;
+ BackgroundContentsService service(&profile, command_line_.get());
}
TEST_F(BackgroundContentsServiceTest, BackgroundContentsCreateDestroy) {
- MockBackgroundContents* contents = new MockBackgroundContents(profile_);
- EXPECT_FALSE(service_->IsTracked(contents));
- contents->SendOpenedNotification(service_.get());
- EXPECT_TRUE(service_->IsTracked(contents));
+ TestingProfile profile;
+ BackgroundContentsService service(&profile, command_line_.get());
+ MockBackgroundContents* contents = new MockBackgroundContents(&profile);
+ EXPECT_FALSE(service.IsTracked(contents));
+ contents->SendOpenedNotification(&service);
+ EXPECT_TRUE(service.IsTracked(contents));
delete contents;
- EXPECT_FALSE(service_->IsTracked(contents));
+ EXPECT_FALSE(service.IsTracked(contents));
}
TEST_F(BackgroundContentsServiceTest, BackgroundContentsUrlAdded) {
+ TestingProfile profile;
+ BackgroundContentsService service(&profile, command_line_.get());
+ BackgroundContentsServiceFactory::GetInstance()->
+ RegisterUserPrefsOnBrowserContext(&profile);
GURL orig_url;
GURL url("http://a/");
GURL url2("http://a/");
{
scoped_ptr<MockBackgroundContents> contents(
- new MockBackgroundContents(profile_));
- EXPECT_EQ(0U, GetPrefs(profile_)->size());
- contents->SendOpenedNotification(service_.get());
+ new MockBackgroundContents(&profile));
+ EXPECT_EQ(0U, GetPrefs(&profile)->size());
+ contents->SendOpenedNotification(&service);
contents->Navigate(url);
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
- EXPECT_EQ(url.spec(), GetPrefURLForApp(profile_, contents->appid()));
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
+ EXPECT_EQ(url.spec(), GetPrefURLForApp(&profile, contents->appid()));
// Navigate the contents to a new url, should not change url.
contents->Navigate(url2);
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
- EXPECT_EQ(url.spec(), GetPrefURLForApp(profile_, contents->appid()));
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
+ EXPECT_EQ(url.spec(), GetPrefURLForApp(&profile, contents->appid()));
}
// Contents are deleted, url should persist.
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
}
TEST_F(BackgroundContentsServiceTest, BackgroundContentsUrlAddedAndClosed) {
+ TestingProfile profile;
+ BackgroundContentsService service(&profile, command_line_.get());
+ BackgroundContentsServiceFactory::GetInstance()->
+ RegisterUserPrefsOnBrowserContext(&profile);
+
GURL url("http://a/");
- MockBackgroundContents* contents = new MockBackgroundContents(profile_);
- EXPECT_EQ(0U, GetPrefs(profile_)->size());
- contents->SendOpenedNotification(service_.get());
+ MockBackgroundContents* contents = new MockBackgroundContents(&profile);
+ EXPECT_EQ(0U, GetPrefs(&profile)->size());
+ contents->SendOpenedNotification(&service);
contents->Navigate(url);
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
- EXPECT_EQ(url.spec(), GetPrefURLForApp(profile_, contents->appid()));
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
+ EXPECT_EQ(url.spec(), GetPrefURLForApp(&profile, contents->appid()));
// Fake a window closed by script.
- contents->MockClose(profile_);
- EXPECT_EQ(0U, GetPrefs(profile_)->size());
+ contents->MockClose(&profile);
+ EXPECT_EQ(0U, GetPrefs(&profile)->size());
}
// Test what happens if a BackgroundContents shuts down (say, due to a renderer
// crash) then is restarted. Should not persist URL twice.
TEST_F(BackgroundContentsServiceTest, RestartBackgroundContents) {
+ TestingProfile profile;
+ BackgroundContentsService service(&profile, command_line_.get());
+ BackgroundContentsServiceFactory::GetInstance()->
+ RegisterUserPrefsOnBrowserContext(&profile);
+
GURL url("http://a/");
{
scoped_ptr<MockBackgroundContents> contents(new MockBackgroundContents(
- profile_, "appid"));
- contents->SendOpenedNotification(service_.get());
+ &profile, "appid"));
+ contents->SendOpenedNotification(&service);
contents->Navigate(url);
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
- EXPECT_EQ(url.spec(), GetPrefURLForApp(profile_, contents->appid()));
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
+ EXPECT_EQ(url.spec(), GetPrefURLForApp(&profile, contents->appid()));
}
// Contents deleted, url should be persisted.
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
{
// Reopen the BackgroundContents to the same URL, we should not register the
// URL again.
scoped_ptr<MockBackgroundContents> contents(new MockBackgroundContents(
- profile_, "appid"));
- contents->SendOpenedNotification(service_.get());
+ &profile, "appid"));
+ contents->SendOpenedNotification(&service);
contents->Navigate(url);
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
}
}
@@ -210,29 +202,34 @@ TEST_F(BackgroundContentsServiceTest, RestartBackgroundContents) {
// between a BackgroundContents and its parent extension, including
// unregistering the BC when the extension is uninstalled.
TEST_F(BackgroundContentsServiceTest, TestApplicationIDLinkage) {
- EXPECT_EQ(NULL, service_->GetAppBackgroundContents(ASCIIToUTF16("appid")));
- MockBackgroundContents* contents = new MockBackgroundContents(profile_,
+ TestingProfile profile;
+ BackgroundContentsService service(&profile, command_line_.get());
+ BackgroundContentsServiceFactory::GetInstance()->
+ RegisterUserPrefsOnBrowserContext(&profile);
+
+ EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid")));
+ MockBackgroundContents* contents = new MockBackgroundContents(&profile,
"appid");
scoped_ptr<MockBackgroundContents> contents2(
- new MockBackgroundContents(profile_, "appid2"));
- contents->SendOpenedNotification(service_.get());
- EXPECT_EQ(contents, service_->GetAppBackgroundContents(contents->appid()));
- contents2->SendOpenedNotification(service_.get());
- EXPECT_EQ(contents2.get(), service_->GetAppBackgroundContents(
+ new MockBackgroundContents(&profile, "appid2"));
+ contents->SendOpenedNotification(&service);
+ EXPECT_EQ(contents, service.GetAppBackgroundContents(contents->appid()));
+ contents2->SendOpenedNotification(&service);
+ EXPECT_EQ(contents2.get(), service.GetAppBackgroundContents(
contents2->appid()));
- EXPECT_EQ(0U, GetPrefs(profile_)->size());
+ EXPECT_EQ(0U, GetPrefs(&profile)->size());
// Navigate the contents, then make sure the one associated with the extension
// is unregistered.
GURL url("http://a/");
GURL url2("http://b/");
contents->Navigate(url);
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
contents2->Navigate(url2);
- EXPECT_EQ(2U, GetPrefs(profile_)->size());
- service_->ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid"));
- EXPECT_FALSE(service_->IsTracked(contents));
- EXPECT_EQ(NULL, service_->GetAppBackgroundContents(ASCIIToUTF16("appid")));
- EXPECT_EQ(1U, GetPrefs(profile_)->size());
- EXPECT_EQ(url2.spec(), GetPrefURLForApp(profile_, contents2->appid()));
+ EXPECT_EQ(2U, GetPrefs(&profile)->size());
+ service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid"));
+ EXPECT_FALSE(service.IsTracked(contents));
+ EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid")));
+ EXPECT_EQ(1U, GetPrefs(&profile)->size());
+ EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid()));
}
diff --git a/chrome/browser/background/background_mode_manager_unittest.cc b/chrome/browser/background/background_mode_manager_unittest.cc
index 7624532..2f222f1 100644
--- a/chrome/browser/background/background_mode_manager_unittest.cc
+++ b/chrome/browser/background/background_mode_manager_unittest.cc
@@ -6,47 +6,26 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/background/background_mode_manager.h"
-#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_unittest_util.h"
-#include "ui/message_center/message_center.h"
class BackgroundModeManagerTest : public testing::Test {
- protected:
+ public:
BackgroundModeManagerTest()
- : profile_manager_(TestingBrowserProcess::GetGlobal()) {
+ : profile_manager_(TestingBrowserProcess::GetGlobal()) {}
+ virtual ~BackgroundModeManagerTest() {}
+ virtual void SetUp() {
command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM));
- CHECK(profile_manager_.SetUp());
-#if defined(OS_CHROMEOS)
- // Because of the http://crbug.com/119175 workaround in the test
- // constructor, browser shutdown needs to be reset otherwise
- // subsequent test will fail.
- browser_shutdown::SetTryingToQuit(false);
-#endif // defined(OS_CHROMEOS)
- }
-
- static void SetUpTestCase() {
- message_center::MessageCenter::Initialize();
-#if defined(OS_CHROMEOS)
- // Needed to handle http://crbug.com/119175.
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kDisableZeroBrowsersOpenForTests);
-#endif // defined(OS_CHROMEOS)
+ ASSERT_TRUE(profile_manager_.SetUp());
}
- static void TearDownTestCase() {
- message_center::MessageCenter::Shutdown();
- }
-
scoped_ptr<CommandLine> command_line_;
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfileManager profile_manager_;
};
diff --git a/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc b/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc
index 532d89e..7e02b83 100644
--- a/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc
@@ -7,8 +7,6 @@
#include "base/bind.h"
#include "base/run_loop.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/storage_partition.h"
-#include "content/public/common/url_constants.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/parsed_cookie.h"
@@ -23,32 +21,25 @@ class BrowsingDataCookieHelperTest : public testing::Test {
: testing_profile_(new TestingProfile()) {
}
- net::CookieMonster* GetCookieMonster(const GURL& origin) {
- using content::BrowserContext;
- // Since it's a unittest, assume default StoragePartition.
- return BrowserContext::GetDefaultStoragePartition(testing_profile_.get())->
- GetCookieStoreForScheme(origin.scheme())->GetCookieMonster();
- }
-
void CreateCookiesForTest() {
- GURL origin1("http://www.google.com");
- GURL origin2("http://www.gmail.google.com");
- GetCookieMonster(origin1)->SetCookieWithOptionsAsync(
- origin1, "A=1", net::CookieOptions(),
+ scoped_refptr<net::CookieMonster> cookie_monster =
+ testing_profile_->GetCookieMonster();
+ cookie_monster->SetCookieWithOptionsAsync(
+ GURL("http://www.google.com"), "A=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback());
- GetCookieMonster(origin2)->SetCookieWithOptionsAsync(
- origin2, "B=1", net::CookieOptions(),
+ cookie_monster->SetCookieWithOptionsAsync(
+ GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback());
}
void CreateCookiesForDomainCookieTest() {
- GURL origin("http://www.google.com");
- scoped_refptr<net::CookieMonster> cookie_monster = GetCookieMonster(origin);
+ scoped_refptr<net::CookieMonster> cookie_monster =
+ testing_profile_->GetCookieMonster();
cookie_monster->SetCookieWithOptionsAsync(
- origin, "A=1", net::CookieOptions(),
+ GURL("http://www.google.com"), "A=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback());
cookie_monster->SetCookieWithOptionsAsync(
- origin, "A=2; Domain=.www.google.com ",
+ GURL("http://www.google.com"), "A=2; Domain=.www.google.com ",
net::CookieOptions(), net::CookieMonster::SetCookiesCallback());
}
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 7ec7e48..3de958d 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -31,15 +31,12 @@
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager_observer.h"
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/storage_partition.h"
-#include "content/public/common/url_constants.h"
+#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "content/public/test/test_utils.h"
#include "net/cookies/cookie_monster.h"
#include "net/ssl/server_bound_cert_service.h"
#include "net/ssl/server_bound_cert_store.h"
@@ -226,9 +223,8 @@ class RemoveCookieTester {
class RemoveProfileCookieTester : public RemoveCookieTester {
public:
explicit RemoveProfileCookieTester(TestingProfile* profile) {
- SetMonster(
- content::BrowserContext::GetDefaultStoragePartition(profile)->
- GetCookieStoreForScheme(chrome::kHttpScheme)->GetCookieMonster());
+ SetMonster(profile->GetRequestContext()->GetURLRequestContext()->
+ cookie_store()->GetCookieMonster());
}
};
@@ -245,9 +241,7 @@ class RemoveSafeBrowsingCookieTester : public RemoveCookieTester {
// Create a cookiemonster that does not have persistant storage, and replace
// the SafeBrowsingService created one with it.
- net::CookieStore* monster =
- content::CreateCookieStore(content::CookieStoreConfig())->
- GetCookieMonster();
+ net::CookieStore* monster = new net::CookieMonster(NULL, NULL);
sb_service->url_request_context()->GetURLRequestContext()->
set_cookie_store(monster);
SetMonster(monster);
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index cdefe7c..2d60399f 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -116,7 +116,6 @@
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/child_process_security_policy.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h"
@@ -124,7 +123,6 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/child_process_host.h"
-#include "content/public/common/content_constants.h"
#include "content/public/common/content_descriptors.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/constants.h"
@@ -135,7 +133,6 @@
#include "net/base/mime_util.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_options.h"
-#include "net/cookies/cookie_store.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "ui/base/l10n/l10n_util.h"
@@ -1653,6 +1650,18 @@ bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
return allow;
}
+net::URLRequestContext*
+ChromeContentBrowserClient::OverrideRequestContextForURL(
+ const GURL& url, content::ResourceContext* context) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (url.SchemeIs(extensions::kExtensionScheme)) {
+ ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
+ return io_data->extensions_request_context();
+ }
+
+ return NULL;
+}
+
QuotaPermissionContext*
ChromeContentBrowserClient::CreateQuotaPermissionContext() {
return new ChromeQuotaPermissionContext();
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index 9dea99d..fbe28f8 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -145,6 +145,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
+ virtual net::URLRequestContext* OverrideRequestContextForURL(
+ const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual content::QuotaPermissionContext*
CreateQuotaPermissionContext() OVERRIDE;
virtual void AllowCertificateError(
diff --git a/chrome/browser/diagnostics/sqlite_diagnostics.cc b/chrome/browser/diagnostics/sqlite_diagnostics.cc
index 0560e65..dcb3491 100644
--- a/chrome/browser/diagnostics/sqlite_diagnostics.cc
+++ b/chrome/browser/diagnostics/sqlite_diagnostics.cc
@@ -219,7 +219,7 @@ DiagnosticsTest* MakeSqliteArchivedHistoryDbTest() {
DiagnosticsTest* MakeSqliteCookiesDbTest() {
return new SqliteIntegrityTest(SqliteIntegrityTest::CRITICAL,
DIAGNOSTICS_SQLITE_INTEGRITY_COOKIE_TEST,
- base::FilePath(content::kCookieFilename));
+ base::FilePath(chrome::kCookieFilename));
}
DiagnosticsTest* MakeSqliteWebDatabaseTrackerDbTest() {
diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc
index 9ec96d2..06cd852 100644
--- a/chrome/browser/download/download_request_limiter_unittest.cc
+++ b/chrome/browser/download/download_request_limiter_unittest.cc
@@ -14,7 +14,6 @@
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::WebContents;
@@ -38,8 +37,7 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness {
&DownloadRequestLimiterTest::FakeCreate, base::Unretained(this));
DownloadRequestInfoBarDelegate::SetCallbackForTesting(
&fake_create_callback_);
- content_settings_ = new HostContentSettingsMap(
- Profile::FromBrowserContext(browser_context())->GetPrefs(), false);
+ content_settings_ = new HostContentSettingsMap(profile_.GetPrefs(), false);
DownloadRequestLimiter::SetContentSettingsForTesting(
content_settings_.get());
}
@@ -141,9 +139,7 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness {
private:
DownloadRequestInfoBarDelegate::FakeCreateCallback fake_create_callback_;
- virtual content::BrowserContext* CreateBrowserContext() OVERRIDE {
- return new TestingProfile();
- }
+ TestingProfile profile_;
};
TEST_F(DownloadRequestLimiterTest,
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc
index 08fc996..39d3908 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc
@@ -6,6 +6,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
#include "chrome/browser/extensions/event_names.h"
@@ -14,7 +15,7 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/common/extensions/api/bluetooth.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
#include "device/bluetooth/test/mock_bluetooth_device.h"
#include "device/bluetooth/test/mock_bluetooth_profile.h"
@@ -86,7 +87,8 @@ class ExtensionBluetoothEventRouterTest : public testing::Test {
ExtensionBluetoothEventRouterTest()
: mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>()),
test_profile_(new TestingProfile()),
- router_(test_profile_.get()) {
+ router_(test_profile_.get()),
+ ui_thread_(content::BrowserThread::UI, &message_loop_) {
router_.SetAdapterForTest(mock_adapter_);
}
@@ -94,17 +96,19 @@ class ExtensionBluetoothEventRouterTest : public testing::Test {
// Some profile-dependent services rely on UI thread to clean up. We make
// sure they are properly cleaned up by running the UI message loop until
// idle.
- test_profile_.reset();
- base::RunLoop().RunUntilIdle();
+ test_profile_.reset(NULL);
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
}
protected:
- content::TestBrowserThreadBundle thread_bundle_;
testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_;
testing::NiceMock<device::MockBluetoothProfile> mock_audio_profile_;
testing::NiceMock<device::MockBluetoothProfile> mock_health_profile_;
scoped_ptr<TestingProfile> test_profile_;
ExtensionBluetoothEventRouter router_;
+ base::MessageLoopForUI message_loop_;
+ content::TestBrowserThread ui_thread_;
};
TEST_F(ExtensionBluetoothEventRouterTest, BluetoothEventListener) {
diff --git a/chrome/browser/extensions/api/cookies/cookies_unittest.cc b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
index 6de2b19..b5fda79 100644
--- a/chrome/browser/extensions/api/cookies/cookies_unittest.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/extensions/api/cookies/cookies_helpers.h"
#include "chrome/common/extensions/api/cookies.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_constants.h"
#include "url/gurl.h"
@@ -40,7 +39,6 @@ class ExtensionCookiesTest : public testing::Test {
};
TEST_F(ExtensionCookiesTest, StoreIdProfileConversion) {
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile::Builder profile_builder;
TestingProfile::Builder otr_profile_builder;
otr_profile_builder.SetIncognito();
@@ -112,7 +110,6 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) {
ASSERT_TRUE(cookie2->expiration_date.get());
EXPECT_EQ(10000, *cookie2->expiration_date);
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
base::ListValue* tab_ids_list = new base::ListValue();
std::vector<int> tab_ids;
diff --git a/chrome/browser/extensions/api/storage/settings_frontend_unittest.cc b/chrome/browser/extensions/api/storage/settings_frontend_unittest.cc
index 249d54e..9eb8e45 100644
--- a/chrome/browser/extensions/api/storage/settings_frontend_unittest.cc
+++ b/chrome/browser/extensions/api/storage/settings_frontend_unittest.cc
@@ -7,7 +7,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h"
@@ -15,8 +14,7 @@
#include "chrome/browser/extensions/api/storage/settings_namespace.h"
#include "chrome/browser/extensions/api/storage/settings_test_util.h"
#include "chrome/browser/value_store/value_store.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
@@ -54,7 +52,9 @@ scoped_ptr<Value> CreateMegabyte() {
class ExtensionSettingsFrontendTest : public testing::Test {
public:
ExtensionSettingsFrontendTest()
- : storage_factory_(new util::ScopedSettingsStorageFactory()) {}
+ : storage_factory_(new util::ScopedSettingsStorageFactory()),
+ ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
+ file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {}
virtual void SetUp() OVERRIDE {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
@@ -66,7 +66,7 @@ class ExtensionSettingsFrontendTest : public testing::Test {
frontend_.reset();
profile_.reset();
// Execute any pending deletion tasks.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
protected:
@@ -76,11 +76,15 @@ class ExtensionSettingsFrontendTest : public testing::Test {
SettingsFrontend::Create(storage_factory_.get(), profile_.get()));
}
- content::TestBrowserThreadBundle thread_bundle_;
base::ScopedTempDir temp_dir_;
scoped_ptr<util::MockProfile> profile_;
scoped_ptr<SettingsFrontend> frontend_;
scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_;
+
+ private:
+ base::MessageLoop message_loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread file_thread_;
};
// Get a semblance of coverage for both extension and app settings by
@@ -137,7 +141,7 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) {
// This would be triggered by extension uninstall via a DataDeleter.
frontend_->DeleteStorageSoon(id);
- base::RunLoop().RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
// The storage area may no longer be valid post-uninstall, so re-request.
storage = util::GetStorage(id, frontend_.get());
@@ -173,7 +177,7 @@ TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) {
}
frontend_.reset();
- base::RunLoop().RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
// TODO(kalman): Figure out why this fails, despite appearing to work.
// Leaving this commented out rather than disabling the whole test so that the
// deletion code paths are at least exercised.
@@ -278,7 +282,7 @@ TEST_F(ExtensionSettingsFrontendTest,
frontend_->RunWithStorage(
id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback));
- base::RunLoop().RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
} // namespace extensions
diff --git a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
index 55870e4..0480062 100644
--- a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
+++ b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
@@ -7,7 +7,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
-#include "base/run_loop.h"
+#include "base/message_loop/message_loop.h"
#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h"
#include "chrome/browser/extensions/api/storage/settings_frontend.h"
#include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
@@ -17,7 +17,7 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/test_extension_service.h"
#include "chrome/browser/value_store/testing_value_store.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "extensions/common/manifest.h"
#include "sync/api/sync_change_processor.h"
#include "sync/api/sync_error_factory.h"
@@ -27,6 +27,7 @@
using base::DictionaryValue;
using base::ListValue;
using base::Value;
+using content::BrowserThread;
namespace extensions {
@@ -204,7 +205,9 @@ class TestingValueStoreFactory : public SettingsStorageFactory {
class ExtensionSettingsSyncTest : public testing::Test {
public:
ExtensionSettingsSyncTest()
- : storage_factory_(new util::ScopedSettingsStorageFactory()),
+ : ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
+ file_thread_(BrowserThread::FILE, base::MessageLoop::current()),
+ storage_factory_(new util::ScopedSettingsStorageFactory()),
sync_processor_(new MockSyncChangeProcessor),
sync_processor_delegate_(new SyncChangeProcessorDelegate(
sync_processor_.get())) {}
@@ -221,7 +224,7 @@ class ExtensionSettingsSyncTest : public testing::Test {
frontend_.reset();
profile_.reset();
// Execute any pending deletion tasks.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
protected:
@@ -258,7 +261,9 @@ class ExtensionSettingsSyncTest : public testing::Test {
}
// Need these so that the DCHECKs for running on FILE or UI threads pass.
- content::TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop message_loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread file_thread_;
base::ScopedTempDir temp_dir_;
scoped_ptr<util::MockProfile> profile_;
diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc
index c271321..8d53a42 100644
--- a/chrome/browser/extensions/data_deleter.cc
+++ b/chrome/browser/extensions/data_deleter.cc
@@ -29,11 +29,35 @@ void DataDeleter::StartDeleting(Profile* profile,
const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id);
- BrowserContext::GetStoragePartitionForSite(profile, site)->
- ClearDataForOrigin((StoragePartition::REMOVE_DATA_MASK_ALL &
- ~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
- StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- storage_origin);
+ StoragePartition* partition =
+ BrowserContext::GetStoragePartitionForSite(profile, site);
+
+ if (storage_origin.SchemeIs(extensions::kExtensionScheme)) {
+ // TODO(ajwong): Cookies are not properly isolated for
+ // chrome-extension:// scheme. (http://crbug.com/158386).
+ //
+ // However, no isolated apps actually can write to kExtensionScheme
+ // origins. Thus, it is benign to delete from the
+ // RequestContextForExtensions because there's nothing stored there. We
+ // preserve this code path without checking for isolation because it's
+ // simpler than special casing. This code should go away once we merge
+ // the various URLRequestContexts (http://crbug.com/159193).
+ partition->ClearDataForOrigin(
+ StoragePartition::REMOVE_DATA_MASK_ALL &
+ (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
+ StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
+ storage_origin,
+ profile->GetRequestContextForExtensions());
+ } else {
+ // We don't need to worry about the media request context because that
+ // shares the same cookie store as the main request context.
+ partition->ClearDataForOrigin(
+ StoragePartition::REMOVE_DATA_MASK_ALL &
+ (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
+ StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
+ storage_origin,
+ partition->GetURLRequestContext());
+ }
// Begin removal of the settings for the current extension.
profile->GetExtensionService()->settings_frontend()->
diff --git a/chrome/browser/extensions/error_console/error_console_unittest.cc b/chrome/browser/extensions/error_console/error_console_unittest.cc
index 792ff14..62b5320 100644
--- a/chrome/browser/extensions/error_console/error_console_unittest.cc
+++ b/chrome/browser/extensions/error_console/error_console_unittest.cc
@@ -12,7 +12,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/common/url_constants.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/extension_error.h"
#include "extensions/common/constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -56,14 +55,14 @@ scoped_ptr<const ExtensionError> CreateNewRuntimeError(
class ErrorConsoleUnitTest : public testing::Test {
public:
- ErrorConsoleUnitTest()
- : error_console_(ErrorConsole::Get(&profile_)) {
+ ErrorConsoleUnitTest() :
+ profile_(new TestingProfile),
+ error_console_(ErrorConsole::Get(profile_.get())) {
}
virtual ~ErrorConsoleUnitTest() { }
protected:
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
+ scoped_ptr<TestingProfile> profile_;
ErrorConsole* error_console_;
};
diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/extension_process_manager_unittest.cc
index 8077894..bdd8d96 100644
--- a/chrome/browser/extensions/extension_process_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_process_manager_unittest.cc
@@ -7,7 +7,6 @@
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -35,7 +34,6 @@ TEST_F(ExtensionProcessManagerTest, ProcessGrouping) {
// Extensions in different profiles should always be different SiteInstances.
// Note: we don't initialize these, since we're not testing that
// functionality. This means we can get away with a NULL UserScriptMaster.
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile1;
scoped_ptr<ExtensionProcessManager> manager1(
ExtensionProcessManager::Create(&profile1));
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 7939bdb..4ccc3c1 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -22,7 +22,6 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
-#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
@@ -4110,8 +4109,8 @@ TEST_F(ExtensionServiceTest, ClearExtensionData) {
// Set a cookie for the extension.
net::CookieMonster* cookie_monster =
- BrowserContext::GetDefaultStoragePartition(profile_.get())->
- GetCookieStoreForScheme(ext_url.scheme())->GetCookieMonster();
+ profile_->GetRequestContextForExtensions()->GetURLRequestContext()->
+ cookie_store()->GetCookieMonster();
ASSERT_TRUE(cookie_monster);
net::CookieOptions options;
cookie_monster->SetCookieWithOptionsAsync(
@@ -4226,8 +4225,8 @@ TEST_F(ExtensionServiceTest, ClearAppData) {
// Set a cookie for the extension.
net::CookieMonster* cookie_monster =
- BrowserContext::GetDefaultStoragePartition(profile_.get())->
- GetCookieStoreForScheme(origin1.scheme())->GetCookieMonster();
+ profile_->GetRequestContext()->GetURLRequestContext()->
+ cookie_store()->GetCookieMonster();
ASSERT_TRUE(cookie_monster);
net::CookieOptions options;
cookie_monster->SetCookieWithOptionsAsync(
@@ -4923,8 +4922,8 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
ExtensionErrorReporter::Init(false); // no noisy errors
ExtensionsReadyRecorder recorder;
- content::TestBrowserThreadBundle thread_bundle;
scoped_ptr<TestingProfile> profile(new TestingProfile());
+ content::TestBrowserThreadBundle thread_bundle_;
#if defined OS_CHROMEOS
chromeos::ScopedTestDeviceSettingsService device_settings_service;
chromeos::ScopedTestCrosSettings cros_settings;
diff --git a/chrome/browser/extensions/extension_warning_badge_service_unittest.cc b/chrome/browser/extensions/extension_warning_badge_service_unittest.cc
index 16b751d..273c016 100644
--- a/chrome/browser/extensions/extension_warning_badge_service_unittest.cc
+++ b/chrome/browser/extensions/extension_warning_badge_service_unittest.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -67,7 +66,6 @@ const ExtensionWarning::WarningType warning_2 =
// Check that no badge appears if it has been suppressed for a specific
// warning.
TEST(ExtensionWarningBadgeServiceTest, SuppressBadgeForCurrentWarnings) {
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
TestExtensionWarningSet warnings(&profile);
TestExtensionWarningBadgeService badge_service(&profile, &warnings);
diff --git a/chrome/browser/extensions/extension_warning_service_unittest.cc b/chrome/browser/extensions/extension_warning_service_unittest.cc
index a612d6e..7ad5b82 100644
--- a/chrome/browser/extensions/extension_warning_service_unittest.cc
+++ b/chrome/browser/extensions/extension_warning_service_unittest.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -48,7 +47,6 @@ const ExtensionWarning::WarningType warning_2 =
// Check that inserting a warning triggers notifications, whereas inserting
// the same warning again is silent.
TEST(ExtensionWarningServiceTest, SetWarning) {
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
TestExtensionWarningService warning_service(&profile);
MockObserver observer;
@@ -71,7 +69,6 @@ TEST(ExtensionWarningServiceTest, SetWarning) {
// Check that ClearWarnings deletes exactly the specified warnings and
// triggers notifications where appropriate.
TEST(ExtensionWarningServiceTest, ClearWarnings) {
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
TestExtensionWarningService warning_service(&profile);
MockObserver observer;
diff --git a/chrome/browser/extensions/menu_manager_unittest.cc b/chrome/browser/extensions/menu_manager_unittest.cc
index 84bbcec..5fef312 100644
--- a/chrome/browser/extensions/menu_manager_unittest.cc
+++ b/chrome/browser/extensions/menu_manager_unittest.cc
@@ -10,7 +10,6 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
-#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -28,10 +27,11 @@
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/context_menu_params.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using content::BrowserThread;
using testing::_;
using testing::AtLeast;
using testing::DeleteArg;
@@ -47,13 +47,15 @@ namespace context_menus = api::context_menus;
class MenuManagerTest : public testing::Test {
public:
MenuManagerTest()
- : manager_(&profile_),
- prefs_(base::MessageLoopForUI::current()->message_loop_proxy().get()),
+ : ui_thread_(BrowserThread::UI, &message_loop_),
+ file_thread_(BrowserThread::FILE, &message_loop_),
+ manager_(&profile_),
+ prefs_(message_loop_.message_loop_proxy().get()),
next_id_(1) {}
virtual void TearDown() OVERRIDE {
prefs_.pref_service()->CommitPendingWrite();
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
// Returns a test item.
@@ -84,7 +86,9 @@ class MenuManagerTest : public testing::Test {
}
protected:
- content::TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoopForUI message_loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread file_thread_;
TestingProfile profile_;
MenuManager manager_;
diff --git a/chrome/browser/history/shortcuts_backend_unittest.cc b/chrome/browser/history/shortcuts_backend_unittest.cc
index 0a413aa..985c8c4 100644
--- a/chrome/browser/history/shortcuts_backend_unittest.cc
+++ b/chrome/browser/history/shortcuts_backend_unittest.cc
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "base/files/scoped_temp_dir.h"
+#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
-#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
@@ -12,7 +12,7 @@
#include "chrome/browser/history/shortcuts_backend_factory.h"
#include "chrome/browser/history/shortcuts_database.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -27,7 +27,9 @@ class ShortcutsBackendTest : public testing::Test,
public ShortcutsBackend::ShortcutsBackendObserver {
public:
ShortcutsBackendTest()
- : load_notified_(false),
+ : ui_thread_(BrowserThread::UI, &ui_message_loop_),
+ db_thread_(BrowserThread::DB),
+ load_notified_(false),
changed_notified_(false) {}
virtual void SetUp();
@@ -38,16 +40,18 @@ class ShortcutsBackendTest : public testing::Test,
void InitBackend();
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
scoped_refptr<ShortcutsBackend> backend_;
+ base::MessageLoopForUI ui_message_loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread db_thread_;
bool load_notified_;
bool changed_notified_;
- base::RunLoop on_loaded_loop_;
};
void ShortcutsBackendTest::SetUp() {
+ db_thread_.Start();
ShortcutsBackendFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, &ShortcutsBackendFactory::BuildProfileForTesting);
backend_ = ShortcutsBackendFactory::GetForProfile(&profile_);
@@ -57,11 +61,12 @@ void ShortcutsBackendTest::SetUp() {
void ShortcutsBackendTest::TearDown() {
backend_->RemoveObserver(this);
+ db_thread_.Stop();
}
void ShortcutsBackendTest::OnShortcutsLoaded() {
load_notified_ = true;
- on_loaded_loop_.Quit();
+ base::MessageLoop::current()->Quit();
}
void ShortcutsBackendTest::OnShortcutsChanged() {
@@ -74,7 +79,7 @@ void ShortcutsBackendTest::InitBackend() {
ASSERT_TRUE(backend);
ASSERT_FALSE(load_notified_);
ASSERT_FALSE(backend_->initialized());
- on_loaded_loop_.Run();
+ base::MessageLoop::current()->Run();
EXPECT_TRUE(load_notified_);
EXPECT_TRUE(backend_->initialized());
}
diff --git a/chrome/browser/history/shortcuts_database_unittest.cc b/chrome/browser/history/shortcuts_database_unittest.cc
index 72b5c17..dd3a322 100644
--- a/chrome/browser/history/shortcuts_database_unittest.cc
+++ b/chrome/browser/history/shortcuts_database_unittest.cc
@@ -9,7 +9,6 @@
#include "base/time/time.h"
#include "chrome/browser/history/shortcuts_database.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -53,13 +52,11 @@ class ShortcutsDatabaseTest : public testing::Test {
void AddAll();
- scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
scoped_ptr<TestingProfile> profile_;
scoped_refptr<ShortcutsDatabase> db_;
};
void ShortcutsDatabaseTest::SetUp() {
- thread_bundle_.reset(new content::TestBrowserThreadBundle());
profile_.reset(new TestingProfile());
db_ = new ShortcutsDatabase(profile_.get());
ASSERT_TRUE(db_->Init());
diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc
index ea911bd..75758e7 100644
--- a/chrome/browser/history/thumbnail_database_unittest.cc
+++ b/chrome/browser/history/thumbnail_database_unittest.cc
@@ -19,7 +19,6 @@
#include "chrome/common/thumbnail_score.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/tools/profiles/thumbnail-inl.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/codec/jpeg_codec.h"
@@ -79,18 +78,26 @@ class ThumbnailDatabaseTest : public testing::Test {
};
class IconMappingMigrationTest : public HistoryUnitTestBase {
+ public:
+ IconMappingMigrationTest() {
+ }
+ virtual ~IconMappingMigrationTest() {
+ }
+
protected:
virtual void SetUp() {
+ profile_.reset(new TestingProfile);
+
base::FilePath data_path;
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
data_path = data_path.AppendASCII("History");
- history_db_name_ = profile_.GetPath().Append(chrome::kHistoryFilename);
+ history_db_name_ = profile_->GetPath().Append(chrome::kHistoryFilename);
ASSERT_NO_FATAL_FAILURE(
ExecuteSQLScript(data_path.AppendASCII("history.20.sql"),
history_db_name_));
thumbnail_db_name_ =
- profile_.GetPath().Append(chrome::kFaviconsFilename);
+ profile_->GetPath().Append(chrome::kFaviconsFilename);
ASSERT_NO_FATAL_FAILURE(
ExecuteSQLScript(data_path.AppendASCII("thumbnails.3.sql"),
thumbnail_db_name_));
@@ -101,8 +108,7 @@ class IconMappingMigrationTest : public HistoryUnitTestBase {
base::FilePath thumbnail_db_name_;
private:
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
+ scoped_ptr<TestingProfile> profile_;
};
TEST_F(ThumbnailDatabaseTest, AddIconMapping) {
diff --git a/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc b/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc
index d22b3d3..314e8a7 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc
@@ -7,7 +7,6 @@
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/invalidation/invalidation_service_test_template.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "sync/notifier/fake_invalidation_handler.h"
#include "sync/notifier/fake_invalidator.h"
#include "sync/notifier/invalidation_util.h"
@@ -24,7 +23,6 @@ class TiclInvalidationServiceTestDelegate {
}
void CreateInvalidationService() {
- thread_bundle_.reset(new content::TestBrowserThreadBundle());
fake_invalidator_ = new syncer::FakeInvalidator();
profile_.reset(new TestingProfile());
invalidation_service_.reset(
@@ -50,7 +48,6 @@ class TiclInvalidationServiceTestDelegate {
}
syncer::FakeInvalidator* fake_invalidator_; // owned by the service.
- scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
scoped_ptr<TiclInvalidationService> invalidation_service_;
scoped_ptr<TestingProfile> profile_;
};
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index bb5fbd5..d2745b3 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -45,12 +45,12 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "net/base/host_mapping_rules.h"
#include "net/base/net_util.h"
#include "net/base/network_time_notifier.h"
#include "net/base/sdch_manager.h"
#include "net/cert/cert_verifier.h"
+#include "net/cookies/cookie_monster.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver.h"
#include "net/dns/mapped_host_resolver.h"
@@ -534,8 +534,7 @@ void IOThread::InitAsync() {
globals_->proxy_script_fetcher_proxy_service.reset(
net::ProxyService::CreateDirectWithNetLog(net_log_));
// In-memory cookie store.
- globals_->system_cookie_store =
- content::CreateCookieStore(content::CookieStoreConfig());
+ globals_->system_cookie_store = new net::CookieMonster(NULL, NULL);
// In-memory server bound cert store.
globals_->system_server_bound_cert_service.reset(
new net::ServerBoundCertService(
@@ -678,6 +677,12 @@ void IOThread::CleanUp() {
}
void IOThread::InitializeNetworkOptions(const CommandLine& command_line) {
+ if (command_line.HasSwitch(switches::kEnableFileCookies)) {
+ // Enable cookie storage for file:// URLs. Must do this before the first
+ // Profile (and therefore the first CookieMonster) is created.
+ net::CookieMonster::EnableFileScheme();
+ }
+
// Only handle use-spdy command line flags if "spdy.disabled" preference is
// not disabled via policy.
if (!is_spdy_disabled_by_policy_) {
diff --git a/chrome/browser/managed_mode/managed_user_sync_service_unittest.cc b/chrome/browser/managed_mode/managed_user_sync_service_unittest.cc
index 496ceb8..7ed7765 100644
--- a/chrome/browser/managed_mode/managed_user_sync_service_unittest.cc
+++ b/chrome/browser/managed_mode/managed_user_sync_service_unittest.cc
@@ -13,7 +13,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "sync/api/sync_change.h"
#include "sync/api/sync_error_factory_mock.h"
#include "sync/protocol/sync.pb.h"
@@ -87,7 +86,6 @@ class ManagedUserSyncServiceTest : public ::testing::Test {
MockChangeProcessor* change_processor() { return change_processor_; }
private:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
ManagedUserSyncService* service_;
diff --git a/chrome/browser/net/chrome_cookie_notification_details.h b/chrome/browser/net/chrome_cookie_notification_details.h
index b4a7c8f..d54f280 100644
--- a/chrome/browser/net/chrome_cookie_notification_details.h
+++ b/chrome/browser/net/chrome_cookie_notification_details.h
@@ -23,7 +23,7 @@ struct ChromeCookieDetails {
const net::CanonicalCookie* cookie;
bool removed;
- net::CookieMonsterDelegate::ChangeCause cause;
+ net::CookieMonster::Delegate::ChangeCause cause;
};
#endif // CHROME_BROWSER_NET_CHROME_COOKIE_NOTIFICATION_DETAILS_H_
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 460353a..f335040 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -57,6 +57,20 @@ class FactoryForMain : public ChromeURLRequestContextFactory {
content::ProtocolHandlerMap protocol_handlers_;
};
+// Factory that creates the ChromeURLRequestContext for extensions.
+class FactoryForExtensions : public ChromeURLRequestContextFactory {
+ public:
+ explicit FactoryForExtensions(const ProfileIOData* profile_io_data)
+ : profile_io_data_(profile_io_data) {}
+
+ virtual ChromeURLRequestContext* Create() OVERRIDE {
+ return profile_io_data_->GetExtensionsRequestContext();
+ }
+
+ private:
+ const ProfileIOData* const profile_io_data_;
+};
+
// Factory that creates the ChromeURLRequestContext for a given isolated app.
class FactoryForIsolatedApp : public ChromeURLRequestContextFactory {
public:
@@ -199,6 +213,15 @@ ChromeURLRequestContextGetter::CreateOriginalForMedia(
// static
ChromeURLRequestContextGetter*
+ChromeURLRequestContextGetter::CreateOriginalForExtensions(
+ Profile* profile, const ProfileIOData* profile_io_data) {
+ DCHECK(!profile->IsOffTheRecord());
+ return new ChromeURLRequestContextGetter(
+ new FactoryForExtensions(profile_io_data));
+}
+
+// static
+ChromeURLRequestContextGetter*
ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
Profile* profile,
const ProfileIOData* profile_io_data,
@@ -242,6 +265,15 @@ ChromeURLRequestContextGetter::CreateOffTheRecord(
// static
ChromeURLRequestContextGetter*
+ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
+ Profile* profile, const ProfileIOData* profile_io_data) {
+ DCHECK(profile->IsOffTheRecord());
+ return new ChromeURLRequestContextGetter(
+ new FactoryForExtensions(profile_io_data));
+}
+
+// static
+ChromeURLRequestContextGetter*
ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
Profile* profile,
const ProfileIOData* profile_io_data,
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 30215e5..db09992 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -100,6 +100,11 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter {
static ChromeURLRequestContextGetter* CreateOriginalForMedia(
Profile* profile, const ProfileIOData* profile_io_data);
+ // Create an instance for an original profile for extensions. This is expected
+ // to get called on UI thread.
+ static ChromeURLRequestContextGetter* CreateOriginalForExtensions(
+ Profile* profile, const ProfileIOData* profile_io_data);
+
// Create an instance for an original profile for an app with isolated
// storage. This is expected to get called on UI thread.
static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp(
@@ -125,6 +130,11 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter {
const ProfileIOData* profile_io_data,
content::ProtocolHandlerMap* protocol_handlers);
+ // Create an instance for an OTR profile for extensions. This is expected
+ // to get called on UI thread.
+ static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions(
+ Profile* profile, const ProfileIOData* profile_io_data);
+
// Create an instance for an OTR profile for an app with isolated storage.
// This is expected to get called on UI thread.
static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp(
diff --git a/chrome/browser/net/cookie_store_util.cc b/chrome/browser/net/cookie_store_util.cc
deleted file mode 100644
index 7999261..0000000
--- a/chrome/browser/net/cookie_store_util.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2013 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/net/cookie_store_util.h"
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/net/chrome_cookie_notification_details.h"
-#include "chrome/browser/net/evicted_domain_cookie_counter.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_switches.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/common/content_constants.h"
-#include "extensions/common/constants.h"
-
-using content::BrowserThread;
-
-namespace {
-
-class ChromeCookieMonsterDelegate : public net::CookieMonsterDelegate {
- public:
- explicit ChromeCookieMonsterDelegate(Profile* profile)
- : profile_getter_(
- base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(),
- profile)) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(profile);
- }
-
- // net::CookieMonster::Delegate implementation.
- virtual void OnCookieChanged(
- const net::CanonicalCookie& cookie,
- bool removed,
- net::CookieMonster::Delegate::ChangeCause cause) OVERRIDE {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper,
- this, cookie, removed, cause));
- }
-
- private:
- virtual ~ChromeCookieMonsterDelegate() {}
-
- static Profile* GetProfileOnUI(ProfileManager* profile_manager,
- Profile* profile) {
- if (profile_manager->IsValidProfile(profile))
- return profile;
- return NULL;
- }
-
- void OnCookieChangedAsyncHelper(
- const net::CanonicalCookie& cookie,
- bool removed,
- net::CookieMonster::Delegate::ChangeCause cause) {
- Profile* profile = profile_getter_.Run();
- if (profile) {
- ChromeCookieDetails cookie_details(&cookie, removed, cause);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_COOKIE_CHANGED,
- content::Source<Profile>(profile),
- content::Details<ChromeCookieDetails>(&cookie_details));
- }
- }
-
- const base::Callback<Profile*(void)> profile_getter_;
-};
-
-} // namespace
-
-namespace chrome_browser_net {
-
-bool IsCookieRecordMode() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- // Only allow Record Mode if we are in a Debug build or where we are running
- // a cycle, and the user has limited control.
- return command_line.HasSwitch(switches::kRecordMode) &&
- (chrome::kRecordModeEnabled ||
- command_line.HasSwitch(switches::kVisitURLs));
-}
-
-bool ShouldUseInMemoryCookiesAndCache() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- return IsCookieRecordMode() ||
- command_line.HasSwitch(switches::kPlaybackMode);
-}
-
-net::CookieMonsterDelegate* CreateCookieDelegate(Profile* profile) {
- return new EvictedDomainCookieCounter(
- new ChromeCookieMonsterDelegate(profile));
-}
-
-void SetCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- content::CookieStoreConfig::SessionCookieMode session_cookie_mode,
- quota::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate,
- content::BrowserContext::CookieSchemeMap* configs) {
- using content::CookieStoreConfig;
- configs->clear();
-
- bool in_memory = in_memory_partition ||
- chrome_browser_net::ShouldUseInMemoryCookiesAndCache();
-
- if (in_memory) {
- (*configs)[content::BrowserContext::kDefaultCookieScheme] =
- CookieStoreConfig(base::FilePath(),
- CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
- storage_policy,
- cookie_delegate);
- } else {
- (*configs)[content::BrowserContext::kDefaultCookieScheme] =
- CookieStoreConfig(partition_path.Append(content::kCookieFilename),
- session_cookie_mode,
- storage_policy,
- cookie_delegate);
- }
-
- // Handle adding the extensions cookie store.
- if (is_default_partition) {
- if (in_memory) {
- (*configs)[extensions::kExtensionScheme] = CookieStoreConfig();
- } else {
- base::FilePath cookie_path = partition_path.Append(
- chrome::kExtensionsCookieFilename);
- (*configs)[extensions::kExtensionScheme] =
- CookieStoreConfig(cookie_path, session_cookie_mode, NULL, NULL);
- }
- }
-}
-
-} // namespace chrome_browser_net
diff --git a/chrome/browser/net/cookie_store_util.h b/chrome/browser/net/cookie_store_util.h
deleted file mode 100644
index 0e8cd28..0000000
--- a/chrome/browser/net/cookie_store_util.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2013 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_NET_COOKIE_STORE_UTIL_H_
-#define CHROME_BROWSER_NET_COOKIE_STORE_UTIL_H_
-
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/cookie_store_factory.h"
-
-class Profile;
-
-namespace net {
-class CookieMonsterDelegate;
-} // namespace net
-
-namespace chrome_browser_net {
-
-// Returns true if cookie-like storage systems should enter record mode for
-// debugging.
-bool IsCookieRecordMode();
-
-// Returns true if command line flags indicate that cookie-like storage systems
-// should be forced to be in memory only.
-bool ShouldUseInMemoryCookiesAndCache();
-
-// Populates |configs| with a correctly configured set of CookieStores to
-// handle http, https, chrome-extension and (depending on flags) file schemes.
-void SetCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- content::CookieStoreConfig::SessionCookieMode session_cookie_mode,
- quota::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate,
- content::BrowserContext::CookieSchemeMap* configs);
-
-// Factory method for creating a CookieStore delegate that sends
-// chrome::NOTIFICATION_COOKIE_CHANGED for the given profile. This
-// delegate is stateless so only one is necessary per profile.
-net::CookieMonsterDelegate* CreateCookieDelegate(Profile* profile);
-
-} // namespace chrome_browser_net
-
-#endif // CHROME_BROWSER_NET_COOKIE_STORE_UTIL_H_
diff --git a/chrome/browser/password_manager/password_form_manager_unittest.cc b/chrome/browser/password_manager/password_form_manager_unittest.cc
index 067276b..33339e1 100644
--- a/chrome/browser/password_manager/password_form_manager_unittest.cc
+++ b/chrome/browser/password_manager/password_form_manager_unittest.cc
@@ -5,6 +5,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/password_manager/password_form_manager.h"
@@ -16,7 +17,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/common/password_form.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -78,6 +78,8 @@ class TestPasswordFormManager : public PasswordFormManager {
class PasswordFormManagerTest : public testing::Test {
public:
+ PasswordFormManagerTest() {
+ }
virtual void SetUp() {
observed_form_.origin = GURL("http://accounts.google.com/a/LoginAuth");
observed_form_.action = GURL("http://accounts.google.com/a/Login");
@@ -94,6 +96,11 @@ class PasswordFormManagerTest : public testing::Test {
saved_match_.password_value = ASCIIToUTF16("test1");
saved_match_.other_possible_usernames.push_back(
ASCIIToUTF16("test2@gmail.com"));
+ profile_ = new TestingProfile();
+ }
+
+ virtual void TearDown() {
+ delete profile_;
}
PasswordForm* GetPendingCredentials(PasswordFormManager* p) {
@@ -134,7 +141,7 @@ class PasswordFormManagerTest : public testing::Test {
return p->IgnoreResult(*form);
}
- Profile* profile() { return &profile_; }
+ Profile* profile() { return profile_; }
PasswordForm* observed_form() { return &observed_form_; }
PasswordForm* saved_match() { return &saved_match_; }
@@ -146,10 +153,9 @@ class PasswordFormManagerTest : public testing::Test {
}
private:
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
PasswordForm observed_form_;
PasswordForm saved_match_;
+ Profile* profile_;
};
TEST_F(PasswordFormManagerTest, TestNewLogin) {
@@ -331,6 +337,8 @@ TEST_F(PasswordFormManagerTest, TestDynamicAction) {
}
TEST_F(PasswordFormManagerTest, TestAlternateUsername) {
+ // Need a MessageLoop for callbacks.
+ base::MessageLoop message_loop;
PasswordStoreFactory::GetInstance()->SetTestingFactory(
profile(), &TestPasswordStore::Create);
scoped_refptr<TestPasswordStore> password_store =
diff --git a/chrome/browser/predictors/autocomplete_action_predictor_table_unittest.cc b/chrome/browser/predictors/autocomplete_action_predictor_table_unittest.cc
index dc64735..9dd1b01 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor_table_unittest.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor_table_unittest.cc
@@ -4,15 +4,14 @@
#include <vector>
-#include "base/run_loop.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/predictors/autocomplete_action_predictor_table.h"
#include "chrome/browser/predictors/predictor_database.h"
#include "chrome/browser/predictors/predictor_database_factory.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -25,7 +24,10 @@ using predictors::AutocompleteActionPredictorTable;
namespace predictors {
class AutocompleteActionPredictorTableTest : public testing::Test {
- protected:
+ public:
+ AutocompleteActionPredictorTableTest();
+ virtual ~AutocompleteActionPredictorTableTest();
+
virtual void SetUp();
virtual void TearDown();
@@ -38,6 +40,8 @@ class AutocompleteActionPredictorTableTest : public testing::Test {
TestingProfile* profile() { return &profile_; }
+ protected:
+
// Test functions that can be run against this text fixture or
// AutocompleteActionPredictorTableReopenTest that inherits from this.
void TestGetRow();
@@ -48,14 +52,15 @@ class AutocompleteActionPredictorTableTest : public testing::Test {
AutocompleteActionPredictorTable::Rows test_db_;
private:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
scoped_ptr<PredictorDatabase> db_;
+ base::MessageLoop loop_;
+ content::TestBrowserThread db_thread_;
};
class AutocompleteActionPredictorTableReopenTest
: public AutocompleteActionPredictorTableTest {
- protected:
+ public:
virtual void SetUp() {
// By calling SetUp twice, we make sure that the table already exists for
// this fixture.
@@ -65,9 +70,17 @@ class AutocompleteActionPredictorTableReopenTest
}
};
+AutocompleteActionPredictorTableTest::AutocompleteActionPredictorTableTest()
+ : loop_(base::MessageLoop::TYPE_DEFAULT),
+ db_thread_(BrowserThread::DB, &loop_) {
+}
+
+AutocompleteActionPredictorTableTest::~AutocompleteActionPredictorTableTest() {
+}
+
void AutocompleteActionPredictorTableTest::SetUp() {
db_.reset(new PredictorDatabase(&profile_));
- base::RunLoop().RunUntilIdle();
+ loop_.RunUntilIdle();
test_db_.push_back(AutocompleteActionPredictorTable::Row(
"BD85DBA2-8C29-49F9-84AE-48E1E90880DF",
@@ -85,7 +98,7 @@ void AutocompleteActionPredictorTableTest::SetUp() {
void AutocompleteActionPredictorTableTest::TearDown() {
db_.reset(NULL);
- base::RunLoop().RunUntilIdle();
+ loop_.RunUntilIdle();
test_db_.clear();
}
diff --git a/chrome/browser/prefs/pref_model_associator_unittest.cc b/chrome/browser/prefs/pref_model_associator_unittest.cc
index 2a3f11d3c..74c985e 100644
--- a/chrome/browser/prefs/pref_model_associator_unittest.cc
+++ b/chrome/browser/prefs/pref_model_associator_unittest.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
class AbstractPreferenceMergeTest : public testing::Test {
@@ -49,7 +48,6 @@ class AbstractPreferenceMergeTest : public testing::Test {
pref_service_->Set(pref_name.c_str(), *empty_value);
}
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
PrefService* pref_service_;
};
diff --git a/chrome/browser/prerender/prerender_unittest.cc b/chrome/browser/prerender/prerender_unittest.cc
index cbd12f7..5c1a466 100644
--- a/chrome/browser/prerender/prerender_unittest.cc
+++ b/chrome/browser/prerender/prerender_unittest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "base/format_macros.h"
#include "base/memory/scoped_vector.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "chrome/browser/prerender/prerender_contents.h"
@@ -15,9 +16,8 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/size.h"
#include "url/gurl.h"
@@ -277,7 +277,8 @@ class PrerenderTest : public testing::Test {
static const int kDefaultChildId = -1;
static const int kDefaultRenderViewRouteId = -1;
- PrerenderTest() : prerender_manager_(new UnitTestPrerenderManager(
+ PrerenderTest() : ui_thread_(BrowserThread::UI, &message_loop_),
+ prerender_manager_(new UnitTestPrerenderManager(
&profile_, prerender_tracker())),
prerender_link_manager_(
new PrerenderLinkManager(prerender_manager_.get())),
@@ -346,8 +347,9 @@ class PrerenderTest : public testing::Test {
}
// Needed to pass PrerenderManager's DCHECKs.
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
+ base::MessageLoop message_loop_;
+ content::TestBrowserThread ui_thread_;
scoped_ptr<UnitTestPrerenderManager> prerender_manager_;
scoped_ptr<PrerenderLinkManager> prerender_link_manager_;
int last_prerender_id_;
diff --git a/chrome/browser/printing/print_dialog_cloud_unittest.cc b/chrome/browser/printing/print_dialog_cloud_unittest.cc
index 4b4e9a8..c08ffa8 100644
--- a/chrome/browser/printing/print_dialog_cloud_unittest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_unittest.cc
@@ -22,11 +22,10 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -149,20 +148,26 @@ class MockCloudPrintDataSenderHelper : public CloudPrintDataSenderHelper {
};
class CloudPrintURLTest : public testing::Test {
+ public:
+ CloudPrintURLTest() {}
+
protected:
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
+ virtual void SetUp() {
+ profile_.reset(new TestingProfile());
+ }
+
+ scoped_ptr<Profile> profile_;
};
TEST_F(CloudPrintURLTest, CheckDefaultURLs) {
std::string service_url =
- CloudPrintURL(&profile_).
+ CloudPrintURL(profile_.get()).
GetCloudPrintServiceURL().spec();
EXPECT_THAT(service_url, HasSubstr("www.google.com"));
EXPECT_THAT(service_url, HasSubstr("cloudprint"));
std::string dialog_url =
- CloudPrintURL(&profile_).
+ CloudPrintURL(profile_.get()).
GetCloudPrintServiceDialogURL().spec();
EXPECT_THAT(dialog_url, HasSubstr("www.google.com"));
EXPECT_THAT(dialog_url, HasSubstr("/cloudprint/"));
@@ -172,7 +177,7 @@ TEST_F(CloudPrintURLTest, CheckDefaultURLs) {
// Repeat to make sure there isn't a transient glitch.
dialog_url =
- CloudPrintURL(&profile_).
+ CloudPrintURL(profile_.get()).
GetCloudPrintServiceDialogURL().spec();
EXPECT_THAT(dialog_url, HasSubstr("www.google.com"));
EXPECT_THAT(dialog_url, HasSubstr("/cloudprint/"));
@@ -181,7 +186,7 @@ TEST_F(CloudPrintURLTest, CheckDefaultURLs) {
EXPECT_THAT(dialog_url, HasSubstr("/dialog.html"));
std::string manage_url =
- CloudPrintURL(&profile_).
+ CloudPrintURL(profile_.get()).
GetCloudPrintServiceManageURL().spec();
EXPECT_THAT(manage_url, HasSubstr("www.google.com"));
EXPECT_THAT(manage_url, HasSubstr("/cloudprint/"));
@@ -208,6 +213,11 @@ TEST_F(CloudPrintURLTest, CheckDefaultURLs) {
// Testing for CloudPrintDataSender needs a mock WebUI.
class CloudPrintDataSenderTest : public testing::Test {
+ public:
+ CloudPrintDataSenderTest()
+ : file_thread_(BrowserThread::FILE, &message_loop_),
+ io_thread_(BrowserThread::IO, &message_loop_) {}
+
protected:
virtual void SetUp() {
mock_helper_.reset(new MockCloudPrintDataSenderHelper);
@@ -225,7 +235,9 @@ class CloudPrintDataSenderTest : public testing::Test {
scoped_refptr<CloudPrintDataSender> print_data_sender_;
scoped_ptr<MockCloudPrintDataSenderHelper> mock_helper_;
- content::TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop message_loop_;
+ content::TestBrowserThread file_thread_;
+ content::TestBrowserThread io_thread_;
};
TEST_F(CloudPrintDataSenderTest, CanSend) {
@@ -279,6 +291,10 @@ using internal_cloud_print_helpers::MockCloudPrintFlowHandler;
using internal_cloud_print_helpers::CloudPrintWebDialogDelegate;
class CloudPrintWebDialogDelegateTest : public testing::Test {
+ public:
+ CloudPrintWebDialogDelegateTest()
+ : ui_thread_(BrowserThread::UI, &message_loop_) {}
+
protected:
virtual void SetUp() {
string16 mock_title;
@@ -300,7 +316,8 @@ class CloudPrintWebDialogDelegateTest : public testing::Test {
delete mock_flow_handler_.get();
}
- content::TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoopForUI message_loop_;
+ content::TestBrowserThread ui_thread_;
base::WeakPtr<MockCloudPrintFlowHandler> mock_flow_handler_;
scoped_ptr<CloudPrintWebDialogDelegate> delegate_;
};
diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
index 804ba09..34b6110 100644
--- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
@@ -25,7 +25,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "extensions/common/manifest_constants.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/test_url_fetcher_factory.h"
@@ -176,13 +176,17 @@ class ConfigParserTest : public testing::Test {
MOCK_METHOD0(Callback, void(void));
- content::TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread io_thread_;
URLFetcherRequestListener request_listener_;
net::FakeURLFetcherFactory factory_;
};
ConfigParserTest::ConfigParserTest()
- : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
+ : loop_(base::MessageLoop::TYPE_IO),
+ ui_thread_(content::BrowserThread::UI, &loop_),
+ io_thread_(content::BrowserThread::IO, &loop_),
factory_(NULL, base::Bind(&ConfigParserTest::CreateFakeURLFetcher,
base::Unretained(this))) {
}
diff --git a/chrome/browser/profiles/avatar_menu_model_unittest.cc b/chrome/browser/profiles/avatar_menu_model_unittest.cc
index 50d74ca..3a140f8 100644
--- a/chrome/browser/profiles/avatar_menu_model_unittest.cc
+++ b/chrome/browser/profiles/avatar_menu_model_unittest.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
@@ -56,7 +55,6 @@ class AvatarMenuModelTest : public testing::Test {
TestingProfileManager* manager() { return &manager_; }
private:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfileManager manager_;
};
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 84726b1..4aacf82 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -30,7 +30,6 @@
#include "chrome/browser/io_thread.h"
#include "chrome/browser/media/chrome_midi_permission_context.h"
#include "chrome/browser/media/chrome_midi_permission_context_factory.h"
-#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/pref_proxy_config_tracker.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
@@ -48,7 +47,6 @@
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
@@ -252,24 +250,6 @@ DownloadManagerDelegate* OffTheRecordProfileImpl::GetDownloadManagerDelegate() {
GetDownloadManagerDelegate();
}
-void OffTheRecordProfileImpl::OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) {
- // The delegate is stateless so it's silly to create more than one per
- // profile.
- if (!cookie_delegate_) {
- cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this);
- }
-
- // Force everything to be to be in-memory.
- chrome_browser_net::SetCookieStoreConfigs(
- base::FilePath(), true, is_default_partition,
- content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
- GetSpecialStoragePolicy(), cookie_delegate_, configs);
-}
-
net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() {
return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
@@ -322,6 +302,11 @@ void OffTheRecordProfileImpl::RequestMIDISysExPermission(
}
net::URLRequestContextGetter*
+ OffTheRecordProfileImpl::GetRequestContextForExtensions() {
+ return io_data_.GetExtensionsRequestContextGetter().get();
+}
+
+net::URLRequestContextGetter*
OffTheRecordProfileImpl::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index e1e6b87..85fced7 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -46,6 +46,8 @@ class OffTheRecordProfileImpl : public Profile {
GetExtensionSpecialStoragePolicy() OVERRIDE;
virtual PrefService* GetPrefs() OVERRIDE;
virtual PrefService* GetOffTheRecordPrefs() OVERRIDE;
+ virtual net::URLRequestContextGetter*
+ GetRequestContextForExtensions() OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
@@ -87,10 +89,6 @@ class OffTheRecordProfileImpl : public Profile {
virtual bool IsOffTheRecord() const OVERRIDE;
virtual content::DownloadManagerDelegate*
GetDownloadManagerDelegate() OVERRIDE;
- virtual void OverrideCookieStoreConfigs(const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
int renderer_child_id) OVERRIDE;
@@ -142,8 +140,6 @@ class OffTheRecordProfileImpl : public Profile {
content::HostZoomMap::ZoomLevelChangedCallback zoom_callback_;
- scoped_refptr<net::CookieMonsterDelegate> cookie_delegate_;
-
DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
};
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc
index 5ce4499..842204e 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.cc
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc
@@ -85,6 +85,18 @@ OffTheRecordProfileIOData::Handle::CreateMainRequestContextGetter(
}
scoped_refptr<ChromeURLRequestContextGetter>
+OffTheRecordProfileIOData::Handle::GetExtensionsRequestContextGetter() const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ LazyInitialize();
+ if (!extensions_request_context_getter_.get()) {
+ extensions_request_context_getter_ =
+ ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
+ profile_, io_data_);
+ }
+ return extensions_request_context_getter_;
+}
+
+scoped_refptr<ChromeURLRequestContextGetter>
OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter(
const base::FilePath& partition_path,
bool in_memory) const {
@@ -191,6 +203,9 @@ void OffTheRecordProfileIOData::InitializeInternal(
set_server_bound_cert_service(server_bound_cert_service);
main_context->set_server_bound_cert_service(server_bound_cert_service);
+ main_context->set_cookie_store(new net::CookieMonster(
+ NULL, profile_params->cookie_monster_delegate.get()));
+
net::HttpCache::BackendFactory* main_backend =
net::HttpCache::DefaultBackend::InMemory(0);
net::HttpNetworkSession::Params network_session_params;
@@ -215,6 +230,52 @@ void OffTheRecordProfileIOData::InitializeInternal(
network_delegate(),
ftp_factory_.get());
main_context->set_job_factory(main_job_factory_.get());
+
+#if defined(ENABLE_EXTENSIONS)
+ InitializeExtensionsRequestContext(profile_params);
+#endif
+}
+
+void OffTheRecordProfileIOData::
+ InitializeExtensionsRequestContext(ProfileParams* profile_params) const {
+ ChromeURLRequestContext* extensions_context = extensions_request_context();
+
+ IOThread* const io_thread = profile_params->io_thread;
+ IOThread::Globals* const io_thread_globals = io_thread->globals();
+
+ ApplyProfileParamsToContext(extensions_context);
+
+ extensions_context->set_transport_security_state(transport_security_state());
+
+ extensions_context->set_net_log(io_thread->net_log());
+
+ extensions_context->set_throttler_manager(
+ io_thread_globals->throttler_manager.get());
+
+ // All we care about for extensions is the cookie store. For incognito, we
+ // use a non-persistent cookie store.
+ net::CookieMonster* extensions_cookie_store =
+ new net::CookieMonster(NULL, NULL);
+ // Enable cookies for devtools and extension URLs.
+ const char* schemes[] = {chrome::kChromeDevToolsScheme,
+ extensions::kExtensionScheme};
+ extensions_cookie_store->SetCookieableSchemes(schemes, 2);
+ extensions_context->set_cookie_store(extensions_cookie_store);
+
+ scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory(
+ new net::URLRequestJobFactoryImpl());
+ // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate.
+ // Without a network_delegate, this protocol handler will never
+ // handle file: requests, but as a side effect it makes
+ // job_factory::IsHandledProtocol return true, which prevents attempts to
+ // handle the protocol externally. We pass NULL in to
+ // SetUpJobFactoryDefaults() to get this effect.
+ extensions_job_factory_ = SetUpJobFactoryDefaults(
+ extensions_job_factory.Pass(),
+ scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(),
+ NULL,
+ ftp_factory_.get());
+ extensions_context->set_job_factory(extensions_job_factory_.get());
}
ChromeURLRequestContext*
@@ -229,6 +290,11 @@ OffTheRecordProfileIOData::InitializeAppRequestContext(
// Copy most state from the main context.
context->CopyFrom(main_context);
+ // Use a separate in-memory cookie store for the app.
+ // TODO(creis): We should have a cookie delegate for notifying the cookie
+ // extensions API, but we need to update it to understand isolated apps first.
+ context->SetCookieStore(new net::CookieMonster(NULL, NULL));
+
// Use a separate in-memory cache for the app.
net::HttpCache::BackendFactory* app_backend =
net::HttpCache::DefaultBackend::InMemory(0);
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h
index 7d4f046..2a40135 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.h
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.h
@@ -51,6 +51,8 @@ class OffTheRecordProfileIOData : public ProfileIOData {
CreateMainRequestContextGetter(
content::ProtocolHandlerMap* protocol_handlers) const;
scoped_refptr<ChromeURLRequestContextGetter>
+ GetExtensionsRequestContextGetter() const;
+ scoped_refptr<ChromeURLRequestContextGetter>
GetIsolatedAppRequestContextGetter(
const base::FilePath& partition_path,
bool in_memory) const;
@@ -81,6 +83,8 @@ class OffTheRecordProfileIOData : public ProfileIOData {
// the ProfileIOData on the IO thread.
mutable scoped_refptr<ChromeURLRequestContextGetter>
main_request_context_getter_;
+ mutable scoped_refptr<ChromeURLRequestContextGetter>
+ extensions_request_context_getter_;
mutable ChromeURLRequestContextGetterMap
app_request_context_getter_map_;
OffTheRecordProfileIOData* const io_data_;
@@ -104,6 +108,8 @@ class OffTheRecordProfileIOData : public ProfileIOData {
virtual void InitializeInternal(
ProfileParams* profile_params,
content::ProtocolHandlerMap* protocol_handlers) const OVERRIDE;
+ virtual void InitializeExtensionsRequestContext(
+ ProfileParams* profile_params) const OVERRIDE;
virtual ChromeURLRequestContext* InitializeAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
@@ -135,6 +141,7 @@ class OffTheRecordProfileIOData : public ProfileIOData {
mutable scoped_ptr<net::FtpTransactionFactory> ftp_factory_;
mutable scoped_ptr<net::URLRequestJobFactory> main_job_factory_;
+ mutable scoped_ptr<net::URLRequestJobFactory> extensions_job_factory_;
DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileIOData);
};
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 0d3ffcd..3af9eeb 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -230,6 +230,10 @@ class Profile : public content::BrowserContext {
// Returns the main request context.
virtual net::URLRequestContextGetter* GetRequestContext() = 0;
+ // Returns the request context used for extension-related requests. This
+ // is only used for a separate cookie store currently.
+ virtual net::URLRequestContextGetter* GetRequestContextForExtensions() = 0;
+
// Returns the SSLConfigService for this profile.
virtual net::SSLConfigService* GetSSLConfigService() = 0;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index b5f2b11..1ad2bcf 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -48,7 +48,6 @@
#include "chrome/browser/media/chrome_midi_permission_context_factory.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/net/chrome_url_request_context.h"
-#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/net_pref_observer.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/pref_proxy_config_tracker.h"
@@ -87,7 +86,6 @@
#include "components/user_prefs/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/notification_service.h"
@@ -499,6 +497,8 @@ void ProfileImpl::DoFinalInit() {
g_browser_process->background_mode_manager()->RegisterProfile(this);
}
+ base::FilePath cookie_path = GetPath();
+ cookie_path = cookie_path.Append(chrome::kCookieFilename);
base::FilePath server_bound_cert_path = GetPath();
server_bound_cert_path =
server_bound_cert_path.Append(chrome::kOBCertFilename);
@@ -520,14 +520,28 @@ void ProfileImpl::DoFinalInit() {
infinite_cache_path =
infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache"));
+#if defined(OS_ANDROID)
+ SessionStartupPref::Type startup_pref_type =
+ SessionStartupPref::GetDefaultStartupType();
+#else
+ SessionStartupPref::Type startup_pref_type =
+ StartupBrowserCreator::GetSessionStartupPref(
+ *CommandLine::ForCurrentProcess(), this).type;
+#endif
+ bool restore_old_session_cookies =
+ (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
+ startup_pref_type == SessionStartupPref::LAST);
+
InitHostZoomMap();
// Make sure we initialize the ProfileIOData after everything else has been
// initialized that we might be reading from the IO thread.
- io_data_.Init(server_bound_cert_path, cache_path,
+ io_data_.Init(cookie_path, server_bound_cert_path, cache_path,
cache_max_size, media_cache_path, media_cache_max_size,
- GetPath(), infinite_cache_path, predictor_,
+ extensions_cookie_path, GetPath(), infinite_cache_path,
+ predictor_,
+ restore_old_session_cookies,
GetSpecialStoragePolicy());
#if defined(ENABLE_PLUGINS)
@@ -545,7 +559,7 @@ void ProfileImpl::DoFinalInit() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableRestoreSessionState)) {
TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk")
- GetDefaultStoragePartition(this)->
+ content::BrowserContext::GetDefaultStoragePartition(this)->
GetDOMStorageContext()->SetSaveSessionStorageOnDisk();
}
@@ -659,40 +673,8 @@ scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() {
GetPath(), BrowserThread::GetBlockingPool());
}
-void ProfileImpl::OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) {
- using content::CookieStoreConfig;
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // The delegate is stateless so it's silly to create more than one per
- // profile.
- if (!cookie_delegate_) {
- cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this);
- }
-
-#if defined(OS_ANDROID)
- SessionStartupPref::Type startup_pref_type =
- SessionStartupPref::GetDefaultStartupType();
-#else
- SessionStartupPref::Type startup_pref_type =
- StartupBrowserCreator::GetSessionStartupPref(
- *CommandLine::ForCurrentProcess(), this).type;
-#endif
-
- CookieStoreConfig::SessionCookieMode session_cookie_mode =
- CookieStoreConfig::PERSISTANT_SESSION_COOKIES;
- if (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
- startup_pref_type == SessionStartupPref::LAST) {
- session_cookie_mode = CookieStoreConfig::RESTORED_SESSION_COOKIES;
- }
-
- chrome_browser_net::SetCookieStoreConfigs(
- partition_path, in_memory_partition, is_default_partition,
- session_cookie_mode, GetSpecialStoragePolicy(), cookie_delegate_,
- configs);
+bool ProfileImpl::IsOffTheRecord() const {
+ return false;
}
Profile* ProfileImpl::GetOffTheRecordProfile() {
@@ -902,6 +884,10 @@ content::ResourceContext* ProfileImpl::GetResourceContext() {
return io_data_.GetResourceContext();
}
+net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
+ return io_data_.GetExtensionsRequestContextGetter().get();
+}
+
net::URLRequestContextGetter*
ProfileImpl::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 2d228aa..544091e 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -62,10 +62,6 @@ class ProfileImpl : public Profile {
// content::BrowserContext implementation:
virtual base::FilePath GetPath() const OVERRIDE;
- virtual void OverrideCookieStoreConfigs(const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) OVERRIDE;
virtual content::DownloadManagerDelegate*
GetDownloadManagerDelegate() OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
@@ -93,6 +89,7 @@ class ProfileImpl : public Profile {
// Note that this implementation returns the Google-services username, if any,
// not the Chrome user's display name.
virtual std::string GetProfileName() OVERRIDE;
+ virtual bool IsOffTheRecord() const OVERRIDE;
virtual Profile* GetOffTheRecordProfile() OVERRIDE;
virtual void DestroyOffTheRecordProfile() OVERRIDE;
virtual bool HasOffTheRecordProfile() OVERRIDE;
@@ -105,6 +102,8 @@ class ProfileImpl : public Profile {
GetExtensionSpecialStoragePolicy() OVERRIDE;
virtual PrefService* GetPrefs() OVERRIDE;
virtual PrefService* GetOffTheRecordPrefs() OVERRIDE;
+ virtual net::URLRequestContextGetter*
+ GetRequestContextForExtensions() OVERRIDE;
virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE;
virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE;
virtual bool IsSameProfile(Profile* profile) OVERRIDE;
@@ -255,8 +254,6 @@ class ProfileImpl : public Profile {
scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
- scoped_refptr<net::CookieMonsterDelegate> cookie_delegate_;
-
// STOP!!!! DO NOT ADD ANY MORE ITEMS HERE!!!!
//
// Instead, make your Service/Manager/whatever object you're hanging off the
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 7ee0770..4026f4b 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/connect_interceptor.h"
-#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/http_server_properties_manager.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/sqlite_server_bound_cert_store.h"
@@ -97,27 +96,33 @@ ProfileImplIOData::Handle::~Handle() {
}
void ProfileImplIOData::Handle::Init(
+ const base::FilePath& cookie_path,
const base::FilePath& server_bound_cert_path,
const base::FilePath& cache_path,
int cache_max_size,
const base::FilePath& media_cache_path,
int media_cache_max_size,
+ const base::FilePath& extensions_cookie_path,
const base::FilePath& profile_path,
const base::FilePath& infinite_cache_path,
chrome_browser_net::Predictor* predictor,
+ bool restore_old_session_cookies,
quota::SpecialStoragePolicy* special_storage_policy) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!io_data_->lazy_params_);
DCHECK(predictor);
- LazyParams* lazy_params = new LazyParams();
+ LazyParams* lazy_params = new LazyParams;
+ lazy_params->cookie_path = cookie_path;
lazy_params->server_bound_cert_path = server_bound_cert_path;
lazy_params->cache_path = cache_path;
lazy_params->cache_max_size = cache_max_size;
lazy_params->media_cache_path = media_cache_path;
lazy_params->media_cache_max_size = media_cache_max_size;
+ lazy_params->extensions_cookie_path = extensions_cookie_path;
lazy_params->infinite_cache_path = infinite_cache_path;
+ lazy_params->restore_old_session_cookies = restore_old_session_cookies;
lazy_params->special_storage_policy = special_storage_policy;
io_data_->lazy_params_.reset(lazy_params);
@@ -186,6 +191,18 @@ ProfileImplIOData::Handle::GetMediaRequestContextGetter() const {
}
scoped_refptr<ChromeURLRequestContextGetter>
+ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ LazyInitialize();
+ if (!extensions_request_context_getter_.get()) {
+ extensions_request_context_getter_ =
+ ChromeURLRequestContextGetter::CreateOriginalForExtensions(profile_,
+ io_data_);
+ }
+ return extensions_request_context_getter_;
+}
+
+scoped_refptr<ChromeURLRequestContextGetter>
ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter(
const base::FilePath& partition_path,
bool in_memory,
@@ -291,7 +308,8 @@ void ProfileImplIOData::Handle::LazyInitialize() const {
ProfileImplIOData::LazyParams::LazyParams()
: cache_max_size(0),
- media_cache_max_size(0) {}
+ media_cache_max_size(0),
+ restore_old_session_cookies(false) {}
ProfileImplIOData::LazyParams::~LazyParams() {}
@@ -312,6 +330,13 @@ void ProfileImplIOData::InitializeInternal(
IOThread* const io_thread = profile_params->io_thread;
IOThread::Globals* const io_thread_globals = io_thread->globals();
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ // Only allow Record Mode if we are in a Debug build or where we are running
+ // a cycle, and the user has limited control.
+ bool record_mode = command_line.HasSwitch(switches::kRecordMode) &&
+ (chrome::kRecordModeEnabled ||
+ command_line.HasSwitch(switches::kVisitURLs));
+ bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode);
network_delegate()->set_predictor(predictor_.get());
@@ -343,14 +368,32 @@ void ProfileImplIOData::InitializeInternal(
main_context->set_proxy_service(proxy_service());
+ scoped_refptr<net::CookieStore> cookie_store = NULL;
net::ServerBoundCertService* server_bound_cert_service = NULL;
- if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
+ if (record_mode || playback_mode) {
+ // Don't use existing cookies and use an in-memory store.
+ cookie_store = new net::CookieMonster(
+ NULL, profile_params->cookie_monster_delegate.get());
// Don't use existing server-bound certs and use an in-memory store.
server_bound_cert_service = new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true));
}
+ // setup cookie store
+ if (!cookie_store.get()) {
+ DCHECK(!lazy_params_->cookie_path.empty());
+
+ cookie_store = content::CreatePersistentCookieStore(
+ lazy_params_->cookie_path,
+ lazy_params_->restore_old_session_cookies,
+ lazy_params_->special_storage_policy.get(),
+ profile_params->cookie_monster_delegate.get());
+ cookie_store->GetCookieMonster()->SetPersistSessionCookies(true);
+ }
+
+ main_context->set_cookie_store(cookie_store.get());
+
// Setup server bound cert service.
if (!server_bound_cert_service) {
DCHECK(!lazy_params_->server_bound_cert_path.empty());
@@ -385,10 +428,9 @@ void ProfileImplIOData::InitializeInternal(
ChromeDataReductionProxyAndroid::Init(main_cache->GetSession());
#endif
- if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
+ if (record_mode || playback_mode) {
main_cache->set_mode(
- chrome_browser_net::IsCookieRecordMode() ?
- net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
+ record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
}
main_http_factory_.reset(main_cache);
@@ -409,6 +451,10 @@ void ProfileImplIOData::InitializeInternal(
ftp_factory_.get());
main_context->set_job_factory(main_job_factory_.get());
+#if defined(ENABLE_EXTENSIONS)
+ InitializeExtensionsRequestContext(profile_params);
+#endif
+
// Create a media request context based on the main context, but using a
// media cache. It shares the same job factory as the main context.
StoragePartitionDescriptor details(profile_path_, false);
@@ -418,6 +464,48 @@ void ProfileImplIOData::InitializeInternal(
lazy_params_.reset();
}
+void ProfileImplIOData::
+ InitializeExtensionsRequestContext(ProfileParams* profile_params) const {
+ ChromeURLRequestContext* extensions_context = extensions_request_context();
+ IOThread* const io_thread = profile_params->io_thread;
+ IOThread::Globals* const io_thread_globals = io_thread->globals();
+ ApplyProfileParamsToContext(extensions_context);
+
+ extensions_context->set_transport_security_state(transport_security_state());
+
+ extensions_context->set_net_log(io_thread->net_log());
+
+ extensions_context->set_throttler_manager(
+ io_thread_globals->throttler_manager.get());
+
+ net::CookieStore* extensions_cookie_store =
+ content::CreatePersistentCookieStore(
+ lazy_params_->extensions_cookie_path,
+ lazy_params_->restore_old_session_cookies,
+ NULL,
+ NULL);
+ // Enable cookies for devtools and extension URLs.
+ const char* schemes[] = {chrome::kChromeDevToolsScheme,
+ extensions::kExtensionScheme};
+ extensions_cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 2);
+ extensions_context->set_cookie_store(extensions_cookie_store);
+
+ scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory(
+ new net::URLRequestJobFactoryImpl());
+ // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate.
+ // Without a network_delegate, this protocol handler will never
+ // handle file: requests, but as a side effect it makes
+ // job_factory::IsHandledProtocol return true, which prevents attempts to
+ // handle the protocol externally. We pass NULL in to
+ // SetUpJobFactory() to get this effect.
+ extensions_job_factory_ = SetUpJobFactoryDefaults(
+ extensions_job_factory.Pass(),
+ scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(),
+ NULL,
+ ftp_factory_.get());
+ extensions_context->set_job_factory(extensions_job_factory_.get());
+}
+
ChromeURLRequestContext*
ProfileImplIOData::InitializeAppRequestContext(
ChromeURLRequestContext* main_context,
@@ -429,9 +517,19 @@ ProfileImplIOData::InitializeAppRequestContext(
AppRequestContext* context = new AppRequestContext(load_time_stats());
context->CopyFrom(main_context);
+ base::FilePath cookie_path = partition_descriptor.path.Append(
+ chrome::kCookieFilename);
base::FilePath cache_path =
partition_descriptor.path.Append(chrome::kCacheDirname);
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ // Only allow Record Mode if we are in a Debug build or where we are running
+ // a cycle, and the user has limited control.
+ bool record_mode = command_line.HasSwitch(switches::kRecordMode) &&
+ (chrome::kRecordModeEnabled ||
+ command_line.HasSwitch(switches::kVisitURLs));
+ bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode);
+
// Use a separate HTTP disk cache for isolated apps.
net::HttpCache::BackendFactory* app_backend = NULL;
if (partition_descriptor.in_memory) {
@@ -450,12 +548,35 @@ ProfileImplIOData::InitializeAppRequestContext(
net::HttpCache* app_http_cache =
new net::HttpCache(main_network_session, app_backend);
- if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
+ scoped_refptr<net::CookieStore> cookie_store = NULL;
+ if (partition_descriptor.in_memory) {
+ cookie_store = new net::CookieMonster(NULL, NULL);
+ } else if (record_mode || playback_mode) {
+ // Don't use existing cookies and use an in-memory store.
+ // TODO(creis): We should have a cookie delegate for notifying the cookie
+ // extensions API, but we need to update it to understand isolated apps
+ // first.
+ cookie_store = new net::CookieMonster(NULL, NULL);
app_http_cache->set_mode(
- chrome_browser_net::IsCookieRecordMode() ?
- net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
+ record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
+ }
+
+ // Use an app-specific cookie store.
+ if (!cookie_store.get()) {
+ DCHECK(!cookie_path.empty());
+
+ // TODO(creis): We should have a cookie delegate for notifying the cookie
+ // extensions API, but we need to update it to understand isolated apps
+ // first.
+ cookie_store = content::CreatePersistentCookieStore(
+ cookie_path,
+ false,
+ NULL,
+ NULL);
}
+ // Transfer ownership of the cookies and cache to AppRequestContext.
+ context->SetCookieStore(cookie_store.get());
context->SetHttpTransactionFactory(
scoped_ptr<net::HttpTransactionFactory>(app_http_cache));
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index d6a1e92..bce32a9 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -36,14 +36,17 @@ class ProfileImplIOData : public ProfileIOData {
// Init() must be called before ~Handle(). It records most of the
// parameters needed to construct a ChromeURLRequestContextGetter.
- void Init(const base::FilePath& server_bound_cert_path,
+ void Init(const base::FilePath& cookie_path,
+ const base::FilePath& server_bound_cert_path,
const base::FilePath& cache_path,
int cache_max_size,
const base::FilePath& media_cache_path,
int media_cache_max_size,
+ const base::FilePath& extensions_cookie_path,
const base::FilePath& profile_path,
const base::FilePath& infinite_cache_path,
chrome_browser_net::Predictor* predictor,
+ bool restore_old_session_cookies,
quota::SpecialStoragePolicy* special_storage_policy);
// These Create*ContextGetter() functions are only exposed because the
@@ -68,6 +71,8 @@ class ProfileImplIOData : public ProfileIOData {
scoped_refptr<ChromeURLRequestContextGetter>
GetMediaRequestContextGetter() const;
scoped_refptr<ChromeURLRequestContextGetter>
+ GetExtensionsRequestContextGetter() const;
+ scoped_refptr<ChromeURLRequestContextGetter>
GetIsolatedMediaRequestContextGetter(
const base::FilePath& partition_path,
bool in_memory) const;
@@ -124,12 +129,15 @@ class ProfileImplIOData : public ProfileIOData {
~LazyParams();
// All of these parameters are intended to be read on the IO thread.
+ base::FilePath cookie_path;
base::FilePath server_bound_cert_path;
base::FilePath cache_path;
int cache_max_size;
base::FilePath media_cache_path;
int media_cache_max_size;
+ base::FilePath extensions_cookie_path;
base::FilePath infinite_cache_path;
+ bool restore_old_session_cookies;
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy;
};
@@ -142,6 +150,8 @@ class ProfileImplIOData : public ProfileIOData {
virtual void InitializeInternal(
ProfileParams* profile_params,
content::ProtocolHandlerMap* protocol_handlers) const OVERRIDE;
+ virtual void InitializeExtensionsRequestContext(
+ ProfileParams* profile_params) const OVERRIDE;
virtual ChromeURLRequestContext* InitializeAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index e972dbf..0e8e732 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/about_protocol_handler.h"
+#include "chrome/browser/net/chrome_cookie_notification_details.h"
#include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
#include "chrome/browser/net/chrome_http_user_agent_settings.h"
#include "chrome/browser/net/chrome_net_log.h"
@@ -64,6 +65,7 @@
#include "extensions/common/constants.h"
#include "net/cert/cert_verifier.h"
#include "net/cookies/canonical_cookie.h"
+#include "net/cookies/cookie_monster.h"
#include "net/http/http_transaction_factory.h"
#include "net/http/http_util.h"
#include "net/proxy/proxy_config_service_fixed.h"
@@ -99,6 +101,56 @@ using content::ResourceContext;
namespace {
+// ----------------------------------------------------------------------------
+// CookieMonster::Delegate implementation
+// ----------------------------------------------------------------------------
+class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate {
+ public:
+ explicit ChromeCookieMonsterDelegate(
+ const base::Callback<Profile*(void)>& profile_getter)
+ : profile_getter_(profile_getter) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ }
+
+ // net::CookieMonster::Delegate implementation.
+ virtual void OnCookieChanged(
+ const net::CanonicalCookie& cookie,
+ bool removed,
+ net::CookieMonster::Delegate::ChangeCause cause) OVERRIDE {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper,
+ this, cookie, removed, cause));
+ }
+
+ private:
+ virtual ~ChromeCookieMonsterDelegate() {}
+
+ void OnCookieChangedAsyncHelper(
+ const net::CanonicalCookie& cookie,
+ bool removed,
+ net::CookieMonster::Delegate::ChangeCause cause) {
+ Profile* profile = profile_getter_.Run();
+ if (profile) {
+ ChromeCookieDetails cookie_details(&cookie, removed, cause);
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_COOKIE_CHANGED,
+ content::Source<Profile>(profile),
+ content::Details<ChromeCookieDetails>(&cookie_details));
+ }
+ }
+
+ const base::Callback<Profile*(void)> profile_getter_;
+};
+
+Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(profile);
+ if (profile_manager->IsValidProfile(profile))
+ return profile;
+ return NULL;
+}
+
#if defined(DEBUG_DEVTOOLS)
bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
@@ -202,6 +254,12 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
params->cookie_settings = CookieSettings::Factory::GetForProfile(profile);
params->host_content_settings_map = profile->GetHostContentSettingsMap();
params->ssl_config_service = profile->GetSSLConfigService();
+ base::Callback<Profile*(void)> profile_getter =
+ base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(),
+ profile);
+ params->cookie_monster_delegate =
+ new chrome_browser_net::EvictedDomainCookieCounter(
+ new ChromeCookieMonsterDelegate(profile_getter));
params->extension_info_map =
extensions::ExtensionSystem::Get(profile)->info_map();
@@ -323,6 +381,12 @@ ProfileIOData::AppRequestContext::AppRequestContext(
load_time_stats) {
}
+void ProfileIOData::AppRequestContext::SetCookieStore(
+ net::CookieStore* cookie_store) {
+ cookie_store_ = cookie_store;
+ set_cookie_store(cookie_store);
+}
+
void ProfileIOData::AppRequestContext::SetHttpTransactionFactory(
scoped_ptr<net::HttpTransactionFactory> http_factory) {
http_factory_ = http_factory.Pass();
@@ -409,6 +473,8 @@ ProfileIOData::~ProfileIOData() {
// are already done in the URLRequestContext destructor.
if (main_request_context_)
main_request_context_->AssertNoURLRequests();
+ if (extensions_request_context_)
+ extensions_request_context_->AssertNoURLRequests();
current_context = 0;
for (URLRequestContextMap::iterator it = app_request_context_map_.begin();
@@ -513,6 +579,11 @@ ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const {
return context;
}
+ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const {
+ DCHECK(initialized_);
+ return extensions_request_context_.get();
+}
+
ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
@@ -692,6 +763,10 @@ void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const {
main_request_context_.reset(
new ChromeURLRequestContext(ChromeURLRequestContext::CONTEXT_TYPE_MAIN,
load_time_stats_));
+ extensions_request_context_.reset(
+ new ChromeURLRequestContext(
+ ChromeURLRequestContext::CONTEXT_TYPE_EXTENSIONS,
+ load_time_stats_));
ChromeNetworkDelegate* network_delegate =
new ChromeNetworkDelegate(
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h
index d4e9a61..724a728 100644
--- a/chrome/browser/profiles/profile_io_data.h
+++ b/chrome/browser/profiles/profile_io_data.h
@@ -99,6 +99,7 @@ class ProfileIOData {
ChromeURLRequestContext* GetMainRequestContext() const;
ChromeURLRequestContext* GetMediaRequestContext() const;
+ ChromeURLRequestContext* GetExtensionsRequestContext() const;
ChromeURLRequestContext* GetIsolatedAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
@@ -152,6 +153,10 @@ class ProfileIOData {
return &one_click_signin_rejected_email_list_;
}
+ ChromeURLRequestContext* extensions_request_context() const {
+ return extensions_request_context_.get();
+ }
+
BooleanPrefMember* safe_browsing_enabled() const {
return &safe_browsing_enabled_;
}
@@ -220,6 +225,7 @@ class ProfileIOData {
explicit AppRequestContext(
chrome_browser_net::LoadTimeStats* load_time_stats);
+ void SetCookieStore(net::CookieStore* cookie_store);
void SetHttpTransactionFactory(
scoped_ptr<net::HttpTransactionFactory> http_factory);
void SetJobFactory(scoped_ptr<net::URLRequestJobFactory> job_factory);
@@ -227,6 +233,7 @@ class ProfileIOData {
private:
virtual ~AppRequestContext();
+ scoped_refptr<net::CookieStore> cookie_store_;
scoped_ptr<net::HttpTransactionFactory> http_factory_;
scoped_ptr<net::URLRequestJobFactory> job_factory_;
};
@@ -242,6 +249,7 @@ class ProfileIOData {
scoped_refptr<CookieSettings> cookie_settings;
scoped_refptr<HostContentSettingsMap> host_content_settings_map;
scoped_refptr<net::SSLConfigService> ssl_config_service;
+ scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate;
scoped_refptr<ExtensionInfoMap> extension_info_map;
scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
resource_prefetch_predictor_observer_;
@@ -384,6 +392,9 @@ class ProfileIOData {
ProfileParams* profile_params,
content::ProtocolHandlerMap* protocol_handlers) const = 0;
+ // Initializes the RequestContext for extensions.
+ virtual void InitializeExtensionsRequestContext(
+ ProfileParams* profile_params) const = 0;
// Does an on-demand initialization of a RequestContext for the given
// isolated app.
virtual ChromeURLRequestContext* InitializeAppRequestContext(
@@ -499,6 +510,7 @@ class ProfileIOData {
// These are only valid in between LazyInitialize() and their accessor being
// called.
mutable scoped_ptr<ChromeURLRequestContext> main_request_context_;
+ mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_;
// One URLRequestContext per isolated app for main and media requests.
mutable URLRequestContextMap app_request_context_map_;
mutable URLRequestContextMap isolated_media_request_context_map_;
diff --git a/chrome/browser/profiles/profile_loader_unittest.cc b/chrome/browser/profiles/profile_loader_unittest.cc
index bd24e41..6637ab9 100644
--- a/chrome/browser/profiles/profile_loader_unittest.cc
+++ b/chrome/browser/profiles/profile_loader_unittest.cc
@@ -12,18 +12,9 @@
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_loader.h"
-#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/testing_profile_manager.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/message_center/message_center.h"
-
-#if defined(OS_CHROMEOS)
-#include "base/command_line.h"
-#include "chrome/common/chrome_switches.h"
-#endif // defined(OS_CHROMEOS)
namespace {
@@ -78,30 +69,8 @@ class MockCallback : public base::RefCountedThreadSafe<MockCallback> {
MockCallback::MockCallback() {}
MockCallback::~MockCallback() {}
-class ProfileLoaderTest : public testing::Test {
- protected:
- static void SetUpTestCase() {
-#if defined(OS_CHROMEOS)
- // Needed to handle http://crbug.com/119175.
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kDisableZeroBrowsersOpenForTests);
-#endif // defined(OS_CHROMEOS)
- message_center::MessageCenter::Initialize();
- }
-
- static void TearDownTestCase() {
- message_center::MessageCenter::Shutdown();
- }
-
- private:
- content::TestBrowserThreadBundle thread_bundle_;
-};
-
-TEST_F(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
- TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal());
- ASSERT_TRUE(profile_manager.SetUp());
- TestingProfile* profile =
- profile_manager.CreateTestingProfile("TestProfile");
+TEST(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
+ TestingProfile profile;
base::FilePath fake_profile_path_1 =
base::FilePath::FromUTF8Unsafe("fake/profile 1");
base::FilePath fake_profile_path_2 =
@@ -121,7 +90,7 @@ TEST_F(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
// path_2 loads after the first request.
EXPECT_CALL(loader, GetProfileByPath(fake_profile_path_2))
.WillOnce(Return(static_cast<Profile*>(NULL)))
- .WillRepeatedly(Return(profile));
+ .WillRepeatedly(Return(&profile));
EXPECT_CALL(loader,
CreateProfileAsync(fake_profile_path_2, _, _, _, std::string()))
.WillRepeatedly(WithArgs<0, 1>(
@@ -133,7 +102,7 @@ TEST_F(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
// path_2_load is called both times.
StrictMock<MockCallback>* path_1_load = new StrictMock<MockCallback>();
StrictMock<MockCallback>* path_2_load = new StrictMock<MockCallback>();
- EXPECT_CALL(*path_2_load, Run(profile))
+ EXPECT_CALL(*path_2_load, Run(&profile))
.Times(2);
// Try to load path_1.
@@ -146,9 +115,9 @@ TEST_F(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
fake_profile_path_2, base::Bind(&MockCallback::Run, path_2_load));
// Finish the load request for path_1, then for path_2.
- loader.RunCreateCallback(fake_profile_path_1, profile,
+ loader.RunCreateCallback(fake_profile_path_1, &profile,
Profile::CREATE_STATUS_INITIALIZED);
- loader.RunCreateCallback(fake_profile_path_2, profile,
+ loader.RunCreateCallback(fake_profile_path_2, &profile,
Profile::CREATE_STATUS_INITIALIZED);
EXPECT_FALSE(loader.IsAnyProfileLoading());
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 3cfef1b..5ae4201 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -299,16 +299,15 @@ SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() {
void SafeBrowsingService::InitURLRequestContextOnIOThread(
net::URLRequestContextGetter* system_url_request_context_getter) {
- using content::CookieStoreConfig;
-
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!url_request_context_.get());
scoped_refptr<net::CookieStore> cookie_store(
- CreateCookieStore(
- CookieStoreConfig(CookieFilePath(),
- CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
- NULL, NULL)));
+ content::CreatePersistentCookieStore(
+ CookieFilePath(),
+ false,
+ NULL,
+ NULL));
url_request_context_.reset(new net::URLRequestContext);
// |system_url_request_context_getter| may be NULL during tests.
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
index 2053089..d2e4db4 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
@@ -15,7 +15,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
@@ -84,7 +83,6 @@ TEST(TemplateURLPrepopulateDataTest, UniqueIDs) {
'V'<<8|'N', 'V'<<8|'U', 'W'<<8|'F', 'W'<<8|'S', 'Y'<<8|'E',
'Y'<<8|'T', 'Z'<<8|'A', 'Z'<<8|'M', 'Z'<<8|'W', -1 };
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
for (size_t i = 0; i < arraysize(kCountryIds); ++i) {
profile.GetPrefs()->SetInteger(prefs::kCountryIDAtInstall, kCountryIds[i]);
@@ -104,7 +102,6 @@ TEST(TemplateURLPrepopulateDataTest, UniqueIDs) {
// Verifies that default search providers from the preferences file
// override the built-in ones.
TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
prefs->SetUserPref(prefs::kSearchProviderOverridesVersion,
@@ -194,7 +191,6 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
}
TEST(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) {
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
prefs->SetUserPref(prefs::kSearchProviderOverridesVersion,
@@ -248,7 +244,6 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
// Use United States.
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kCountry, "US");
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
ScopedVector<TemplateURL> t_urls;
size_t default_index;
diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc
index 160a03a..f008430 100644
--- a/chrome/browser/signin/signin_manager_unittest.cc
+++ b/chrome/browser/signin/signin_manager_unittest.cc
@@ -23,9 +23,7 @@
#include "chrome/test/base/testing_profile.h"
#include "components/webdata/encryptor/encryptor.h"
#include "content/public/browser/child_process_security_policy.h"
-#include "content/public/browser/storage_partition.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "content/public/test/test_utils.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/cookies/cookie_monster.h"
@@ -202,12 +200,6 @@ class SigninManagerTest : public TokenServiceTestHarness {
manager_->SignOut();
}
- net::CookieMonster* GetCookieMonster(const GURL& origin) {
- // Since it's a unittest, assume default StoragePartition.
- return content::BrowserContext::GetDefaultStoragePartition(profile())->
- GetCookieStoreForScheme(origin.scheme())->GetCookieMonster();
- }
-
net::TestURLFetcherFactory factory_;
scoped_ptr<SigninManager> manager_;
content::TestNotificationTracker google_login_success_;
@@ -297,14 +289,14 @@ TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordValidCookie) {
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
// Set a valid LSID cookie in the test cookie store.
- GURL origin("https://accounts.google.com");
- scoped_refptr<net::CookieMonster> cookie_monster = GetCookieMonster(origin);
+ scoped_refptr<net::CookieMonster> cookie_monster =
+ profile()->GetCookieMonster();
net::CookieOptions options;
options.set_include_httponly();
cookie_monster->SetCookieWithOptionsAsync(
- origin,
- "LSID=1234; secure; httponly", options,
- net::CookieMonster::SetCookiesCallback());
+ GURL("https://accounts.google.com"),
+ "LSID=1234; secure; httponly", options,
+ net::CookieMonster::SetCookiesCallback());
// Since the password is empty, will verify the gaia cookies first.
manager_->StartSignInWithCredentials(
@@ -342,14 +334,14 @@ TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordInValidCookie) {
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
// Set an invalid LSID cookie in the test cookie store.
- GURL origin("https://accounts.google.com");
- scoped_refptr<net::CookieMonster> cookie_monster = GetCookieMonster(origin);
+ scoped_refptr<net::CookieMonster> cookie_monster =
+ profile()->GetCookieMonster();
net::CookieOptions options;
options.set_include_httponly();
cookie_monster->SetCookieWithOptionsAsync(
- origin,
- "LSID=1234; domain=google.com; secure; httponly", options,
- net::CookieMonster::SetCookiesCallback());
+ GURL("https://accounts.google.com"),
+ "LSID=1234; domain=google.com; secure; httponly", options,
+ net::CookieMonster::SetCookiesCallback());
// Since the password is empty, must verify the gaia cookies first.
manager_->StartSignInWithCredentials(
diff --git a/chrome/browser/spellchecker/feedback_sender_unittest.cc b/chrome/browser/spellchecker/feedback_sender_unittest.cc
index fe565ab..5c0b1db 100644
--- a/chrome/browser/spellchecker/feedback_sender_unittest.cc
+++ b/chrome/browser/spellchecker/feedback_sender_unittest.cc
@@ -20,7 +20,7 @@
#include "chrome/common/spellcheck_marker.h"
#include "chrome/common/spellcheck_result.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -61,7 +61,7 @@ int CountOccurences(const std::string& haystack, const std::string& needle) {
// A test fixture to help keep tests simple.
class FeedbackSenderTest : public testing::Test {
public:
- FeedbackSenderTest() {
+ FeedbackSenderTest() : ui_thread_(content::BrowserThread::UI, &loop_) {
// The command-line switch and the field trial are temporary.
// TODO(rouslan): Remove the command-line switch and the field trial.
// http://crbug.com/247726
@@ -125,8 +125,9 @@ class FeedbackSenderTest : public testing::Test {
scoped_ptr<spellcheck::FeedbackSender> feedback_;
private:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
+ base::MessageLoop loop_;
+ content::TestBrowserThread ui_thread_;
scoped_ptr<base::FieldTrialList> field_trial_list_;
scoped_refptr<base::FieldTrial> field_trial_;
net::TestURLFetcherFactory fetchers_;
diff --git a/chrome/browser/sync/sync_global_error_unittest.cc b/chrome/browser/sync/sync_global_error_unittest.cc
index 0051d65..ee798ea 100644
--- a/chrome/browser/sync/sync_global_error_unittest.cc
+++ b/chrome/browser/sync/sync_global_error_unittest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock-actions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/thumbnails/thumbnail_service_unittest.cc b/chrome/browser/thumbnails/thumbnail_service_unittest.cc
index b7ef5cd..1b128e3 100644
--- a/chrome/browser/thumbnails/thumbnail_service_unittest.cc
+++ b/chrome/browser/thumbnails/thumbnail_service_unittest.cc
@@ -7,13 +7,9 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/history/top_sites_impl.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
-class ThumbnailServiceTest : public testing::Test {
- private:
- content::TestBrowserThreadBundle thread_bundle_;
-};
+typedef testing::Test ThumbnailServiceTest;
// A mock version of TopSitesImpl, used for testing
// ShouldAcquirePageThumbnail().
diff --git a/chrome/browser/ui/autofill/account_chooser_model_unittest.cc b/chrome/browser/ui/autofill/account_chooser_model_unittest.cc
index a843407..f27c1be 100644
--- a/chrome/browser/ui/autofill/account_chooser_model_unittest.cc
+++ b/chrome/browser/ui/autofill/account_chooser_model_unittest.cc
@@ -8,7 +8,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/core/browser/autofill_metrics.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -53,7 +52,6 @@ class AccountChooserModelTest : public testing::Test {
const AutofillMetrics& metric_logger() { return metric_logger_; }
private:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
MockAccountChooserModelDelegate delegate_;
TestAccountChooserModel model_;
diff --git a/chrome/browser/ui/bookmarks/bookmark_ui_utils_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_ui_utils_unittest.cc
index 8d5d287..dbe485a 100644
--- a/chrome/browser/ui/bookmarks/bookmark_ui_utils_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_ui_utils_unittest.cc
@@ -7,7 +7,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#if !defined(OS_ANDROID) && !defined(OS_IOS)
@@ -56,7 +55,6 @@ TEST(BookmarkUIUtilsTest, HasBookmarkURLs) {
TEST(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) {
BookmarkModel model(NULL);
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
std::vector<const BookmarkNode*> nodes;
diff --git a/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc b/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc
index d3eb8ed..8bc1ea4 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc
+++ b/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "grit/theme_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/skia_utils_gtk.h"
@@ -28,7 +27,6 @@ class GtkThemeServiceTest : public testing::Test {
}
protected:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
GtkThemeService* provider_;
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk_unittest.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk_unittest.cc
index a1c98f2..c7f7859 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk_unittest.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk_unittest.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
#include "ui/base/gtk/gtk_hig_constants.h"
@@ -42,9 +42,11 @@ class OmniboxEditControllerMock : public OmniboxEditController {
class OmniboxViewGtkTest : public PlatformTest {
public:
+ OmniboxViewGtkTest() : file_thread_(content::BrowserThread::UI) {}
+
virtual void SetUp() {
PlatformTest::SetUp();
- profile_.reset(new TestingProfile());
+ profile_.reset(new TestingProfile);
window_ = gtk_window_new(GTK_WINDOW_POPUP);
controller_.reset(new OmniboxEditControllerMock);
view_.reset(new OmniboxViewGtk(controller_.get(), NULL, profile_.get(),
@@ -62,12 +64,15 @@ class OmniboxViewGtkTest : public PlatformTest {
view_->paste_clipboard_requested_ = b;
}
- content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<OmniboxEditControllerMock> controller_;
scoped_ptr<TestingProfile> profile_;
GtkTextBuffer* text_buffer_;
scoped_ptr<OmniboxViewGtk> view_;
GtkWidget* window_;
+ content::TestBrowserThread file_thread_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OmniboxViewGtkTest);
};
TEST_F(OmniboxViewGtkTest, InsertText) {
diff --git a/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc b/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc
index 65b0a33..4c855c3 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/ui/omnibox/omnibox_controller.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
class OmniboxControllerTest : public testing::Test {
@@ -26,7 +25,6 @@ class OmniboxControllerTest : public testing::Test {
}
private:
- content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
scoped_ptr<OmniboxController> omnibox_controller_;
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc b/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc
index 83ac9bb..4dd7d09 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/ui/toolbar/test_toolbar_model.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image.h"
@@ -182,7 +181,6 @@ TEST_F(AutocompleteEditTest, AdjustTextForCopy) {
};
TestingOmniboxEditController controller(toolbar_model());
TestingOmniboxView view(&controller);
- content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
// NOTE: The TemplateURLService must be created before the
// AutocompleteClassifier so that the SearchProvider gets a non-NULL
diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
index 3cebb63..a0b1d03 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
@@ -97,6 +97,10 @@ class TestProfileIOData : public ProfileIOData {
content::ProtocolHandlerMap* protocol_handlers) const OVERRIDE {
NOTREACHED();
}
+ virtual void InitializeExtensionsRequestContext(
+ ProfileParams* profile_params) const OVERRIDE {
+ NOTREACHED();
+ }
virtual ChromeURLRequestContext* InitializeAppRequestContext(
ChromeURLRequestContext* main_context,
const StoragePartitionDescriptor& details,
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
index 37fb546..57820cb 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -29,6 +28,9 @@ class OneClickSigninSyncStarterTest : public testing::Test {
// testing::Test:
virtual void SetUp() OVERRIDE {
+ testing::Test::SetUp();
+ profile_.reset(new TestingProfile());
+
// Disable sync to simplify the creation of a OneClickSigninSyncStarter.
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
@@ -36,9 +38,9 @@ class OneClickSigninSyncStarterTest : public testing::Test {
SigninManagerBase* signin_manager =
static_cast<FakeSigninManager*>(
SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- &profile_,
+ profile_.get(),
&OneClickSigninSyncStarterTest::BuildSigninManager));
- signin_manager->Initialize(&profile_, NULL);
+ signin_manager->Initialize(profile_.get(), NULL);
signin_manager->SetAuthenticatedUsername(kTestingUsername);
}
@@ -52,7 +54,7 @@ class OneClickSigninSyncStarterTest : public testing::Test {
protected:
void CreateSyncStarter(OneClickSigninSyncStarter::Callback callback) {
sync_starter_ = new OneClickSigninSyncStarter(
- &profile_,
+ profile_.get(),
NULL,
std::string(),
kTestingUsername,
@@ -65,8 +67,7 @@ class OneClickSigninSyncStarterTest : public testing::Test {
);
}
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
+ scoped_ptr<TestingProfile> profile_;
// Deletes itself when SigninFailed() or SigninSuccess() is called.
OneClickSigninSyncStarter* sync_starter_;
diff --git a/chrome/browser/ui/sync/sync_promo_ui_unittest.cc b/chrome/browser/ui/sync/sync_promo_ui_unittest.cc
index 20aa029..1a9d8d6 100644
--- a/chrome/browser/ui/sync/sync_promo_ui_unittest.cc
+++ b/chrome/browser/ui/sync/sync_promo_ui_unittest.cc
@@ -12,18 +12,26 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
class SyncPromoUITest : public testing::Test {
+ public:
+ SyncPromoUITest() {}
+
+ // testing::Test:
+ virtual void SetUp() OVERRIDE {
+ testing::Test::SetUp();
+ profile_.reset(new TestingProfile());
+ }
+
protected:
void CreateSigninManager(const std::string& username) {
SigninManagerBase* signin_manager =
static_cast<FakeSigninManagerBase*>(
SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- &profile_,
+ profile_.get(),
&FakeSigninManagerBase::Build));
- signin_manager->Initialize(&profile_, NULL);
+ signin_manager->Initialize(profile_.get(), NULL);
if (!username.empty()) {
ASSERT_TRUE(signin_manager);
@@ -35,8 +43,10 @@ class SyncPromoUITest : public testing::Test {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
}
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
+ scoped_ptr<TestingProfile> profile_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyncPromoUITest);
};
// Verifies that ShouldShowSyncPromo returns false if sync is disabled by
@@ -44,7 +54,7 @@ class SyncPromoUITest : public testing::Test {
TEST_F(SyncPromoUITest, ShouldShowSyncPromoSyncDisabled) {
CreateSigninManager("");
DisableSync();
- EXPECT_FALSE(SyncPromoUI::ShouldShowSyncPromo(&profile_));
+ EXPECT_FALSE(SyncPromoUI::ShouldShowSyncPromo(profile_.get()));
}
// Verifies that ShouldShowSyncPromo returns true if all conditions to
@@ -53,8 +63,8 @@ TEST_F(SyncPromoUITest, ShouldShowSyncPromoSyncEnabled) {
CreateSigninManager("");
#if defined(OS_CHROMEOS)
// No sync promo on CrOS.
- EXPECT_FALSE(SyncPromoUI::ShouldShowSyncPromo(&profile_));
+ EXPECT_FALSE(SyncPromoUI::ShouldShowSyncPromo(profile_.get()));
#else
- EXPECT_TRUE(SyncPromoUI::ShouldShowSyncPromo(&profile_));
+ EXPECT_TRUE(SyncPromoUI::ShouldShowSyncPromo(profile_.get()));
#endif
}
diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index 4c7dd2d..62715e8 100644
--- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -682,6 +682,7 @@ void NetInternalsMessageHandler::RegisterMessages() {
proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(),
profile->GetRequestContext());
proxy_->AddRequestContextGetter(profile->GetMediaRequestContext());
+ proxy_->AddRequestContextGetter(profile->GetRequestContextForExtensions());
#if defined(OS_CHROMEOS)
syslogs_getter_.reset(new SystemLogsGetter(this,
chromeos::system::SyslogsProvider::GetInstance()));
diff --git a/chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc b/chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc
index 69a79cb..9b749a8 100644
--- a/chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc
+++ b/chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h"
#include "chrome/browser/ui/webui/ntp/suggestions_source.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -208,23 +207,34 @@ class SuggestionsSourceStub : public SuggestionsSource {
};
class SuggestionsCombinerTest : public testing::Test {
+ public:
+ SuggestionsCombinerTest() {
+ }
+
protected:
+ Profile* profile_;
+ SuggestionsHandler* suggestions_handler_;
+ SuggestionsCombiner* combiner_;
+
+ void Reset() {
+ delete combiner_;
+ combiner_ = new SuggestionsCombiner(suggestions_handler_, profile_);
+ }
+
+ private:
virtual void SetUp() {
- thread_bundle_.reset(new content::TestBrowserThreadBundle());
- profile_.reset(new TestingProfile());
- suggestions_handler_.reset(new SuggestionsHandler());
- Reset();
+ profile_ = new TestingProfile();
+ suggestions_handler_ = new SuggestionsHandler();
+ combiner_ = new SuggestionsCombiner(suggestions_handler_, profile_);
}
- void Reset() {
- combiner_.reset(
- new SuggestionsCombiner(suggestions_handler_.get(), profile_.get()));
+ virtual void TearDown() {
+ delete combiner_;
+ delete suggestions_handler_;
+ delete profile_;
}
- scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
- scoped_ptr<Profile> profile_;
- scoped_ptr<SuggestionsHandler> suggestions_handler_;
- scoped_ptr<SuggestionsCombiner> combiner_;
+ DISALLOW_COPY_AND_ASSIGN(SuggestionsCombinerTest);
};
TEST_F(SuggestionsCombinerTest, NoSource) {
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 1a68e39..c3f2552 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1148,8 +1148,6 @@
'browser/net/connect_interceptor.h',
'browser/net/connection_tester.cc',
'browser/net/connection_tester.h',
- 'browser/net/cookie_store_util.cc',
- 'browser/net/cookie_store_util.h',
'browser/net/crl_set_fetcher.cc',
'browser/net/crl_set_fetcher.h',
'browser/net/dns_probe_runner.cc',
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index bec4e02..3dd5bd3 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -153,6 +153,7 @@ const base::FilePath::CharType kArchivedHistoryFilename[] =
FPL("Archived History");
const base::FilePath::CharType kBookmarksFileName[] = FPL("Bookmarks");
const base::FilePath::CharType kCacheDirname[] = FPL("Cache");
+const base::FilePath::CharType kCookieFilename[] = FPL("Cookies");
const base::FilePath::CharType kCRLSetFilename[] =
FPL("Certificate Revocation Lists");
const base::FilePath::CharType kCustomDictionaryFileName[] =
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index 051e917..1691e56 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -54,6 +54,7 @@ extern const base::FilePath::CharType kAndroidCacheFilename[];
extern const base::FilePath::CharType kArchivedHistoryFilename[];
extern const base::FilePath::CharType kBookmarksFileName[];
extern const base::FilePath::CharType kCacheDirname[];
+extern const base::FilePath::CharType kCookieFilename[];
extern const base::FilePath::CharType kCRLSetFilename[];
extern const base::FilePath::CharType kCustomDictionaryFileName[];
extern const base::FilePath::CharType kExtensionActivityLogFilename[];
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 96efa80..c604b6c 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -583,6 +583,10 @@ const char kExtensionsInActionBox[] = "extensions-in-action-box";
// crbug.com/142458 .
const char kEnableFastUnload[] = "enable-fast-unload";
+// By default, cookies are not allowed on file://. They are needed for testing,
+// for example page cycler and layout tests. See bug 1157243.
+const char kEnableFileCookies[] = "enable-file-cookies";
+
// Enables Google Now integration.
const char kEnableGoogleNowIntegration[] = "enable-google-now-integration";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 0850299..7bd5c7b 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -171,6 +171,7 @@ extern const char kEnableDnsProbes[];
extern const char kEnableExtensionActivityLogging[];
extern const char kEnableExtensionActivityLogTesting[];
extern const char kEnableFastUnload[];
+extern const char kEnableFileCookies[];
extern const char kEnableGoogleNowIntegration[];
extern const char kEnableHttp2Draft04[];
extern const char kEnableInstantExtendedAPI[];
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 587f430..f53c423 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -37,7 +37,6 @@
#include "chrome/browser/history/shortcuts_backend_factory.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/history/web_history_service_factory.h"
-#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/pref_proxy_config_tracker.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
@@ -63,7 +62,6 @@
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
@@ -113,6 +111,38 @@ class QuittingHistoryDBTask : public history::HistoryDBTask {
DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask);
};
+class TestExtensionURLRequestContext : public net::URLRequestContext {
+ public:
+ TestExtensionURLRequestContext() {
+ net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
+ const char* schemes[] = {extensions::kExtensionScheme};
+ cookie_monster->SetCookieableSchemes(schemes, 1);
+ set_cookie_store(cookie_monster);
+ }
+
+ virtual ~TestExtensionURLRequestContext() {}
+};
+
+class TestExtensionURLRequestContextGetter
+ : public net::URLRequestContextGetter {
+ public:
+ virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
+ if (!context_.get())
+ context_.reset(new TestExtensionURLRequestContext());
+ return context_.get();
+ }
+ virtual scoped_refptr<base::SingleThreadTaskRunner>
+ GetNetworkTaskRunner() const OVERRIDE {
+ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
+ }
+
+ protected:
+ virtual ~TestExtensionURLRequestContextGetter() {}
+
+ private:
+ scoped_ptr<net::URLRequestContext> context_;
+};
+
BrowserContextKeyedService* CreateTestDesktopNotificationService(
content::BrowserContext* profile) {
#if defined(ENABLE_NOTIFICATIONS)
@@ -562,6 +592,13 @@ TestingProfile::GetExtensionSpecialStoragePolicy() {
return extension_special_storage_policy_.get();
}
+net::CookieMonster* TestingProfile::GetCookieMonster() {
+ if (!GetRequestContext())
+ return NULL;
+ return GetRequestContext()->GetURLRequestContext()->cookie_store()->
+ GetCookieMonster();
+}
+
void TestingProfile::CreateTestingPrefService() {
DCHECK(!prefs_.get());
testing_prefs_ = new TestingPrefServiceSyncable();
@@ -606,18 +643,6 @@ DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
return NULL;
}
-void TestingProfile::OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) {
- // Force this to be in-memory.
- chrome_browser_net::SetCookieStoreConfigs(
- base::FilePath(), true, is_default_partition,
- content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
- GetSpecialStoragePolicy(), NULL, configs);
-}
-
net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
@@ -661,6 +686,12 @@ void TestingProfile::RequestMIDISysExPermission(
callback.Run(false);
}
+net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
+ if (!extensions_request_context_.get())
+ extensions_request_context_ = new TestExtensionURLRequestContextGetter();
+ return extensions_request_context_.get();
+}
+
net::SSLConfigService* TestingProfile::GetSSLConfigService() {
if (!GetRequestContext())
return NULL;
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 0d162fb..03c95d4 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -192,10 +192,6 @@ class TestingProfile : public Profile {
virtual bool IsOffTheRecord() const OVERRIDE;
virtual content::DownloadManagerDelegate*
GetDownloadManagerDelegate() OVERRIDE;
- virtual void OverrideCookieStoreConfigs(const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
@@ -239,6 +235,10 @@ class TestingProfile : public Profile {
ExtensionSpecialStoragePolicy* extension_special_storage_policy);
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() OVERRIDE;
+ // TODO(ajwong): Remove this API in favor of directly retrieving the
+ // CookieStore from the StoragePartition after ExtensionURLRequestContext
+ // has been removed.
+ net::CookieMonster* GetCookieMonster();
virtual PrefService* GetPrefs() OVERRIDE;
@@ -249,6 +249,8 @@ class TestingProfile : public Profile {
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
int renderer_child_id) OVERRIDE;
virtual net::URLRequestContextGetter*
+ GetRequestContextForExtensions() OVERRIDE;
+ virtual net::URLRequestContextGetter*
GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) OVERRIDE;
diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
index 391fcba..e9662a5 100644
--- a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
+++ b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
@@ -11,7 +11,6 @@
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/browser/wallet/wallet_service_url.h"
#include "components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h"
-#include "content/public/browser/storage_partition.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
@@ -202,6 +201,7 @@ TEST_F(WalletSigninHelperTest, PassiveUserInfoFailedUserInfo) {
TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) {
EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken"));
+ net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
net::CookieOptions httponly_options;
httponly_options.set_include_httponly();
scoped_ptr<net::CanonicalCookie> cookie(
@@ -212,12 +212,9 @@ TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) {
net::CookieList cookie_list;
cookie_list.push_back(*cookie);
-
- net::CookieMonster* cookie_monster =
- content::BrowserContext::GetDefaultStoragePartition(&browser_context_)->
- GetCookieStoreForScheme(GetPassiveAuthUrl().scheme())->
- GetCookieMonster();
cookie_monster->InitializeFrom(cookie_list);
+ browser_context_.GetRequestContext()->GetURLRequestContext()
+ ->set_cookie_store(cookie_monster);
signin_helper_->StartWalletCookieValueFetch();
base::RunLoop().RunUntilIdle();
}
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index 6ebb163..a4e895c 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -6,12 +6,11 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
-#include "base/run_loop.h"
+#include "base/message_loop/message_loop.h"
#include "content/browser/appcache/chrome_appcache_service.h"
-#include "content/public/browser/browser_thread.h"
+#include "content/browser/browser_thread_impl.h"
#include "content/public/browser/resource_context.h"
#include "content/public/test/test_browser_context.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "net/url_request/url_request_context_getter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/appcache/appcache_database.h"
@@ -34,29 +33,63 @@ const char kProtectedManifest[] = "http://www.protected.com/cache.manifest";
const char kNormalManifest[] = "http://www.normal.com/cache.manifest";
const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest";
+class MockURLRequestContextGetter : public net::URLRequestContextGetter {
+ public:
+ MockURLRequestContextGetter(
+ net::URLRequestContext* context,
+ base::MessageLoopProxy* message_loop_proxy)
+ : context_(context), message_loop_proxy_(message_loop_proxy) {
+ }
+
+ virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
+ return context_;
+ }
+
+ virtual scoped_refptr<base::SingleThreadTaskRunner>
+ GetNetworkTaskRunner() const OVERRIDE {
+ return message_loop_proxy_;
+ }
+
+ protected:
+ virtual ~MockURLRequestContextGetter() {}
+
+ private:
+ net::URLRequestContext* context_;
+ scoped_refptr<base::SingleThreadTaskRunner> message_loop_proxy_;
+};
+
} // namespace
class ChromeAppCacheServiceTest : public testing::Test {
- protected:
+ public:
ChromeAppCacheServiceTest()
- : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
+ : message_loop_(base::MessageLoop::TYPE_IO),
kProtectedManifestURL(kProtectedManifest),
kNormalManifestURL(kNormalManifest),
- kSessionOnlyManifestURL(kSessionOnlyManifest) {
- }
+ kSessionOnlyManifestURL(kSessionOnlyManifest),
+ file_thread_(BrowserThread::FILE, &message_loop_),
+ file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
+ &message_loop_),
+ cache_thread_(BrowserThread::CACHE, &message_loop_),
+ io_thread_(BrowserThread::IO, &message_loop_) {}
+ protected:
scoped_refptr<ChromeAppCacheService> CreateAppCacheService(
const base::FilePath& appcache_path,
bool init_storage);
void InsertDataIntoAppCache(ChromeAppCacheService* appcache_service);
- TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop message_loop_;
base::ScopedTempDir temp_dir_;
const GURL kProtectedManifestURL;
const GURL kNormalManifestURL;
const GURL kSessionOnlyManifestURL;
private:
+ BrowserThreadImpl file_thread_;
+ BrowserThreadImpl file_user_blocking_thread_;
+ BrowserThreadImpl cache_thread_;
+ BrowserThreadImpl io_thread_;
TestBrowserContext browser_context_;
};
@@ -70,6 +103,10 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
new quota::MockSpecialStoragePolicy;
mock_policy->AddProtected(kProtectedManifestURL.GetOrigin());
mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin());
+ scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter =
+ new MockURLRequestContextGetter(
+ browser_context_.GetResourceContext()->GetRequestContext(),
+ message_loop_.message_loop_proxy().get());
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
@@ -77,17 +114,17 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
appcache_service.get(),
appcache_path,
browser_context_.GetResourceContext(),
- make_scoped_refptr(browser_context_.GetRequestContext()),
+ mock_request_context_getter,
mock_policy));
// Steps needed to initialize the storage of AppCache data.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
if (init_storage) {
appcache::AppCacheStorageImpl* storage =
static_cast<appcache::AppCacheStorageImpl*>(
appcache_service->storage());
storage->database_->db_connection();
storage->disk_cache();
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
return appcache_service;
}
@@ -123,7 +160,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
// Test: delete the ChromeAppCacheService
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
// Recreate the appcache (for reading the data back)
appcache_service = CreateAppCacheService(appcache_path, false);
@@ -143,7 +180,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
// Delete and let cleanup tasks run prior to returning.
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
@@ -163,7 +200,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
// Test: delete the ChromeAppCacheService
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
// Recreate the appcache (for reading the data back)
appcache_service = CreateAppCacheService(appcache_path, false);
@@ -183,7 +220,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
// Delete and let cleanup tasks run prior to returning.
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
} // namespace content
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index d6cfe9f..2e76dc0 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -93,9 +93,6 @@ void PurgeMemoryOnIOThread(appcache::AppCacheService* appcache_service) {
} // namespace
-// Choose something that isn't a legal URI scheme for the kDefaultCookieScheme.
-const char BrowserContext::kDefaultCookieScheme[] = "1 default scheme";
-
// static
void BrowserContext::AsyncObliterateStoragePartition(
BrowserContext* browser_context,
@@ -276,8 +273,4 @@ BrowserContext::~BrowserContext() {
#endif
}
-bool BrowserContext::IsOffTheRecord() const {
- return false;
-}
-
} // namespace content
diff --git a/content/browser/fileapi/fileapi_message_filter_unittest.cc b/content/browser/fileapi/fileapi_message_filter_unittest.cc
index 4858cff..06b112b 100644
--- a/content/browser/fileapi/fileapi_message_filter_unittest.cc
+++ b/content/browser/fileapi/fileapi_message_filter_unittest.cc
@@ -9,8 +9,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/shared_memory.h"
+#include "base/message_loop/message_loop.h"
#include "base/process/process.h"
-#include "base/run_loop.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/streams/stream_registry.h"
@@ -20,7 +20,7 @@
#include "content/public/common/common_param_traits.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "net/base/io_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/blob/blob_storage_controller.h"
@@ -42,6 +42,11 @@ const char kFakeContentType[] = "fake/type";
} // namespace
class FileAPIMessageFilterTest : public testing::Test {
+ public:
+ FileAPIMessageFilterTest()
+ : io_browser_thread_(BrowserThread::IO, &message_loop_) {
+ }
+
protected:
virtual void SetUp() OVERRIDE {
file_system_context_ =
@@ -67,7 +72,7 @@ class FileAPIMessageFilterTest : public testing::Test {
stream_context_);
// Complete initialization.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
// Tests via OnMessageReceived(const IPC::Message&). The channel proxy calls
@@ -79,7 +84,8 @@ class FileAPIMessageFilterTest : public testing::Test {
return casted_filter->OnMessageReceived(message);
}
- TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop message_loop_;
+ TestBrowserThread io_browser_thread_;
TestBrowserContext browser_context_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
@@ -128,7 +134,7 @@ TEST_F(FileAPIMessageFilterTest, CloseChannelWithInflightRequest) {
filter->OnChannelConnected(0);
// Complete initialization.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
IPC::ChannelProxy::MessageFilter* casted_filter =
static_cast<IPC::ChannelProxy::MessageFilter*>(filter.get());
@@ -142,7 +148,7 @@ TEST_F(FileAPIMessageFilterTest, CloseChannelWithInflightRequest) {
filter->OnChannelClosing();
// This shouldn't cause DCHECK failure.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
TEST_F(FileAPIMessageFilterTest, MultipleFilters) {
@@ -164,7 +170,7 @@ TEST_F(FileAPIMessageFilterTest, MultipleFilters) {
filter2->OnChannelConnected(1);
// Complete initialization.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
IPC::ChannelProxy::MessageFilter* casted_filter =
static_cast<IPC::ChannelProxy::MessageFilter*>(filter1.get());
@@ -178,7 +184,7 @@ TEST_F(FileAPIMessageFilterTest, MultipleFilters) {
filter2->OnChannelClosing();
// This shouldn't cause DCHECK failure.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
TEST_F(FileAPIMessageFilterTest, BuildEmptyStream) {
@@ -221,7 +227,7 @@ TEST_F(FileAPIMessageFilterTest, BuildEmptyStream) {
EXPECT_EQ(0, bytes_read);
// Run loop to finish transfer.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
EXPECT_EQ(Stream::STREAM_COMPLETE,
stream->ReadRawData(buffer.get(), kBufferSize, &bytes_read));
@@ -251,7 +257,7 @@ TEST_F(FileAPIMessageFilterTest, BuildNonEmptyStream) {
EXPECT_TRUE(InvokeOnMessageReceived(finish_message));
// Run loop to finish transfer and commit finalize command.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kFakeData.size()));
int bytes_read = 0;
@@ -299,7 +305,7 @@ TEST_F(FileAPIMessageFilterTest, BuildStreamWithSharedMemory) {
EXPECT_TRUE(InvokeOnMessageReceived(finish_message));
// Run loop to finish transfer and commit finalize command.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kFakeData.size()));
int bytes_read = 0;
diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
index 1885fe9..be46339 100644
--- a/content/browser/loader/resource_dispatcher_host_unittest.cc
+++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
@@ -33,7 +33,6 @@
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_simple_job.h"
#include "net/url_request/url_request_test_job.h"
@@ -183,14 +182,13 @@ class MockURLRequestContextSelector
class ForwardingFilter : public ResourceMessageFilter {
public:
explicit ForwardingFilter(IPC::Sender* dest,
- ResourceContext* resource_context,
- net::URLRequestContextGetter* request_context)
+ ResourceContext* resource_context)
: ResourceMessageFilter(
ChildProcessHostImpl::GenerateChildProcessUniqueId(),
PROCESS_TYPE_RENDERER,
resource_context, NULL, NULL, NULL,
new MockURLRequestContextSelector(
- request_context->GetURLRequestContext())),
+ resource_context->GetRequestContext())),
dest_(dest) {
OnChannelConnected(base::GetCurrentProcId());
}
@@ -535,8 +533,7 @@ class ResourceDispatcherHostTest : public testing::Test,
BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
message_loop_.RunUntilIdle();
filter_ = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
}
virtual ~ResourceDispatcherHostTest() {
@@ -1053,9 +1050,8 @@ TEST_F(ResourceDispatcherHostTest, CancelInDelegate) {
// pending and some canceled.
class TestFilter : public ForwardingFilter {
public:
- explicit TestFilter(ResourceContext* resource_context,
- net::URLRequestContextGetter* url_request_context)
- : ForwardingFilter(NULL, resource_context, url_request_context),
+ explicit TestFilter(ResourceContext* resource_context)
+ : ForwardingFilter(NULL, resource_context),
has_canceled_(false),
received_after_canceled_(0) {
}
@@ -1079,8 +1075,7 @@ class TestFilter : public ForwardingFilter {
// Tests CancelRequestsForProcess
TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
scoped_refptr<TestFilter> test_filter = new TestFilter(
- browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ browser_context_->GetResourceContext());
// request 1 goes to the test delegate
ResourceHostMsg_Request request = CreateResourceRequest(
@@ -1223,8 +1218,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
host_.BlockRequestsForRoute(second_filter->child_id(), 0);
@@ -1261,8 +1255,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
host_.BlockRequestsForRoute(filter_->child_id(), 1);
host_.BlockRequestsForRoute(filter_->child_id(), 2);
@@ -1329,8 +1322,7 @@ TEST_F(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
// Saturate the number of outstanding requests for our process.
for (size_t i = 0; i < kMaxRequests; ++i) {
@@ -1394,11 +1386,9 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
// Needed to emulate additional processes.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
scoped_refptr<ForwardingFilter> third_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
// Saturate the number of outstanding requests for our process.
for (size_t i = 0; i < kMaxRequestsPerProcess; ++i) {
@@ -1738,8 +1728,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigation) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
int new_render_view_id = 1;
int new_request_id = 2;
@@ -1800,8 +1789,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationAndThenRedirect) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
int new_render_view_id = 1;
int new_request_id = 2;
diff --git a/content/browser/loader/resource_message_filter.h b/content/browser/loader/resource_message_filter.h
index a4b9bd4..2c56af0 100644
--- a/content/browser/loader/resource_message_filter.h
+++ b/content/browser/loader/resource_message_filter.h
@@ -32,7 +32,6 @@ class ResourceContext;
class CONTENT_EXPORT ResourceMessageFilter : public BrowserMessageFilter {
public:
// Allows selecting the net::URLRequestContext used to service requests.
- // TODO(ajwong): Delete class after http://crbug.com/159193 is resolved.
class URLRequestContextSelector {
public:
URLRequestContextSelector() {}
diff --git a/content/browser/net/cookie_store_map.cc b/content/browser/net/cookie_store_map.cc
deleted file mode 100644
index a36aec3..0000000
--- a/content/browser/net/cookie_store_map.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2013 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 "content/browser/net/cookie_store_map.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/logging.h"
-#include "base/threading/thread_checker.h"
-#include "net/cookies/cookie_monster.h"
-#include "net/cookies/cookie_store.h"
-#include "url/gurl.h"
-
-namespace {
-
-class CookieClearBarrier {
- public:
- CookieClearBarrier(int n, const base::Closure& done)
- : left_(n),
- all_done_(done) {
- }
-
- void OnCookieCleared(int num_deleted) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- // We don't care how many are deleted.
- DCHECK_GT(left_, 0);
-
- if (--left_ == 0) {
- all_done_.Run();
- all_done_.Reset();
- }
- }
-
- static base::Callback<void(int)> NewBarrierClosure(
- int n, const base::Closure& done) {
- DCHECK_GT(n, 0);
- CookieClearBarrier* barrier = new CookieClearBarrier(n, done);
- return base::Bind(&CookieClearBarrier::OnCookieCleared,
- base::Owned(barrier));
- }
-
- private:
- int left_;
- base::Closure all_done_;
- base::ThreadChecker thread_checker_;
-};
-
-} // namespace
-
-namespace content {
-
-CookieStoreMap::CookieStoreMap() {
-}
-
-CookieStoreMap::~CookieStoreMap() {
-}
-
-net::CookieStore* CookieStoreMap::GetForScheme(
- const std::string& scheme) const {
- MapType::const_iterator it = scheme_map_.find(scheme);
- if (it == scheme_map_.end())
- return NULL;
- return it->second;
-}
-
-void CookieStoreMap::SetForScheme(const std::string& scheme,
- net::CookieStore* cookie_store) {
- DCHECK(scheme_map_.find(scheme) == scheme_map_.end());
- DCHECK(cookie_store);
- scheme_map_[scheme] = cookie_store;
-}
-
-void CookieStoreMap::DeleteCookies(const GURL& origin,
- const base::Time begin,
- const base::Time end,
- const base::Closure& done) {
- if (origin.is_empty()) {
- net::CookieStore::DeleteCallback on_delete =
- CookieClearBarrier::NewBarrierClosure(scheme_map_.size(), done);
- for (MapType::const_iterator it = scheme_map_.begin();
- it != scheme_map_.end(); ++it) {
- it->second->DeleteAllCreatedBetweenAsync(begin, end, on_delete);
- }
- } else {
- net::CookieStore* cookie_store = GetForScheme(origin.scheme());
- if (!cookie_store) {
- done.Run();
- return;
- }
- cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync(
- begin, end, origin, CookieClearBarrier::NewBarrierClosure(1, done));
- }
-}
-
-CookieStoreMap* CookieStoreMap::Clone() const {
- CookieStoreMap* cloned_map = new CookieStoreMap();
- cloned_map->scheme_map_ = scheme_map_;
- return cloned_map;
-}
-
-} // namespace content
diff --git a/content/browser/net/cookie_store_map.h b/content/browser/net/cookie_store_map.h
deleted file mode 100644
index b2be30f..0000000
--- a/content/browser/net/cookie_store_map.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2013 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 CONTENT_BROWSER_NET_COOKIE_STORE_MAP_H_
-#define CONTENT_BROWSER_NET_COOKIE_STORE_MAP_H_
-
-#include <map>
-#include <string>
-
-#include "base/callback_forward.h"
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "base/time/time.h"
-#include "content/common/content_export.h"
-
-class GURL;
-
-namespace net {
-class CookieStore;
-} // namespace net
-
-namespace content {
-
-// CookieStoreMap allows associating different CookieStore objects with
-// different schemes. It is mainly a convenience class.
-class CookieStoreMap {
- public:
- CookieStoreMap();
- virtual ~CookieStoreMap();
-
- // Returns the CookieStore associated with |scheme|.
- CONTENT_EXPORT net::CookieStore* GetForScheme(
- const std::string& scheme) const;
-
- // Associates a |cookie_store| with the given |scheme|. Should only be called
- // once for any given |scheme|. |cookie_store| must be non-NULL. The
- // CookieStoreMap will retain the |cookie_store| object.
- void SetForScheme(const std::string& scheme, net::CookieStore* cookie_store);
-
- // Clears cookies matching the specified parameters from all CookieStores
- // contained in this map. Calls |done| when all CookieStores have been
- // cleared. |done| is guaranteed to be run on the calling thread.
- void DeleteCookies(const GURL& origin,
- const base::Time begin,
- const base::Time end,
- const base::Closure& done);
-
- // Makes a clone of the map. Useful if the map needs to be copied to another
- // thread.
- CookieStoreMap* Clone() const;
-
- private:
- typedef std::map<std::string, scoped_refptr<net::CookieStore> > MapType;
- MapType scheme_map_;
-
- DISALLOW_COPY_AND_ASSIGN(CookieStoreMap);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_NET_COOKIE_STORE_MAP_H_
diff --git a/content/browser/net/sqlite_persistent_cookie_store.cc b/content/browser/net/sqlite_persistent_cookie_store.cc
index 55be9e9d..c23692d 100644
--- a/content/browser/net/sqlite_persistent_cookie_store.cc
+++ b/content/browser/net/sqlite_persistent_cookie_store.cc
@@ -12,7 +12,6 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/callback.h"
-#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/location.h"
@@ -29,7 +28,6 @@
#include "base/time/time.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/common/content_switches.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_constants.h"
@@ -1196,60 +1194,28 @@ SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
// a reference if the background runner has not run Close() yet.
}
-CookieStoreConfig::CookieStoreConfig(
+net::CookieStore* CreatePersistentCookieStore(
const base::FilePath& path,
- SessionCookieMode session_cookie_mode,
+ bool restore_old_session_cookies,
quota::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate)
- : path(path),
- session_cookie_mode(session_cookie_mode),
- storage_policy(storage_policy),
- cookie_delegate(cookie_delegate) {
- CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES);
-}
-
-CookieStoreConfig::CookieStoreConfig()
- : session_cookie_mode(EPHEMERAL_SESSION_COOKIES) {
- // Default to an in-memory cookie store.
-}
-
-CookieStoreConfig::~CookieStoreConfig() {
-}
-
-net::CookieStore* CreateCookieStore(const CookieStoreConfig& config) {
- if (config.path.empty()) {
- return new net::CookieMonster(NULL, config.cookie_delegate);
- }
-
+ net::CookieMonster::Delegate* cookie_monster_delegate) {
SQLitePersistentCookieStore* persistent_store =
new SQLitePersistentCookieStore(
- config.path,
+ path,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
BrowserThread::GetBlockingPool()->GetSequenceToken()),
- (config.session_cookie_mode ==
- CookieStoreConfig::RESTORED_SESSION_COOKIES),
- config.storage_policy);
+ restore_old_session_cookies,
+ storage_policy);
net::CookieMonster* cookie_monster =
- new net::CookieMonster(persistent_store, config.cookie_delegate);
- if ((config.session_cookie_mode ==
- CookieStoreConfig::PERSISTANT_SESSION_COOKIES) ||
- (config.session_cookie_mode ==
- CookieStoreConfig::RESTORED_SESSION_COOKIES)) {
- cookie_monster->SetPersistSessionCookies(true);
- }
-
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableFileCookies)) {
- cookie_monster->SetEnableFileScheme(true);
- }
+ new net::CookieMonster(persistent_store, cookie_monster_delegate);
const std::string cookie_priority_experiment_group =
base::FieldTrialList::FindFullName("CookieRetentionPriorityStudy");
cookie_monster->SetPriorityAwareGarbageCollection(
cookie_priority_experiment_group == "ExperimentOn");
- return cookie_monster;
+ return cookie_monster;
}
} // namespace content
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 571e57b..fc84eab 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -22,7 +22,6 @@
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/media/media_internals.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/browser/plugin_process_host.h"
#include "content/browser/plugin_service_impl.h"
#include "content/browser/ppapi_plugin_process_host.h"
@@ -86,6 +85,8 @@
#include "media/base/android/webaudio_media_codec_bridge.h"
#endif
+using net::CookieStore;
+
namespace content {
namespace {
@@ -291,7 +292,6 @@ RenderMessageFilter::RenderMessageFilter(
PluginServiceImpl* plugin_service,
BrowserContext* browser_context,
net::URLRequestContextGetter* request_context,
- const CookieStoreMap& cookie_store_map,
RenderWidgetHelper* render_widget_helper,
media::AudioManager* audio_manager,
MediaInternals* media_internals,
@@ -300,7 +300,6 @@ RenderMessageFilter::RenderMessageFilter(
plugin_service_(plugin_service),
profile_data_directory_(browser_context->GetPath()),
request_context_(request_context),
- cookie_store_map_(cookie_store_map.Clone()),
resource_context_(browser_context->GetResourceContext()),
render_widget_helper_(render_widget_helper),
incognito_(browser_context->IsOffTheRecord()),
@@ -542,15 +541,9 @@ void RenderMessageFilter::OnSetCookie(const IPC::Message& message,
url, first_party_for_cookies, cookie,
resource_context_, render_process_id_, message.routing_id(),
&options)) {
+ net::URLRequestContext* context = GetRequestContextForURL(url);
// Pass a null callback since we don't care about when the 'set' completes.
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
-
- // Handle requests for non-cookieable schemes.
- if (!cookie_store)
- return;
-
- cookie_store->SetCookieWithOptionsAsync(
+ context->cookie_store()->SetCookieWithOptionsAsync(
url, cookie, options, net::CookieMonster::SetCookiesCallback());
}
}
@@ -571,15 +564,10 @@ void RenderMessageFilter::OnGetCookies(const GURL& url,
base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
base::debug::Alias(url_buf);
- // Handle requests for non-cookieable schemes.
- net::CookieStore* cookie_store = cookie_store_map_->GetForScheme(
- url.scheme());
- if (!cookie_store) {
- SendGetCookiesResponse(reply_msg, std::string());
- return;
- }
-
- cookie_store->GetCookieMonster()->GetAllCookiesForURLAsync(
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ net::CookieMonster* cookie_monster =
+ context->cookie_store()->GetCookieMonster();
+ cookie_monster->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::CheckPolicyForCookies, this, url,
first_party_for_cookies, reply_msg));
}
@@ -594,24 +582,19 @@ void RenderMessageFilter::OnGetRawCookies(
// not targeted to an an external host like ChromeFrame.
// TODO(ananta) We need to support retreiving raw cookies from external
// hosts.
- //
- // We check policy here to avoid sending back cookies that would not normally
- // be applied to outbound requests for the given URL. Since this cookie info
- // is visible in the developer tools, it is helpful to make it match reality.
if (!policy->CanReadRawCookies(render_process_id_) ||
!policy->CanAccessCookiesForOrigin(render_process_id_, url)) {
SendGetRawCookiesResponse(reply_msg, net::CookieList());
return;
}
- // Handle requests for non-cookieable schemes.
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
- if (!cookie_store) {
- SendGetRawCookiesResponse(reply_msg, net::CookieList());
- return;
- }
- cookie_store->GetCookieMonster()->GetAllCookiesForURLAsync(
+ // We check policy here to avoid sending back cookies that would not normally
+ // be applied to outbound requests for the given URL. Since this cookie info
+ // is visible in the developer tools, it is helpful to make it match reality.
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ net::CookieMonster* cookie_monster =
+ context->cookie_store()->GetCookieMonster();
+ cookie_monster->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::SendGetRawCookiesResponse,
this, reply_msg));
}
@@ -623,12 +606,8 @@ void RenderMessageFilter::OnDeleteCookie(const GURL& url,
if (!policy->CanAccessCookiesForOrigin(render_process_id_, url))
return;
- // Handle requests for non-cookieable schemes.
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
- if (!cookie_store)
- return;
- cookie_store->DeleteCookieAsync(url, cookie_name, base::Closure());
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ context->cookie_store()->DeleteCookieAsync(url, cookie_name, base::Closure());
}
void RenderMessageFilter::OnCookiesEnabled(
@@ -887,6 +866,19 @@ void RenderMessageFilter::OnAllocateSharedMemory(
buffer_size, PeerHandle(), handle);
}
+net::URLRequestContext* RenderMessageFilter::GetRequestContextForURL(
+ const GURL& url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ net::URLRequestContext* context =
+ GetContentClient()->browser()->OverrideRequestContextForURL(
+ url, resource_context_);
+ if (!context)
+ context = request_context_->GetURLRequestContext();
+
+ return context;
+}
+
#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
void RenderMessageFilter::OnAllocTransportDIB(
uint32 size, bool cache_in_browser, TransportDIB::Handle* handle) {
@@ -1033,15 +1025,14 @@ void RenderMessageFilter::CheckPolicyForCookies(
const GURL& first_party_for_cookies,
IPC::Message* reply_msg,
const net::CookieList& cookie_list) {
+ net::URLRequestContext* context = GetRequestContextForURL(url);
// Check the policy for get cookies, and pass cookie_list to the
// TabSpecificContentSetting for logging purpose.
if (GetContentClient()->browser()->AllowGetCookie(
url, first_party_for_cookies, cookie_list, resource_context_,
render_process_id_, reply_msg->routing_id())) {
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
// Gets the cookies from cookie store if allowed.
- cookie_store->GetCookiesWithOptionsAsync(
+ context->cookie_store()->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
base::Bind(&RenderMessageFilter::SendGetCookiesResponse,
this, reply_msg));
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 06a8f40..4eb9864 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -60,12 +60,12 @@ struct MediaLogEvent;
}
namespace net {
+class URLRequestContext;
class URLRequestContextGetter;
}
namespace content {
class BrowserContext;
-class CookieStoreMap;
class DOMStorageContextWrapper;
class MediaInternals;
class PluginServiceImpl;
@@ -85,7 +85,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
PluginServiceImpl * plugin_service,
BrowserContext* browser_context,
net::URLRequestContextGetter* request_context,
- const CookieStoreMap& cookie_store_map,
RenderWidgetHelper* render_widget_helper,
media::AudioManager* audio_manager,
MediaInternals* media_internals,
@@ -106,6 +105,11 @@ class RenderMessageFilter : public BrowserMessageFilter {
int render_process_id() const { return render_process_id_; }
+ // Returns the correct net::URLRequestContext depending on what type of url is
+ // given.
+ // Only call on the IO thread.
+ net::URLRequestContext* GetRequestContextForURL(const GURL& url);
+
private:
friend class BrowserThread;
friend class base::DeleteHelper<RenderMessageFilter>;
@@ -268,12 +272,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
// Contextual information to be used for requests created here.
scoped_refptr<net::URLRequestContextGetter> request_context_;
- // Map of schemes to the CookieStore instance that services those schemes.
- // We store a clone of the CookieStoreMap passed in the constructor in
- // order to avoid having 2 threads access the same object. Is is assumed
- // that the source map never changes after we make the clone.
- scoped_ptr<CookieStoreMap> cookie_store_map_;
-
// The ResourceContext which is to be used on the IO thread.
ResourceContext* resource_context_;
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 6872d22..bafb4a8 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -554,8 +554,7 @@ void RenderProcessHostImpl::CreateMessageFilters() {
NULL,
#endif
GetBrowserContext(),
- storage_partition_impl_->GetURLRequestContext(),
- storage_partition_impl_->GetCookieStoreMap(),
+ GetBrowserContext()->GetRequestContextForRenderProcess(GetID()),
widget_helper_.get(),
audio_manager,
media_internals,
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 12368ff..d68b174 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -9,7 +9,6 @@
#include "content/browser/browser_main_loop.h"
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/gpu/shader_disk_cache.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/common/dom_storage/dom_storage_types.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -17,7 +16,6 @@
#include "content/public/browser/indexed_db_context.h"
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/session_storage_usage_info.h"
-#include "content/public/common/url_constants.h"
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
#include "net/cookies/cookie_monster.h"
@@ -45,6 +43,40 @@ int GenerateQuotaClientMask(uint32 remove_mask) {
return quota_client_mask;
}
+void OnClearedCookies(const base::Closure& callback, int num_deleted) {
+ // The final callback needs to happen from UI thread.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&OnClearedCookies, callback, num_deleted));
+ return;
+ }
+
+ callback.Run();
+}
+
+void ClearCookiesOnIOThread(
+ const scoped_refptr<net::URLRequestContextGetter>& rq_context,
+ const base::Time begin,
+ const base::Time end,
+ const GURL& remove_origin,
+ const base::Closure& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::CookieStore* cookie_store = rq_context->
+ GetURLRequestContext()->cookie_store();
+ if (remove_origin.is_empty()) {
+ cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenAsync(
+ begin,
+ end,
+ base::Bind(&OnClearedCookies, callback));
+ } else {
+ cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync(
+ begin,
+ end,
+ remove_origin, base::Bind(&OnClearedCookies, callback));
+ }
+}
+
void OnQuotaManagedOriginDeleted(const GURL& origin,
quota::StorageType type,
size_t* origins_to_delete_count,
@@ -216,7 +248,7 @@ struct StoragePartitionImpl::DataDeletionHelper {
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
const base::FilePath& path,
- CookieStoreMap* cookie_store_map,
+ net::URLRequestContextGetter* rq_context,
DOMStorageContextWrapper* dom_storage_context,
quota::QuotaManager* quota_manager,
WebRTCIdentityStore* webrtc_identity_store,
@@ -252,7 +284,6 @@ StoragePartitionImpl::StoragePartitionImpl(
webkit_database::DatabaseTracker* database_tracker,
DOMStorageContextWrapper* dom_storage_context,
IndexedDBContextImpl* indexed_db_context,
- scoped_ptr<CookieStoreMap> cookie_store_map,
WebRTCIdentityStore* webrtc_identity_store)
: partition_path_(partition_path),
quota_manager_(quota_manager),
@@ -261,9 +292,7 @@ StoragePartitionImpl::StoragePartitionImpl(
database_tracker_(database_tracker),
dom_storage_context_(dom_storage_context),
indexed_db_context_(indexed_db_context),
- cookie_store_map_(cookie_store_map.Pass()),
- webrtc_identity_store_(webrtc_identity_store) {
-}
+ webrtc_identity_store_(webrtc_identity_store) {}
StoragePartitionImpl::~StoragePartitionImpl() {
// These message loop checks are just to avoid leaks in unittests.
@@ -287,8 +316,7 @@ StoragePartitionImpl::~StoragePartitionImpl() {
StoragePartitionImpl* StoragePartitionImpl::Create(
BrowserContext* context,
bool in_memory,
- const base::FilePath& partition_path,
- scoped_ptr<CookieStoreMap> cookie_store_map) {
+ const base::FilePath& partition_path) {
// Ensure that these methods are called on the UI thread, except for
// unittests where a UI thread might not have been created.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
@@ -352,7 +380,6 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
database_tracker.get(),
dom_storage_context.get(),
indexed_db_context.get(),
- cookie_store_map.Pass(),
webrtc_identity_store.get());
}
@@ -393,15 +420,11 @@ IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
return indexed_db_context_.get();
}
-net::CookieStore* StoragePartitionImpl::GetCookieStoreForScheme(
- const std::string& scheme) {
- return GetCookieStoreMap().GetForScheme(scheme);
-}
-
void StoragePartitionImpl::ClearDataImpl(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
+ net::URLRequestContextGetter* rq_context,
const base::Time begin,
const base::Time end,
const base::Closure& callback) {
@@ -411,7 +434,7 @@ void StoragePartitionImpl::ClearDataImpl(
// DataDeletionHelper::DecrementTaskCountOnUI().
helper->ClearDataOnUIThread(
remove_mask, quota_storage_remove_mask, remove_origin,
- GetPath(), cookie_store_map_.get(), dom_storage_context_, quota_manager_,
+ GetPath(), rq_context, dom_storage_context_, quota_manager_,
webrtc_identity_store_, begin, end);
}
@@ -524,7 +547,7 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
const base::FilePath& path,
- CookieStoreMap* cookie_store_map,
+ net::URLRequestContextGetter* rq_context,
DOMStorageContextWrapper* dom_storage_context,
quota::QuotaManager* quota_manager,
WebRTCIdentityStore* webrtc_identity_store,
@@ -540,8 +563,11 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
if (remove_mask & REMOVE_DATA_MASK_COOKIES) {
// Handle the cookies.
IncrementTaskCountOnUI();
- cookie_store_map->DeleteCookies(remove_origin, begin, end,
- decrement_callback);
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ClearCookiesOnIOThread,
+ make_scoped_refptr(rq_context), begin, end, remove_origin,
+ decrement_callback));
}
if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB ||
@@ -600,17 +626,20 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
void StoragePartitionImpl::ClearDataForOrigin(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& storage_origin) {
+ const GURL& storage_origin,
+ net::URLRequestContextGetter* request_context_getter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin,
- base::Time(), base::Time::Max(), base::Bind(&base::DoNothing));
+ request_context_getter, base::Time(), base::Time::Max(),
+ base::Bind(&base::DoNothing));
}
void StoragePartitionImpl::ClearDataForUnboundedRange(
uint32 remove_mask,
uint32 quota_storage_remove_mask) {
ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(),
- base::Time(), base::Time::Max(), base::Bind(&base::DoNothing));
+ GetURLRequestContext(), base::Time(), base::Time::Max(),
+ base::Bind(&base::DoNothing));
}
void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask,
@@ -618,18 +647,14 @@ void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask,
const base::Time& begin,
const base::Time& end,
const base::Closure& callback) {
- ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), begin, end,
- callback);
+ ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(),
+ GetURLRequestContext(), begin, end, callback);
}
WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() {
return webrtc_identity_store_.get();
}
-const CookieStoreMap& StoragePartitionImpl::GetCookieStoreMap() {
- return *cookie_store_map_;
-}
-
void StoragePartitionImpl::SetURLRequestContext(
net::URLRequestContextGetter* url_request_context) {
url_request_context_ = url_request_context;
diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h
index 0d3c7c5..e59347c 100644
--- a/content/browser/storage_partition_impl.h
+++ b/content/browser/storage_partition_impl.h
@@ -12,7 +12,6 @@
#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "content/browser/media/webrtc_identity_store.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/common/content_export.h"
#include "content/public/browser/storage_partition.h"
@@ -32,12 +31,12 @@ class StoragePartitionImpl : public StoragePartition {
virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE;
virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
- virtual net::CookieStore* GetCookieStoreForScheme(
- const std::string& scheme) OVERRIDE;
+
virtual void ClearDataForOrigin(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& storage_origin) OVERRIDE;
+ const GURL& storage_origin,
+ net::URLRequestContextGetter* request_context_getter) OVERRIDE;
virtual void ClearDataForUnboundedRange(
uint32 remove_mask,
uint32 quota_storage_remove_mask) OVERRIDE;
@@ -48,7 +47,6 @@ class StoragePartitionImpl : public StoragePartition {
const base::Closure& callback) OVERRIDE;
WebRTCIdentityStore* GetWebRTCIdentityStore();
- CONTENT_EXPORT const CookieStoreMap& GetCookieStoreMap();
struct DataDeletionHelper;
struct QuotaManagedDataDeletionHelper;
@@ -60,14 +58,12 @@ class StoragePartitionImpl : public StoragePartition {
// The |partition_path| is the absolute path to the root of this
// StoragePartition's on-disk storage.
//
- // If |in_memory| is true, the |profile_path| is (ab)used as a way of
+ // If |in_memory| is true, the |partition_path| is (ab)used as a way of
// distinguishing different in-memory partitions, but nothing is persisted
// on to disk.
- static StoragePartitionImpl* Create(
- BrowserContext* context,
- bool in_memory,
- const base::FilePath& profile_path,
- scoped_ptr<CookieStoreMap> cookie_store_map);
+ static StoragePartitionImpl* Create(BrowserContext* context,
+ bool in_memory,
+ const base::FilePath& profile_path);
// Quota managed data uses a different bitmask for types than
// StoragePartition uses. This method generates that mask.
@@ -81,13 +77,12 @@ class StoragePartitionImpl : public StoragePartition {
webkit_database::DatabaseTracker* database_tracker,
DOMStorageContextWrapper* dom_storage_context,
IndexedDBContextImpl* indexed_db_context,
- scoped_ptr<CookieStoreMap> cookie_store_map,
WebRTCIdentityStore* webrtc_identity_store);
- // Use an empty |remove_origin| to delete data from all origins.
void ClearDataImpl(uint32 remove_mask,
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
+ net::URLRequestContextGetter* rq_context,
const base::Time begin,
const base::Time end,
const base::Closure& callback);
@@ -117,7 +112,6 @@ class StoragePartitionImpl : public StoragePartition {
scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
- scoped_ptr<CookieStoreMap> cookie_store_map_;
scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index eba0f4b..c5721ae 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -18,7 +18,6 @@
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/loader/resource_request_info_impl.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/browser/resource_context_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/streams/stream.h"
@@ -29,12 +28,10 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/url_constants.h"
#include "crypto/sha2.h"
-#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "webkit/browser/blob/blob_url_request_job_factory.h"
@@ -349,14 +346,6 @@ void BlockingGarbageCollect(
base::Bind(base::IgnoreResult(&base::DeleteFile), trash_directory, true));
}
-void AttachDefaultCookieStoreOnIOThread(
- const scoped_refptr<net::URLRequestContextGetter>& url_request_context,
- const scoped_refptr<net::CookieStore> cookie_store) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- url_request_context->GetURLRequestContext()->set_cookie_store(
- cookie_store.get());
-}
-
} // namespace
// static
@@ -414,16 +403,9 @@ StoragePartitionImpl* StoragePartitionImplMap::Get(
base::FilePath partition_path =
browser_context_->GetPath().Append(
GetStoragePartitionPath(partition_domain, partition_name));
-
- // Create the cookie stores.
- scoped_ptr<CookieStoreMap> cookie_store_map(
- CreateCookieStores(partition_path,
- in_memory,
- partition_domain.empty()));
-
StoragePartitionImpl* partition =
StoragePartitionImpl::Create(browser_context_, in_memory,
- partition_path, cookie_store_map.Pass());
+ partition_path);
partitions_[partition_config] = partition;
ChromeBlobStorageContext* blob_storage_context =
@@ -586,29 +568,8 @@ void StoragePartitionImplMap::PostCreateInitialization(
InitializeResourceContext(browser_context_);
}
- // In unittests, BrowserThread::IO may not be valid which would yield a
- // memory leak on a PostTask. Also, in content_unittests, the
- // URLRequestContext is NULL.
- //
- // TODO(ajwong): Should default ContentBrowserClient return a non-null
- // URLRequestContext?
- if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
- partition->GetURLRequestContext()) {
- // The main URLRequestContextGetter was first created just before
- // PostCreateInitialization() is called thus attaching the CookieStore here
- // is guaranteed to occur before anyone else can see the main request
- // context including the media request context.
- //
- // We pass the cookie store for chrome::kHttpScheme because we know this
- // will return the default cookie store.
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&AttachDefaultCookieStoreOnIOThread,
- make_scoped_refptr(partition->GetURLRequestContext()),
- make_scoped_refptr(
- partition->GetCookieStoreMap().GetForScheme(
- chrome::kHttpScheme))));
-
+ // Check first to avoid memory leak in unittests.
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
@@ -620,7 +581,7 @@ void StoragePartitionImplMap::PostCreateInitialization(
make_scoped_refptr(
browser_context_->GetSpecialStoragePolicy())));
- // We do not initialize the AppCacheService for media contexts because,
+ // We do not call InitializeURLRequestContext() for media contexts because,
// other than the HTTP cache, the media contexts share the same backing
// objects as their associated "normal" request context. Thus, the previous
// call serves to initialize the media request context for this storage
@@ -628,47 +589,4 @@ void StoragePartitionImplMap::PostCreateInitialization(
}
}
-scoped_ptr<CookieStoreMap> StoragePartitionImplMap::CreateCookieStores(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition) {
- scoped_ptr<CookieStoreMap> cookie_store_map(new CookieStoreMap());
- std::map<std::string, CookieStoreConfig> cookie_store_configs;
- cookie_store_configs[BrowserContext::kDefaultCookieScheme] =
- CookieStoreConfig();
-
- browser_context_->OverrideCookieStoreConfigs(
- partition_path, in_memory_partition, is_default_partition,
- &cookie_store_configs);
-
- for (std::map<std::string, CookieStoreConfig>::const_iterator it =
- cookie_store_configs.begin();
- it != cookie_store_configs.end();
- ++it) {
- scoped_refptr<net::CookieStore> cookie_store =
- CreateCookieStore(it->second);
- if (it->first == BrowserContext::kDefaultCookieScheme) {
- cookie_store_map->SetForScheme(chrome::kHttpScheme, cookie_store);
- cookie_store_map->SetForScheme(content::kHttpsScheme, cookie_store);
-
- // If file scheme is enabled, share the same cookie store as http. This is
- // legacy behavior. A complete valid, alternate approach is to use a
- // different cookie database. See comments inside CookieMonster about
- // separating out file cookies into their own CookieMonster.
- if ((cookie_store_configs.find(chrome::kFileScheme) ==
- cookie_store_configs.end())
- && cookie_store->GetCookieMonster()->IsCookieableScheme(
- chrome::kFileScheme)) {
- cookie_store_map->SetForScheme(chrome::kFileScheme, cookie_store);
- }
- } else {
- const char* schemes[] = { it->first.c_str() };
- cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 1);
- cookie_store_map->SetForScheme(it->first, cookie_store);
- }
- }
-
- return cookie_store_map.Pass();
-}
-
} // namespace content
diff --git a/content/browser/storage_partition_impl_map.h b/content/browser/storage_partition_impl_map.h
index b6a65c5..972335a 100644
--- a/content/browser/storage_partition_impl_map.h
+++ b/content/browser/storage_partition_impl_map.h
@@ -118,11 +118,6 @@ class StoragePartitionImplMap : public base::SupportsUserData::Data {
void PostCreateInitialization(StoragePartitionImpl* partition,
bool in_memory);
- scoped_ptr<CookieStoreMap> CreateCookieStores(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition);
-
BrowserContext* browser_context_; // Not Owned.
scoped_refptr<base::SequencedTaskRunner> file_access_runner_;
PartitionMap partitions_;
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc
index c14a7d4..a8b47bc 100644
--- a/content/browser/storage_partition_impl_unittest.cc
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -8,7 +8,6 @@
#include "base/threading/thread.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/gpu/shader_disk_cache.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -110,8 +109,8 @@ TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) {
EXPECT_EQ(1u, Size());
TestClosureCallback clear_cb;
- StoragePartitionImpl sp(cache_path(), NULL, NULL, NULL, NULL, NULL, NULL,
- scoped_ptr<CookieStoreMap>(), NULL);
+ StoragePartitionImpl sp(
+ cache_path(), NULL, NULL, NULL, NULL, NULL, NULL, NULL);
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearData, &sp, clear_cb.callback()));
clear_cb.WaitForResult();
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 8fc2eab..064a12e 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -718,8 +718,6 @@
'browser/mime_registry_message_filter.h',
'browser/net/browser_online_state_observer.cc',
'browser/net/browser_online_state_observer.h',
- 'browser/net/cookie_store_map.cc',
- 'browser/net/cookie_store_map.h',
'browser/net/sqlite_persistent_cookie_store.cc',
'browser/net/sqlite_persistent_cookie_store.h',
'browser/net/view_blob_internals_job_factory.cc',
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h
index d1066e3..cbac82f 100644
--- a/content/public/browser/browser_context.h
+++ b/content/public/browser/browser_context.h
@@ -38,14 +38,10 @@ class IndexedDBContext;
class ResourceContext;
class SiteInstance;
class StoragePartition;
-struct CookieStoreConfig;
// This class holds the context needed for a browsing session.
// It lives on the UI thread. All these methods must only be called on the UI
// thread.
-//
-// TODO(jam): Pure virtual methods should be converted to ones with empty or
-// trivial default implementations.
class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
public:
static DownloadManager* GetDownloadManager(BrowserContext* browser_context);
@@ -75,9 +71,8 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
scoped_ptr<base::hash_set<base::FilePath> > active_paths,
const base::Closure& done);
- // Prefer GetStoragePartition() or GetStoragePartitionForSite() above. Only
- // use this if it is 100% certain that the cookie store, cache, etc., that
- // is returned by this will be the correct one.
+ // DON'T USE THIS. GetDefaultStoragePartition() is going away.
+ // Use GetStoragePartition() instead. Ask ajwong@ if you have problems.
static content::StoragePartition* GetDefaultStoragePartition(
BrowserContext* browser_context);
@@ -101,23 +96,7 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
virtual base::FilePath GetPath() const = 0;
// Return whether this context is incognito. Default is false.
- virtual bool IsOffTheRecord() const;
-
- // kDefaultCookieScheme is used in place of a scheme to specify the
- // CookieStoreConfig for the http, https, and possibly file scheme.
- //
- // The http and https scheme must share a single cookie jar in order for
- // the web to function properly. The legacy setup also has the file scheme
- // share the same cookie jar when file cookies are enabled.
- static const char kDefaultCookieScheme[];
- typedef std::map<std::string, CookieStoreConfig> CookieSchemeMap;
-
- // Allows embedder to change how the Cookie stores are configured.
- virtual void OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) {}
+ virtual bool IsOffTheRecord() const = 0;
// Returns the request context information associated with this context. Call
// this only on the UI thread, since it can send notifications that should
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index f5419be..c2bf137 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -163,6 +163,11 @@ QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() {
return NULL;
}
+net::URLRequestContext* ContentBrowserClient::OverrideRequestContextForURL(
+ const GURL& url, ResourceContext* context) {
+ return NULL;
+}
+
std::string ContentBrowserClient::GetStoragePartitionIdForSite(
BrowserContext* browser_context,
const GURL& site) {
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 4380f28..1f5e836 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -22,7 +22,6 @@
#include "content/public/common/window_container_type.h"
#include "net/base/mime_util.h"
#include "net/cookies/canonical_cookie.h"
-#include "net/cookies/cookie_store.h"
#include "net/url_request/url_request_job_factory.h"
#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
#include "ui/base/window_open_disposition.h"
@@ -54,12 +53,12 @@ class ImageSkia;
namespace net {
class CookieOptions;
-class CookieStore;
class HttpNetworkSession;
class NetLog;
class SSLCertRequestInfo;
class SSLInfo;
class URLRequest;
+class URLRequestContext;
class URLRequestContextGetter;
class X509Certificate;
}
@@ -329,6 +328,13 @@ class CONTENT_EXPORT ContentBrowserClient {
ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views);
+ // Allow the embedder to override the request context based on the URL for
+ // certain operations, like cookie access. Returns NULL to indicate the
+ // regular request context should be used.
+ // This is called on the IO thread.
+ virtual net::URLRequestContext* OverrideRequestContextForURL(
+ const GURL& url, ResourceContext* context);
+
// Allow the embedder to specify a string version of the storage partition
// config with a site.
virtual std::string GetStoragePartitionIdForSite(
diff --git a/content/public/browser/cookie_store_factory.h b/content/public/browser/cookie_store_factory.h
index 2b6e879..c7a9c6e 100644
--- a/content/public/browser/cookie_store_factory.h
+++ b/content/public/browser/cookie_store_factory.h
@@ -5,48 +5,24 @@
#ifndef CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_
#define CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
-#include "webkit/browser/quota/special_storage_policy.h"
+#include "net/cookies/cookie_monster.h"
namespace base {
class FilePath;
}
-namespace net {
-class CookieMonsterDelegate;
-class CookieStore;
+namespace quota {
+class SpecialStoragePolicy;
}
namespace content {
-struct CONTENT_EXPORT CookieStoreConfig {
- // Specifies how session cookies are persisted in the backing data store.
- enum SessionCookieMode {
- EPHEMERAL_SESSION_COOKIES,
- PERSISTANT_SESSION_COOKIES,
- RESTORED_SESSION_COOKIES
- };
-
- // If |path| is empty, then this specifies an in-memory cookie store.
- // With in-memory cookie stores, |session_cookie_mode| must be
- // EPHEMERAL_SESSION_COOKIES.
- CookieStoreConfig();
- CookieStoreConfig(const base::FilePath& path,
- SessionCookieMode session_cookie_mode,
- quota::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate);
- ~CookieStoreConfig();
-
- base::FilePath path;
- SessionCookieMode session_cookie_mode;
- scoped_refptr<quota::SpecialStoragePolicy> storage_policy;
- scoped_refptr<net::CookieMonsterDelegate> cookie_delegate;
-};
-
-CONTENT_EXPORT net::CookieStore* CreateCookieStore(
- const CookieStoreConfig& config);
+CONTENT_EXPORT net::CookieStore* CreatePersistentCookieStore(
+ const base::FilePath& path,
+ bool restore_old_session_cookies,
+ quota::SpecialStoragePolicy* storage_policy,
+ net::CookieMonster::Delegate* cookie_monster_delegate);
} // namespace content
diff --git a/content/public/browser/storage_partition.h b/content/public/browser/storage_partition.h
index 60242f6..b30ca42 100644
--- a/content/public/browser/storage_partition.h
+++ b/content/public/browser/storage_partition.h
@@ -21,7 +21,6 @@ class FileSystemContext;
}
namespace net {
-class CookieStore;
class URLRequestContextGetter;
}
@@ -36,9 +35,8 @@ class DatabaseTracker;
namespace content {
class BrowserContext;
-class CookieStoreMap;
-class DOMStorageContext;
class IndexedDBContext;
+class DOMStorageContext;
// Defines what persistent state a child process can access.
//
@@ -57,8 +55,6 @@ class StoragePartition {
virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0;
virtual DOMStorageContext* GetDOMStorageContext() = 0;
virtual IndexedDBContext* GetIndexedDBContext() = 0;
- virtual net::CookieStore* GetCookieStoreForScheme(
- const std::string& scheme) = 0;
enum RemoveDataMask {
REMOVE_DATA_MASK_APPCACHE = 1 << 0,
@@ -90,9 +86,16 @@ class StoragePartition {
// inside this StoragePartition for the given |storage_origin|.
// Note session dom storage is not cleared even if you specify
// REMOVE_DATA_MASK_LOCAL_STORAGE.
+ //
+ // TODO(ajwong): Right now, the embedder may have some
+ // URLRequestContextGetter objects that the StoragePartition does not know
+ // about. This will no longer be the case when we resolve
+ // http://crbug.com/159193. Remove |request_context_getter| when that bug
+ // is fixed.
virtual void ClearDataForOrigin(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& storage_origin) = 0;
+ const GURL& storage_origin,
+ net::URLRequestContextGetter* rq_context) = 0;
// Similar to ClearDataForOrigin(), but deletes all data out of the
// StoragePartition rather than just the data related to this origin.
diff --git a/content/public/common/content_constants.cc b/content/public/common/content_constants.cc
index fa19eaa..75e9273 100644
--- a/content/public/common/content_constants.cc
+++ b/content/public/common/content_constants.cc
@@ -11,9 +11,6 @@ const base::FilePath::CharType kAppCacheDirname[] =
const base::FilePath::CharType kPepperDataDirname[] =
FILE_PATH_LITERAL("Pepper Data");
-const base::FilePath::CharType kCookieFilename[] =
- FILE_PATH_LITERAL("Cookies");
-
const char kBrowserPluginMimeType[] = "application/browser-plugin";
const char kFlashPluginName[] = "Shockwave Flash";
diff --git a/content/public/common/content_constants.h b/content/public/common/content_constants.h
index a5de2b7..012b00f 100644
--- a/content/public/common/content_constants.h
+++ b/content/public/common/content_constants.h
@@ -21,8 +21,6 @@ CONTENT_EXPORT extern const base::FilePath::CharType kAppCacheDirname[];
// data is put.
CONTENT_EXPORT extern const base::FilePath::CharType kPepperDataDirname[];
-CONTENT_EXPORT extern const base::FilePath::CharType kCookieFilename[];
-
// The MIME type used for the browser plugin.
CONTENT_EXPORT extern const char kBrowserPluginMimeType[];
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 92e1111..bcf7820 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -63,10 +63,6 @@ const char kDebugPluginLoading[] = "debug-plugin-loading";
const char kDefaultTileWidth[] = "default-tile-width";
const char kDefaultTileHeight[] = "default-tile-height";
-// By default, cookies are not allowed on file://. They are needed for testing,
-// for example page cycler and layout tests. See bug 1157243.
-const char kEnableFileCookies[] = "enable-file-cookies";
-
// Disable antialiasing on 2d canvas.
const char kDisable2dCanvasAntialiasing[] = "disable-canvas-aa";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 29d798c..e0da3ef 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -30,7 +30,6 @@ CONTENT_EXPORT extern const char kBrowserSubprocessPath[];
extern const char kDebugPluginLoading[];
extern const char kDefaultTileWidth[];
extern const char kDefaultTileHeight[];
-CONTENT_EXPORT extern const char kEnableFileCookies[];
CONTENT_EXPORT extern const char kDisable2dCanvasAntialiasing[];
CONTENT_EXPORT extern const char kDisable3DAPIs[];
CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[];
diff --git a/content/public/test/mock_resource_context.cc b/content/public/test/mock_resource_context.cc
index bcea128..342766c 100644
--- a/content/public/test/mock_resource_context.cc
+++ b/content/public/test/mock_resource_context.cc
@@ -9,12 +9,12 @@
namespace content {
MockResourceContext::MockResourceContext()
- : request_context_(NULL) {
+ : test_request_context_(NULL) {
}
MockResourceContext::MockResourceContext(
- net::URLRequestContext* request_context)
- : request_context_(request_context),
+ net::URLRequestContext* test_request_context)
+ : test_request_context_(test_request_context),
mic_allowed_(false),
camera_allowed_(false) {
}
@@ -26,8 +26,8 @@ net::HostResolver* MockResourceContext::GetHostResolver() {
}
net::URLRequestContext* MockResourceContext::GetRequestContext() {
- CHECK(request_context_);
- return request_context_;
+ CHECK(test_request_context_);
+ return test_request_context_;
}
bool MockResourceContext::AllowMicAccess(const GURL& origin) {
diff --git a/content/public/test/mock_resource_context.h b/content/public/test/mock_resource_context.h
index 934b20e..8f1791a 100644
--- a/content/public/test/mock_resource_context.h
+++ b/content/public/test/mock_resource_context.h
@@ -21,7 +21,7 @@ class MockResourceContext : public ResourceContext {
MockResourceContext();
// Does not take ownership of |test_request_context|.
- explicit MockResourceContext(net::URLRequestContext* request_context);
+ explicit MockResourceContext(net::URLRequestContext* test_request_context);
virtual ~MockResourceContext();
@@ -42,7 +42,7 @@ class MockResourceContext : public ResourceContext {
}
private:
- net::URLRequestContext* request_context_;
+ net::URLRequestContext* test_request_context_;
bool mic_allowed_;
bool camera_allowed_;
diff --git a/content/public/test/test_browser_context.cc b/content/public/test/test_browser_context.cc
index b75817f..907f748 100644
--- a/content/public/test/test_browser_context.cc
+++ b/content/public/test/test_browser_context.cc
@@ -6,8 +6,6 @@
#include "base/files/file_path.h"
#include "base/test/null_task_runner.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/browser/storage_partition.h"
#include "content/public/test/mock_resource_context.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
@@ -72,7 +70,10 @@ DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
}
net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
- return GetDefaultStoragePartition(this)->GetURLRequestContext();
+ if (!request_context_.get()) {
+ request_context_ = new TestContextURLRequestContextGetter();
+ }
+ return request_context_.get();
}
net::URLRequestContextGetter*
@@ -108,7 +109,8 @@ void TestBrowserContext::RequestMIDISysExPermission(
ResourceContext* TestBrowserContext::GetResourceContext() {
if (!resource_context_)
- resource_context_.reset(new MockResourceContext());
+ resource_context_.reset(new MockResourceContext(
+ GetRequestContext()->GetURLRequestContext()));
return resource_context_.get();
}
diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc
index f3f7002..8e60a32 100644
--- a/content/shell/app/shell_main_delegate.cc
+++ b/content/shell/app/shell_main_delegate.cc
@@ -149,6 +149,8 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitch(switches::kEnableInbandTextTracks);
command_line.AppendSwitch(switches::kMuteAudio);
+ net::CookieMonster::EnableFileScheme();
+
// Unless/until WebM files are added to the media layout tests, we need to
// avoid removing MP4/H264/AAC so that layout tests can run on Android.
#if !defined(OS_ANDROID)
diff --git a/content/shell/browser/shell_browser_context.cc b/content/shell/browser/shell_browser_context.cc
index 4334b6c..c6dbb99 100644
--- a/content/shell/browser/shell_browser_context.cc
+++ b/content/shell/browser/shell_browser_context.cc
@@ -12,7 +12,6 @@
#include "base/path_service.h"
#include "base/threading/thread.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
diff --git a/content/shell/browser/shell_url_request_context_getter.cc b/content/shell/browser/shell_url_request_context_getter.cc
index 6ddfa14..dfdb852 100644
--- a/content/shell/browser/shell_url_request_context_getter.cc
+++ b/content/shell/browser/shell_url_request_context_getter.cc
@@ -12,7 +12,6 @@
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/worker_pool.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/shell/browser/shell_network_delegate.h"
@@ -102,8 +101,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
url_request_context_->set_network_delegate(network_delegate_.get());
storage_.reset(
new net::URLRequestContextStorage(url_request_context_.get()));
- storage_->set_cookie_store(
- content::CreateCookieStore(content::CookieStoreConfig()));
+ storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true)));
diff --git a/content/test/test_content_browser_client.cc b/content/test/test_content_browser_client.cc
index 9780f27..7b9d368 100644
--- a/content/test/test_content_browser_client.cc
+++ b/content/test/test_content_browser_client.cc
@@ -8,9 +8,7 @@
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "content/public/browser/browser_thread.h"
#include "content/test/test_web_contents_view.h"
-#include "net/url_request/url_request_test_util.h"
namespace content {
@@ -32,13 +30,6 @@ WebContentsViewPort* TestContentBrowserClient::OverrideCreateWebContentsView(
#endif
}
-net::URLRequestContextGetter* TestContentBrowserClient::CreateRequestContext(
- BrowserContext* browser_context,
- ProtocolHandlerMap* protocol_handlers) {
- return new net::TestURLRequestContextGetter(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
-}
-
base::FilePath TestContentBrowserClient::GetDefaultDownloadDirectory() {
if (!download_dir_.IsValid()) {
bool result = download_dir_.CreateUniqueTempDir();
diff --git a/content/test/test_content_browser_client.h b/content/test/test_content_browser_client.h
index 0182ef1..f0d58bb 100644
--- a/content/test/test_content_browser_client.h
+++ b/content/test/test_content_browser_client.h
@@ -12,10 +12,6 @@
#include "base/files/scoped_temp_dir.h"
#include "content/public/browser/content_browser_client.h"
-namespace net {
-class URLRequestContextGetter;
-} // namespace net
-
namespace content {
// Base for unit tests that need a ContentBrowserClient.
@@ -27,9 +23,6 @@ class TestContentBrowserClient : public ContentBrowserClient {
virtual WebContentsViewPort* OverrideCreateWebContentsView(
WebContents* web_contents,
RenderViewHostDelegateView** render_view_host_delegate_view) OVERRIDE;
- virtual net::URLRequestContextGetter* CreateRequestContext(
- BrowserContext* browser_context,
- ProtocolHandlerMap* protocol_handlers) OVERRIDE;
virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
private:
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index 5eda0e6..f246377 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -256,38 +256,38 @@ CookieMonster::CookieItVector::iterator LowerBoundAccessDate(
LowerBoundAccessDateComparator);
}
-// Mapping between DeletionCause and CookieMonsterDelegate::ChangeCause; the
-// mapping also provides a boolean that specifies whether or not an
-// OnCookieChanged notification ought to be generated.
+// Mapping between DeletionCause and Delegate::ChangeCause; the mapping also
+// provides a boolean that specifies whether or not an OnCookieChanged
+// notification ought to be generated.
typedef struct ChangeCausePair_struct {
- CookieMonsterDelegate::ChangeCause cause;
+ CookieMonster::Delegate::ChangeCause cause;
bool notify;
} ChangeCausePair;
ChangeCausePair ChangeCauseMapping[] = {
// DELETE_COOKIE_EXPLICIT
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, true },
// DELETE_COOKIE_OVERWRITE
- { CookieMonsterDelegate::CHANGE_COOKIE_OVERWRITE, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_OVERWRITE, true },
// DELETE_COOKIE_EXPIRED
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED, true },
// DELETE_COOKIE_EVICTED
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
// DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, false },
// DELETE_COOKIE_DONT_RECORD
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, false },
// DELETE_COOKIE_EVICTED_DOMAIN
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
// DELETE_COOKIE_EVICTED_GLOBAL
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
// DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
// DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
// DELETE_COOKIE_EXPIRED_OVERWRITE
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED_OVERWRITE, true },
+ { CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED_OVERWRITE, true },
// DELETE_COOKIE_LAST_ENTRY
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false }
+ { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, false }
};
std::string BuildCookieLine(const CanonicalCookieVector& cookies) {
@@ -308,8 +308,10 @@ std::string BuildCookieLine(const CanonicalCookieVector& cookies) {
} // namespace
-CookieMonster::CookieMonster(PersistentCookieStore* store,
- CookieMonsterDelegate* delegate)
+// static
+bool CookieMonster::default_enable_file_scheme_ = false;
+
+CookieMonster::CookieMonster(PersistentCookieStore* store, Delegate* delegate)
: initialized_(false),
loaded_(false),
store_(store),
@@ -325,7 +327,7 @@ CookieMonster::CookieMonster(PersistentCookieStore* store,
}
CookieMonster::CookieMonster(PersistentCookieStore* store,
- CookieMonsterDelegate* delegate,
+ Delegate* delegate,
int last_access_threshold_milliseconds)
: initialized_(false),
loaded_(false),
@@ -1277,6 +1279,11 @@ void CookieMonster::SetKeepExpiredCookies() {
keep_expired_cookies_ = true;
}
+// static
+void CookieMonster::EnableFileScheme() {
+ default_enable_file_scheme_ = true;
+}
+
void CookieMonster::FlushStore(const base::Closure& callback) {
base::AutoLock autolock(lock_);
if (initialized_ && store_.get())
@@ -1635,9 +1642,9 @@ const int CookieMonster::kDefaultCookieableSchemesCount =
arraysize(CookieMonster::kDefaultCookieableSchemes);
void CookieMonster::SetDefaultCookieableSchemes() {
- // Always disable file scheme unless SetEnableFileScheme(true) is called.
- SetCookieableSchemes(kDefaultCookieableSchemes,
- kDefaultCookieableSchemesCount - 1);
+ int num_schemes = default_enable_file_scheme_ ?
+ kDefaultCookieableSchemesCount : kDefaultCookieableSchemesCount - 1;
+ SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes);
}
void CookieMonster::FindCookiesForHostAndDomain(
@@ -1737,7 +1744,7 @@ void CookieMonster::InternalInsertCookie(const std::string& key,
cookies_.insert(CookieMap::value_type(key, cc));
if (delegate_.get()) {
delegate_->OnCookieChanged(
- *cc, false, CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT);
+ *cc, false, CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT);
}
}
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h
index 52ccd14..eaf89d3 100644
--- a/net/cookies/cookie_monster.h
+++ b/net/cookies/cookie_monster.h
@@ -37,7 +37,6 @@ class TimeTicks;
namespace net {
-class CookieMonsterDelegate;
class ParsedCookie;
// The cookie monster is the system for storing and retrieving cookies. It has
@@ -66,8 +65,8 @@ class ParsedCookie;
// - Verify that our domain enforcement and non-dotted handling is correct
class NET_EXPORT CookieMonster : public CookieStore {
public:
+ class Delegate;
class PersistentCookieStore;
- typedef CookieMonsterDelegate Delegate;
// Terminology:
// * The 'top level domain' (TLD) of an internet domain name is
@@ -139,11 +138,11 @@ class NET_EXPORT CookieMonster : public CookieStore {
// monster's existence. If |store| is NULL, then no backing store will be
// updated. If |delegate| is non-NULL, it will be notified on
// creation/deletion of cookies.
- CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate);
+ CookieMonster(PersistentCookieStore* store, Delegate* delegate);
// Only used during unit testing.
CookieMonster(PersistentCookieStore* store,
- CookieMonsterDelegate* delegate,
+ Delegate* delegate,
int last_access_threshold_milliseconds);
// Helper function that adds all cookies from |list| into this instance.
@@ -225,10 +224,6 @@ class NET_EXPORT CookieMonster : public CookieStore {
// Resets the list of cookieable schemes to kDefaultCookieableSchemes with or
// without 'file' being included.
- //
- // There are some unknowns about how to correctly handle file:// cookies,
- // and our implementation for this is not robust enough. This allows you
- // to enable support, but it should only be used for testing. Bug 1157243.
void SetEnableFileScheme(bool accept);
// Instructs the cookie monster to not delete expired cookies. This is used
@@ -239,6 +234,12 @@ class NET_EXPORT CookieMonster : public CookieStore {
// Protects session cookies from deletion on shutdown.
void SetForceKeepSessionState();
+ // There are some unknowns about how to correctly handle file:// cookies,
+ // and our implementation for this is not robust enough. This allows you
+ // to enable support, but it should only be used for testing. Bug 1157243.
+ // Must be called before creating a CookieMonster instance.
+ static void EnableFileScheme();
+
// Flush the backing store (if any) to disk and post the given callback when
// done.
// WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE.
@@ -351,8 +352,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
// and to provide a public cause for onCookieChange notifications.
//
// If you add or remove causes from this list, please be sure to also update
- // the CookieMonsterDelegate::ChangeCause mapping inside ChangeCauseMapping.
- // Moreover, these are used as array indexes, so avoid reordering to keep the
+ // the Delegate::ChangeCause mapping inside ChangeCauseMapping. Moreover,
+ // these are used as array indexes, so avoid reordering to keep the
// histogram buckets consistent. New items (if necessary) should be added
// at the end of the list, just before DELETE_COOKIE_LAST_ENTRY.
enum DeletionCause {
@@ -539,8 +540,7 @@ class NET_EXPORT CookieMonster : public CookieStore {
const base::Time& current_time);
// |deletion_cause| argument is used for collecting statistics and choosing
- // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged
- // notifications.
+ // the correct Delegate::ChangeCause for OnCookieChanged notifications.
void InternalDeleteCookie(CookieMap::iterator it, bool sync_to_store,
DeletionCause deletion_cause);
@@ -662,7 +662,7 @@ class NET_EXPORT CookieMonster : public CookieStore {
std::vector<std::string> cookieable_schemes_;
- scoped_refptr<CookieMonsterDelegate> delegate_;
+ scoped_refptr<Delegate> delegate_;
// Lock for thread-safety
base::Lock lock_;
@@ -681,8 +681,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
DISALLOW_COPY_AND_ASSIGN(CookieMonster);
};
-class NET_EXPORT CookieMonsterDelegate
- : public base::RefCountedThreadSafe<CookieMonsterDelegate> {
+class NET_EXPORT CookieMonster::Delegate
+ : public base::RefCountedThreadSafe<CookieMonster::Delegate> {
public:
// The publicly relevant reasons a cookie might be changed.
enum ChangeCause {
@@ -714,8 +714,8 @@ class NET_EXPORT CookieMonsterDelegate
bool removed,
ChangeCause cause) = 0;
protected:
- friend class base::RefCountedThreadSafe<CookieMonsterDelegate>;
- virtual ~CookieMonsterDelegate() {}
+ friend class base::RefCountedThreadSafe<CookieMonster::Delegate>;
+ virtual ~Delegate() {}
};
typedef base::RefCountedThreadSafe<CookieMonster::PersistentCookieStore>
diff --git a/net/cookies/cookie_monster_store_test.h b/net/cookies/cookie_monster_store_test.h
index ec40de6..d7da521 100644
--- a/net/cookies/cookie_monster_store_test.h
+++ b/net/cookies/cookie_monster_store_test.h
@@ -115,8 +115,8 @@ class MockPersistentCookieStore
DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore);
};
-// Mock for CookieMonsterDelegate
-class MockCookieMonsterDelegate : public CookieMonsterDelegate {
+// Mock for CookieMonster::Delegate
+class MockCookieMonsterDelegate : public CookieMonster::Delegate {
public:
typedef std::pair<CanonicalCookie, bool>
CookieNotification;
@@ -130,7 +130,7 @@ class MockCookieMonsterDelegate : public CookieMonsterDelegate {
virtual void OnCookieChanged(
const CanonicalCookie& cookie,
bool removed,
- CookieMonsterDelegate::ChangeCause cause) OVERRIDE;
+ CookieMonster::Delegate::ChangeCause cause) OVERRIDE;
private:
virtual ~MockCookieMonsterDelegate();
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index 11607b4..d1ce04f 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -1549,7 +1549,7 @@ TEST_F(CookieMonsterTest, DontImportDuplicateCreationTimes) {
EXPECT_NE(name1, name2);
}
-TEST_F(CookieMonsterTest, CookieMonsterDelegate) {
+TEST_F(CookieMonsterTest, Delegate) {
scoped_refptr<MockPersistentCookieStore> store(
new MockPersistentCookieStore);
scoped_refptr<MockCookieMonsterDelegate> delegate(
diff --git a/net/cookies/cookie_store.h b/net/cookies/cookie_store.h
index c773e2d..af99637 100644
--- a/net/cookies/cookie_store.h
+++ b/net/cookies/cookie_store.h
@@ -33,6 +33,7 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
typedef base::Callback<void(bool success)> SetCookiesCallback;
typedef base::Callback<void(int num_deleted)> DeleteCallback;
+
// Sets a single cookie. Expects a cookie line, like "a=1; domain=b.com".
//
// Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc
index e8e3dd0..276a10e 100644
--- a/webkit/support/test_webkit_platform_support.cc
+++ b/webkit/support/test_webkit_platform_support.cc
@@ -96,6 +96,8 @@ TestWebKitPlatformSupport::TestWebKitPlatformSupport() {
SetThemeEngine(NULL);
#endif
+ net::CookieMonster::EnableFileScheme();
+
// Test shell always exposes the GC.
webkit_glue::SetJavaScriptFlags(" --expose-gc");
}