OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/privacy_blacklist/blacklist.h" | 10 #include "chrome/browser/privacy_blacklist/blacklist.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/extensions/extensions_service.h" | 12 #include "chrome/browser/extensions/extensions_service.h" |
13 #include "chrome/browser/extensions/user_script_master.h" | 13 #include "chrome/browser/extensions/user_script_master.h" |
| 14 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
14 #include "chrome/browser/net/dns_global.h" | 15 #include "chrome/browser/net/dns_global.h" |
15 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
22 #include "net/ftp/ftp_network_layer.h" | 23 #include "net/ftp/ftp_network_layer.h" |
23 #include "net/http/http_cache.h" | 24 #include "net/http/http_cache.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 context->ftp_transaction_factory_ = | 152 context->ftp_transaction_factory_ = |
152 new net::FtpNetworkLayer(context->host_resolver_); | 153 new net::FtpNetworkLayer(context->host_resolver_); |
153 #endif | 154 #endif |
154 | 155 |
155 // setup cookie store | 156 // setup cookie store |
156 if (!context->cookie_store_) { | 157 if (!context->cookie_store_) { |
157 DCHECK(!cookie_store_path.empty()); | 158 DCHECK(!cookie_store_path.empty()); |
158 | 159 |
159 scoped_refptr<SQLitePersistentCookieStore> cookie_db = | 160 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
160 new SQLitePersistentCookieStore( | 161 new SQLitePersistentCookieStore( |
161 cookie_store_path.ToWStringHack(), | 162 cookie_store_path, |
162 g_browser_process->db_thread()->message_loop()); | 163 g_browser_process->db_thread()->message_loop()); |
163 context->cookie_store_ = new net::CookieMonster(cookie_db.get()); | 164 context->cookie_store_ = new net::CookieMonster(cookie_db.get()); |
164 } | 165 } |
165 | 166 |
166 return context; | 167 return context; |
167 } | 168 } |
168 | 169 |
169 // static | 170 // static |
170 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( | 171 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( |
171 Profile* profile, const FilePath& disk_cache_path, int cache_size) { | 172 Profile* profile, const FilePath& disk_cache_path, int cache_size) { |
172 DCHECK(!profile->IsOffTheRecord()); | 173 DCHECK(!profile->IsOffTheRecord()); |
173 return CreateRequestContextForMedia(profile, disk_cache_path, cache_size, | 174 return CreateRequestContextForMedia(profile, disk_cache_path, cache_size, |
174 false); | 175 false); |
175 } | 176 } |
176 | 177 |
177 // static | 178 // static |
178 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForExtensions( | 179 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForExtensions( |
179 Profile* profile, const FilePath& cookie_store_path) { | 180 Profile* profile, const FilePath& cookie_store_path) { |
180 DCHECK(!profile->IsOffTheRecord()); | 181 DCHECK(!profile->IsOffTheRecord()); |
181 ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); | 182 ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); |
182 | 183 |
183 // All we care about for extensions is the cookie store. | 184 // All we care about for extensions is the cookie store. |
184 DCHECK(!cookie_store_path.empty()); | 185 DCHECK(!cookie_store_path.empty()); |
185 | 186 |
186 scoped_refptr<SQLitePersistentCookieStore> cookie_db = | 187 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
187 new SQLitePersistentCookieStore( | 188 new SQLitePersistentCookieStore( |
188 cookie_store_path.ToWStringHack(), | 189 cookie_store_path, |
189 g_browser_process->db_thread()->message_loop()); | 190 g_browser_process->db_thread()->message_loop()); |
190 net::CookieMonster* cookie_monster = new net::CookieMonster(cookie_db.get()); | 191 net::CookieMonster* cookie_monster = new net::CookieMonster(cookie_db.get()); |
191 | 192 |
192 // Enable cookies for extension URLs only. | 193 // Enable cookies for extension URLs only. |
193 const char* schemes[] = {chrome::kExtensionScheme}; | 194 const char* schemes[] = {chrome::kExtensionScheme}; |
194 cookie_monster->SetCookieableSchemes(schemes, 1); | 195 cookie_monster->SetCookieableSchemes(schemes, 1); |
195 context->cookie_store_ = cookie_monster; | 196 context->cookie_store_ = cookie_monster; |
196 | 197 |
197 return context; | 198 return context; |
198 } | 199 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 DCHECK(NULL == prefs_); | 540 DCHECK(NULL == prefs_); |
540 | 541 |
541 NotificationService::current()->Notify( | 542 NotificationService::current()->Notify( |
542 NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 543 NotificationType::URL_REQUEST_CONTEXT_RELEASED, |
543 Source<URLRequestContext>(this), | 544 Source<URLRequestContext>(this), |
544 NotificationService::NoDetails()); | 545 NotificationService::NoDetails()); |
545 | 546 |
546 delete ftp_transaction_factory_; | 547 delete ftp_transaction_factory_; |
547 delete http_transaction_factory_; | 548 delete http_transaction_factory_; |
548 } | 549 } |
OLD | NEW |