Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/profile.h" | 5 #include "chrome/browser/profile.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/lock.h" | 9 #include "base/lock.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 public NotificationObserver { | 98 public NotificationObserver { |
| 99 public: | 99 public: |
| 100 // |cookie_store_path| is the local disk path at which the cookie store | 100 // |cookie_store_path| is the local disk path at which the cookie store |
| 101 // is persisted. | 101 // is persisted. |
| 102 RequestContext(const std::wstring& cookie_store_path, | 102 RequestContext(const std::wstring& cookie_store_path, |
| 103 const std::wstring& disk_cache_path, | 103 const std::wstring& disk_cache_path, |
| 104 PrefService* prefs) | 104 PrefService* prefs) |
| 105 : prefs_(prefs) { | 105 : prefs_(prefs) { |
| 106 cookie_store_ = NULL; | 106 cookie_store_ = NULL; |
| 107 | 107 |
| 108 // setup user agent | |
| 109 user_agent_ = webkit_glue::GetUserAgent(); | |
| 110 // set up Accept-Language and Accept-Charset header values | 108 // set up Accept-Language and Accept-Charset header values |
| 111 // TODO(jungshik) : This may slow down http requests. Perhaps, | 109 // TODO(jungshik) : This may slow down http requests. Perhaps, |
| 112 // we have to come up with a better way to set up these values. | 110 // we have to come up with a better way to set up these values. |
| 113 accept_language_ = WideToASCII(prefs_->GetString(prefs::kAcceptLanguages)); | 111 accept_language_ = WideToASCII(prefs_->GetString(prefs::kAcceptLanguages)); |
| 114 accept_charset_ = WideToASCII(prefs_->GetString(prefs::kDefaultCharset)); | 112 accept_charset_ = WideToASCII(prefs_->GetString(prefs::kDefaultCharset)); |
| 115 accept_charset_ += ",*,utf-8"; | 113 accept_charset_ += ",*,utf-8"; |
| 116 | 114 |
| 117 CommandLine command_line; | 115 CommandLine command_line; |
| 118 | 116 |
| 119 scoped_ptr<net::ProxyInfo> proxy_info(CreateProxyInfo(command_line)); | 117 scoped_ptr<net::ProxyInfo> proxy_info(CreateProxyInfo(command_line)); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 149 default_request_context_ = this; | 147 default_request_context_ = this; |
| 150 NotificationService::current()->Notify( | 148 NotificationService::current()->Notify( |
| 151 NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE, | 149 NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE, |
| 152 NotificationService::AllSources(), NotificationService::NoDetails()); | 150 NotificationService::AllSources(), NotificationService::NoDetails()); |
| 153 | 151 |
| 154 // Register for notifications about prefs. | 152 // Register for notifications about prefs. |
| 155 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); | 153 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); |
| 156 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); | 154 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); |
| 157 } | 155 } |
| 158 | 156 |
| 157 const std::string& GetUserAgent( | |
|
darin (slow to review)
2009/01/28 09:15:01
nit: the line break here should probably be remove
| |
| 158 const GURL& url) const { | |
| 159 return webkit_glue::GetUserAgent(url); | |
| 160 } | |
| 161 | |
| 159 // NotificationObserver implementation. | 162 // NotificationObserver implementation. |
| 160 virtual void Observe(NotificationType type, | 163 virtual void Observe(NotificationType type, |
| 161 const NotificationSource& source, | 164 const NotificationSource& source, |
| 162 const NotificationDetails& details) { | 165 const NotificationDetails& details) { |
| 163 if (NOTIFY_PREF_CHANGED == type) { | 166 if (NOTIFY_PREF_CHANGED == type) { |
| 164 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); | 167 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); |
| 165 PrefService* prefs = Source<PrefService>(source).ptr(); | 168 PrefService* prefs = Source<PrefService>(source).ptr(); |
| 166 DCHECK(pref_name_in && prefs); | 169 DCHECK(pref_name_in && prefs); |
| 167 if (*pref_name_in == prefs::kAcceptLanguages) { | 170 if (*pref_name_in == prefs::kAcceptLanguages) { |
| 168 std::string accept_language = | 171 std::string accept_language = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 // context to make sure it doesn't go away when we delete the object graph. | 247 // context to make sure it doesn't go away when we delete the object graph. |
| 245 original_context_ = profile->GetRequestContext(); | 248 original_context_ = profile->GetRequestContext(); |
| 246 | 249 |
| 247 CommandLine command_line; | 250 CommandLine command_line; |
| 248 scoped_ptr<net::ProxyInfo> proxy_info(CreateProxyInfo(command_line)); | 251 scoped_ptr<net::ProxyInfo> proxy_info(CreateProxyInfo(command_line)); |
| 249 | 252 |
| 250 http_transaction_factory_ = new net::HttpCache(NULL, 0); | 253 http_transaction_factory_ = new net::HttpCache(NULL, 0); |
| 251 cookie_store_ = new net::CookieMonster; | 254 cookie_store_ = new net::CookieMonster; |
| 252 cookie_policy_.SetType(net::CookiePolicy::FromInt( | 255 cookie_policy_.SetType(net::CookiePolicy::FromInt( |
| 253 prefs_->GetInteger(prefs::kCookieBehavior))); | 256 prefs_->GetInteger(prefs::kCookieBehavior))); |
| 254 user_agent_ = original_context_->user_agent(); | |
| 255 accept_language_ = original_context_->accept_language(); | 257 accept_language_ = original_context_->accept_language(); |
| 256 accept_charset_ = original_context_->accept_charset(); | 258 accept_charset_ = original_context_->accept_charset(); |
| 257 is_off_the_record_ = true; | 259 is_off_the_record_ = true; |
| 258 | 260 |
| 259 // Register for notifications about prefs. | 261 // Register for notifications about prefs. |
| 260 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); | 262 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); |
| 261 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); | 263 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); |
| 262 } | 264 } |
| 263 | 265 |
| 264 // Since OffTheRecordProfileImpl maybe be destroyed after destroying | 266 // Since OffTheRecordProfileImpl maybe be destroyed after destroying |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 } | 970 } |
| 969 | 971 |
| 970 #ifdef CHROME_PERSONALIZATION | 972 #ifdef CHROME_PERSONALIZATION |
| 971 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 973 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
| 972 if (!personalization_.get()) | 974 if (!personalization_.get()) |
| 973 personalization_.reset( | 975 personalization_.reset( |
| 974 Personalization::CreateProfilePersonalization(this)); | 976 Personalization::CreateProfilePersonalization(this)); |
| 975 return personalization_.get(); | 977 return personalization_.get(); |
| 976 } | 978 } |
| 977 #endif | 979 #endif |
| OLD | NEW |