Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Unified Diff: trunk/src/chrome/browser/profiles/profile_io_data.cc

Issue 23551005: Revert 219709 "Remove the Extensions URLRequestContext." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/profiles/profile_io_data.cc
===================================================================
--- trunk/src/chrome/browser/profiles/profile_io_data.cc (revision 219785)
+++ trunk/src/chrome/browser/profiles/profile_io_data.cc (working copy)
@@ -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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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(
« no previous file with comments | « trunk/src/chrome/browser/profiles/profile_io_data.h ('k') | trunk/src/chrome/browser/profiles/profile_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698