diff options
Diffstat (limited to 'chrome/test/testing_profile.cc')
-rw-r--r-- | chrome/test/testing_profile.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 27708f2..f9d4924 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -7,6 +7,7 @@ #include "build/build_config.h" #include "base/command_line.h" #include "base/string_util.h" +#include "chrome/common/url_constants.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/dom_ui/ntp_resource_cache.h" #include "chrome/browser/history/history_backend.h" @@ -109,6 +110,28 @@ class TestURLRequestContextGetter : public URLRequestContextGetter { scoped_refptr<URLRequestContext> context_; }; +class TestExtensionURLRequestContext : public URLRequestContext { + public: + TestExtensionURLRequestContext() { + net::CookieMonster* cookie_monster = new net::CookieMonster(NULL); + const char* schemes[] = {chrome::kExtensionScheme}; + cookie_monster->SetCookieableSchemes(schemes, 1); + cookie_store_ = cookie_monster; + } +}; + +class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { + public: + virtual URLRequestContext* GetURLRequestContext() { + if (!context_) + context_ = new TestExtensionURLRequestContext(); + return context_.get(); + } + + private: + scoped_refptr<URLRequestContext> context_; +}; + } // namespace TestingProfile::TestingProfile() @@ -277,6 +300,12 @@ void TestingProfile::CreateRequestContext() { request_context_ = new TestURLRequestContextGetter(); } +URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { + if (!extensions_request_context_) + extensions_request_context_ = new TestExtensionURLRequestContextGetter(); + return extensions_request_context_.get(); +} + void TestingProfile::set_session_service(SessionService* session_service) { session_service_ = session_service; } |