| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 default_request_context_ = this; | 147 default_request_context_ = this; |
| 148 NotificationService::current()->Notify( | 148 NotificationService::current()->Notify( |
| 149 NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE, | 149 NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE, |
| 150 NotificationService::AllSources(), NotificationService::NoDetails()); | 150 NotificationService::AllSources(), NotificationService::NoDetails()); |
| 151 | 151 |
| 152 // Register for notifications about prefs. | 152 // Register for notifications about prefs. |
| 153 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); | 153 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); |
| 154 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); | 154 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); |
| 155 } | 155 } |
| 156 | 156 |
| 157 const std::string& GetUserAgent( | 157 const std::string& GetUserAgent(const GURL& url) const { |
| 158 const GURL& url) const { | |
| 159 return webkit_glue::GetUserAgent(url); | 158 return webkit_glue::GetUserAgent(url); |
| 160 } | 159 } |
| 161 | 160 |
| 162 // NotificationObserver implementation. | 161 // NotificationObserver implementation. |
| 163 virtual void Observe(NotificationType type, | 162 virtual void Observe(NotificationType type, |
| 164 const NotificationSource& source, | 163 const NotificationSource& source, |
| 165 const NotificationDetails& details) { | 164 const NotificationDetails& details) { |
| 166 if (NOTIFY_PREF_CHANGED == type) { | 165 if (NOTIFY_PREF_CHANGED == type) { |
| 167 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); | 166 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); |
| 168 PrefService* prefs = Source<PrefService>(source).ptr(); | 167 PrefService* prefs = Source<PrefService>(source).ptr(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 prefs_->GetInteger(prefs::kCookieBehavior))); | 255 prefs_->GetInteger(prefs::kCookieBehavior))); |
| 257 accept_language_ = original_context_->accept_language(); | 256 accept_language_ = original_context_->accept_language(); |
| 258 accept_charset_ = original_context_->accept_charset(); | 257 accept_charset_ = original_context_->accept_charset(); |
| 259 is_off_the_record_ = true; | 258 is_off_the_record_ = true; |
| 260 | 259 |
| 261 // Register for notifications about prefs. | 260 // Register for notifications about prefs. |
| 262 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); | 261 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); |
| 263 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); | 262 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); |
| 264 } | 263 } |
| 265 | 264 |
| 265 const std::string& GetUserAgent(const GURL& url) const { |
| 266 return original_context_->GetUserAgent(url); |
| 267 } |
| 268 |
| 266 // Since OffTheRecordProfileImpl maybe be destroyed after destroying | 269 // Since OffTheRecordProfileImpl maybe be destroyed after destroying |
| 267 // PrefService, but all PrefService observers are needed to clear in | 270 // PrefService, but all PrefService observers are needed to clear in |
| 268 // before destroying PrefService. So we use to CleanupBeforeDestroy | 271 // before destroying PrefService. So we use to CleanupBeforeDestroy |
| 269 // to do this thing. This function need to be called on destructor | 272 // to do this thing. This function need to be called on destructor |
| 270 // of ProfileImpl. | 273 // of ProfileImpl. |
| 271 void CleanupBeforeDestroy() { | 274 void CleanupBeforeDestroy() { |
| 272 // Unregister for pref notifications. | 275 // Unregister for pref notifications. |
| 273 prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this); | 276 prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this); |
| 274 prefs_->RemovePrefObserver(prefs::kCookieBehavior, this); | 277 prefs_->RemovePrefObserver(prefs::kCookieBehavior, this); |
| 275 prefs_ = NULL; | 278 prefs_ = NULL; |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 } | 973 } |
| 971 | 974 |
| 972 #ifdef CHROME_PERSONALIZATION | 975 #ifdef CHROME_PERSONALIZATION |
| 973 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 976 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
| 974 if (!personalization_.get()) | 977 if (!personalization_.get()) |
| 975 personalization_.reset( | 978 personalization_.reset( |
| 976 Personalization::CreateProfilePersonalization(this)); | 979 Personalization::CreateProfilePersonalization(this)); |
| 977 return personalization_.get(); | 980 return personalization_.get(); |
| 978 } | 981 } |
| 979 #endif | 982 #endif |
| OLD | NEW |