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

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "chrome/browser/history/top_sites.h" 46 #include "chrome/browser/history/top_sites.h"
47 #include "chrome/browser/metrics/metrics_service.h" 47 #include "chrome/browser/metrics/metrics_service.h"
48 #include "chrome/browser/net/chrome_url_request_context.h" 48 #include "chrome/browser/net/chrome_url_request_context.h"
49 #include "chrome/browser/net/net_pref_observer.h" 49 #include "chrome/browser/net/net_pref_observer.h"
50 #include "chrome/browser/net/predictor.h" 50 #include "chrome/browser/net/predictor.h"
51 #include "chrome/browser/net/proxy_service_factory.h" 51 #include "chrome/browser/net/proxy_service_factory.h"
52 #include "chrome/browser/net/ssl_config_service_manager.h" 52 #include "chrome/browser/net/ssl_config_service_manager.h"
53 #include "chrome/browser/net/url_fixer_upper.h" 53 #include "chrome/browser/net/url_fixer_upper.h"
54 #include "chrome/browser/plugins/plugin_prefs.h" 54 #include "chrome/browser/plugins/plugin_prefs.h"
55 #include "chrome/browser/prefs/browser_prefs.h" 55 #include "chrome/browser/prefs/browser_prefs.h"
56 #include "chrome/browser/prefs/chrome_pref_service_builder.h" 56 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
57 #include "chrome/browser/prefs/scoped_user_pref_update.h" 57 #include "chrome/browser/prefs/scoped_user_pref_update.h"
58 #include "chrome/browser/prerender/prerender_manager_factory.h" 58 #include "chrome/browser/prerender/prerender_manager_factory.h"
59 #include "chrome/browser/profiles/chrome_version_service.h" 59 #include "chrome/browser/profiles/chrome_version_service.h"
60 #include "chrome/browser/profiles/gaia_info_update_service.h" 60 #include "chrome/browser/profiles/gaia_info_update_service.h"
61 #include "chrome/browser/profiles/profile_dependency_manager.h" 61 #include "chrome/browser/profiles/profile_dependency_manager.h"
62 #include "chrome/browser/profiles/profile_destroyer.h" 62 #include "chrome/browser/profiles/profile_destroyer.h"
63 #include "chrome/browser/profiles/profile_info_cache.h" 63 #include "chrome/browser/profiles/profile_info_cache.h"
64 #include "chrome/browser/profiles/profile_manager.h" 64 #include "chrome/browser/profiles/profile_manager.h"
65 #include "chrome/browser/search_engines/template_url_fetcher.h" 65 #include "chrome/browser/search_engines/template_url_fetcher.h"
66 #include "chrome/browser/sessions/session_service_factory.h" 66 #include "chrome/browser/sessions/session_service_factory.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 return new ProfileImpl(path, delegate, create_mode, sequenced_task_runner); 262 return new ProfileImpl(path, delegate, create_mode, sequenced_task_runner);
263 } 263 }
264 264
265 // static 265 // static
266 int ProfileImpl::create_readme_delay_ms = 60000; 266 int ProfileImpl::create_readme_delay_ms = 60000;
267 267
268 // static 268 // static
269 const char* const ProfileImpl::kPrefExitTypeNormal = "Normal"; 269 const char* const ProfileImpl::kPrefExitTypeNormal = "Normal";
270 270
271 // static 271 // static
272 void ProfileImpl::RegisterUserPrefs(PrefService* prefs) { 272 void ProfileImpl::RegisterUserPrefs(PrefServiceSyncable* prefs) {
273 prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled, 273 prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled,
274 false, 274 false,
275 PrefService::UNSYNCABLE_PREF); 275 PrefServiceSyncable::UNSYNCABLE_PREF);
276 prefs->RegisterBooleanPref(prefs::kForceSafeSearch, 276 prefs->RegisterBooleanPref(prefs::kForceSafeSearch,
277 false, 277 false,
278 PrefService::UNSYNCABLE_PREF); 278 PrefServiceSyncable::UNSYNCABLE_PREF);
279 prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex, 279 prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex,
280 -1, 280 -1,
281 PrefService::SYNCABLE_PREF); 281 PrefServiceSyncable::SYNCABLE_PREF);
282 prefs->RegisterStringPref(prefs::kProfileName, 282 prefs->RegisterStringPref(prefs::kProfileName,
283 "", 283 "",
284 PrefService::SYNCABLE_PREF); 284 PrefServiceSyncable::SYNCABLE_PREF);
285 prefs->RegisterBooleanPref(prefs::kProfileIsManaged, 285 prefs->RegisterBooleanPref(prefs::kProfileIsManaged,
286 false, 286 false,
287 PrefService::SYNCABLE_PREF); 287 PrefServiceSyncable::SYNCABLE_PREF);
288 prefs->RegisterStringPref(prefs::kHomePage, 288 prefs->RegisterStringPref(prefs::kHomePage,
289 std::string(), 289 std::string(),
290 PrefService::SYNCABLE_PREF); 290 PrefServiceSyncable::SYNCABLE_PREF);
291 #if defined(ENABLE_PRINTING) 291 #if defined(ENABLE_PRINTING)
292 prefs->RegisterBooleanPref(prefs::kPrintingEnabled, 292 prefs->RegisterBooleanPref(prefs::kPrintingEnabled,
293 true, 293 true,
294 PrefService::UNSYNCABLE_PREF); 294 PrefServiceSyncable::UNSYNCABLE_PREF);
295 #endif 295 #endif
296 prefs->RegisterBooleanPref(prefs::kPrintPreviewDisabled, 296 prefs->RegisterBooleanPref(prefs::kPrintPreviewDisabled,
297 #if defined(GOOGLE_CHROME_BUILD) 297 #if defined(GOOGLE_CHROME_BUILD)
298 false, 298 false,
299 #else 299 #else
300 true, 300 true,
301 #endif 301 #endif
302 PrefService::UNSYNCABLE_PREF); 302 PrefServiceSyncable::UNSYNCABLE_PREF);
303 303
304 // Initialize the cache prefs. 304 // Initialize the cache prefs.
305 prefs->RegisterFilePathPref(prefs::kDiskCacheDir, 305 prefs->RegisterFilePathPref(prefs::kDiskCacheDir,
306 FilePath(), 306 FilePath(),
307 PrefService::UNSYNCABLE_PREF); 307 PrefServiceSyncable::UNSYNCABLE_PREF);
308 prefs->RegisterIntegerPref(prefs::kDiskCacheSize, 308 prefs->RegisterIntegerPref(prefs::kDiskCacheSize,
309 0, 309 0,
310 PrefService::UNSYNCABLE_PREF); 310 PrefServiceSyncable::UNSYNCABLE_PREF);
311 prefs->RegisterIntegerPref(prefs::kMediaCacheSize, 311 prefs->RegisterIntegerPref(prefs::kMediaCacheSize,
312 0, 312 0,
313 PrefService::UNSYNCABLE_PREF); 313 PrefServiceSyncable::UNSYNCABLE_PREF);
314 314
315 // Deprecated. Kept around for migration. 315 // Deprecated. Kept around for migration.
316 prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit, 316 prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
317 false, 317 false,
318 PrefService::SYNCABLE_PREF); 318 PrefServiceSyncable::SYNCABLE_PREF);
319 } 319 }
320 320
321 ProfileImpl::ProfileImpl( 321 ProfileImpl::ProfileImpl(
322 const FilePath& path, 322 const FilePath& path,
323 Delegate* delegate, 323 Delegate* delegate,
324 CreateMode create_mode, 324 CreateMode create_mode,
325 base::SequencedTaskRunner* sequenced_task_runner) 325 base::SequencedTaskRunner* sequenced_task_runner)
326 : path_(path), 326 : path_(path),
327 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 327 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
328 host_content_settings_map_(NULL), 328 host_content_settings_map_(NULL),
(...skipping 17 matching lines...) Expand all
346 !command_line->HasSwitch(switches::kDisablePreconnect), 346 !command_line->HasSwitch(switches::kDisablePreconnect),
347 g_browser_process->profile_manager() == NULL); 347 g_browser_process->profile_manager() == NULL);
348 348
349 #if defined(ENABLE_CONFIGURATION_POLICY) 349 #if defined(ENABLE_CONFIGURATION_POLICY)
350 // If we are creating the profile synchronously, then we should load the 350 // If we are creating the profile synchronously, then we should load the
351 // policy data immediately. 351 // policy data immediately.
352 bool force_immediate_policy_load = (create_mode == CREATE_MODE_SYNCHRONOUS); 352 bool force_immediate_policy_load = (create_mode == CREATE_MODE_SYNCHRONOUS);
353 353
354 // TODO(atwilson): Change |cloud_policy_manager_| and 354 // TODO(atwilson): Change |cloud_policy_manager_| and
355 // |managed_mode_policy_provider_| to proper ProfileKeyedServices once 355 // |managed_mode_policy_provider_| to proper ProfileKeyedServices once
356 // PrefService is a ProfileKeyedService (policy must be initialized before 356 // PrefServiceSyncable is a ProfileKeyedService (policy must be initialized
357 // PrefService because PrefService depends on policy loading to get overridden 357 // before PrefServiceSyncable because PrefServiceSyncable depends on policy
358 // pref values). 358 // loading to get overridden pref values).
359 #if !defined(OS_CHROMEOS) 359 #if !defined(OS_CHROMEOS)
360 if (command_line->HasSwitch(switches::kLoadCloudPolicyOnSignin)) { 360 if (command_line->HasSwitch(switches::kLoadCloudPolicyOnSignin)) {
361 cloud_policy_manager_ = 361 cloud_policy_manager_ =
362 policy::UserCloudPolicyManagerFactory::CreateForProfile( 362 policy::UserCloudPolicyManagerFactory::CreateForProfile(
363 this, force_immediate_policy_load); 363 this, force_immediate_policy_load);
364 cloud_policy_manager_->Init(); 364 cloud_policy_manager_->Init();
365 } 365 }
366 #endif 366 #endif
367 managed_mode_policy_provider_ = 367 managed_mode_policy_provider_ =
368 policy::ManagedModePolicyProvider::Create(this, 368 policy::ManagedModePolicyProvider::Create(this,
369 sequenced_task_runner, 369 sequenced_task_runner,
370 force_immediate_policy_load); 370 force_immediate_policy_load);
371 managed_mode_policy_provider_->Init(); 371 managed_mode_policy_provider_->Init();
372 policy_service_ = 372 policy_service_ =
373 g_browser_process->browser_policy_connector()->CreatePolicyService(this); 373 g_browser_process->browser_policy_connector()->CreatePolicyService(this);
374 #else 374 #else
375 policy_service_.reset(new policy::PolicyServiceStub()); 375 policy_service_.reset(new policy::PolicyServiceStub());
376 #endif 376 #endif
377 377
378 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS || 378 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS ||
379 create_mode == CREATE_MODE_SYNCHRONOUS); 379 create_mode == CREATE_MODE_SYNCHRONOUS);
380 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS; 380 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS;
381 prefs_.reset(ChromePrefServiceBuilder().CreateChromePrefs( 381 prefs_.reset(chrome_prefs::CreateProfilePrefs(
382 GetPrefFilePath(), 382 GetPrefFilePath(),
383 sequenced_task_runner, 383 sequenced_task_runner,
384 policy_service_.get(), 384 policy_service_.get(),
385 new ExtensionPrefStore( 385 new ExtensionPrefStore(
386 ExtensionPrefValueMapFactory::GetForProfile(this), false), 386 ExtensionPrefValueMapFactory::GetForProfile(this), false),
387 async_prefs)); 387 async_prefs));
388 if (async_prefs) { 388 if (async_prefs) {
389 // Wait for the notification that prefs has been loaded 389 // Wait for the notification that prefs has been loaded
390 // (successfully or not). Note that we can use base::Unretained 390 // (successfully or not). Note that we can use base::Unretained
391 // because the PrefService is owned by this class and lives on 391 // because the PrefService is owned by this class and lives on
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 #else 768 #else
769 return NULL; 769 return NULL;
770 #endif 770 #endif
771 } 771 }
772 772
773 policy::PolicyService* ProfileImpl::GetPolicyService() { 773 policy::PolicyService* ProfileImpl::GetPolicyService() {
774 DCHECK(policy_service_.get()); // Should explicitly be initialized. 774 DCHECK(policy_service_.get()); // Should explicitly be initialized.
775 return policy_service_.get(); 775 return policy_service_.get();
776 } 776 }
777 777
778 PrefService* ProfileImpl::GetPrefs() { 778 PrefServiceSyncable* ProfileImpl::GetPrefs() {
779 DCHECK(prefs_.get()); // Should explicitly be initialized. 779 DCHECK(prefs_.get()); // Should explicitly be initialized.
780 return prefs_.get(); 780 return prefs_.get();
781 } 781 }
782 782
783 PrefService* ProfileImpl::GetOffTheRecordPrefs() { 783 PrefServiceSyncable* ProfileImpl::GetOffTheRecordPrefs() {
784 if (!otr_prefs_.get()) { 784 if (!otr_prefs_.get()) {
785 // The new ExtensionPrefStore is ref_counted and the new PrefService 785 // The new ExtensionPrefStore is ref_counted and the new PrefService
786 // stores a reference so that we do not leak memory here. 786 // stores a reference so that we do not leak memory here.
787 otr_prefs_.reset(GetPrefs()->CreateIncognitoPrefService( 787 otr_prefs_.reset(GetPrefs()->CreateIncognitoPrefService(
788 new ExtensionPrefStore( 788 new ExtensionPrefStore(
789 ExtensionPrefValueMapFactory::GetForProfile(this), true))); 789 ExtensionPrefValueMapFactory::GetForProfile(this), true)));
790 } 790 }
791 return otr_prefs_.get(); 791 return otr_prefs_.get();
792 } 792 }
793 793
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 if (!path.empty()) 1155 if (!path.empty())
1156 *cache_path = path; 1156 *cache_path = path;
1157 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1157 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1158 prefs_->GetInteger(prefs::kDiskCacheSize); 1158 prefs_->GetInteger(prefs::kDiskCacheSize);
1159 } 1159 }
1160 1160
1161 base::Callback<ChromeURLDataManagerBackend*(void)> 1161 base::Callback<ChromeURLDataManagerBackend*(void)>
1162 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1162 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1163 return io_data_.GetChromeURLDataManagerBackendGetter(); 1163 return io_data_.GetChromeURLDataManagerBackendGetter();
1164 } 1164 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698