OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_impl.h" | 5 #include "chrome/browser/profile_impl.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "chrome/browser/instant/instant_controller.h" | 49 #include "chrome/browser/instant/instant_controller.h" |
50 #include "chrome/browser/in_process_webkit/webkit_context.h" | 50 #include "chrome/browser/in_process_webkit/webkit_context.h" |
51 #include "chrome/browser/net/chrome_url_request_context.h" | 51 #include "chrome/browser/net/chrome_url_request_context.h" |
52 #include "chrome/browser/net/gaia/token_service.h" | 52 #include "chrome/browser/net/gaia/token_service.h" |
53 #include "chrome/browser/net/net_pref_observer.h" | 53 #include "chrome/browser/net/net_pref_observer.h" |
54 #include "chrome/browser/net/ssl_config_service_manager.h" | 54 #include "chrome/browser/net/ssl_config_service_manager.h" |
55 #include "chrome/browser/notifications/desktop_notification_service.h" | 55 #include "chrome/browser/notifications/desktop_notification_service.h" |
56 #include "chrome/browser/password_manager/password_store_default.h" | 56 #include "chrome/browser/password_manager/password_store_default.h" |
57 #include "chrome/browser/policy/configuration_policy_provider.h" | 57 #include "chrome/browser/policy/configuration_policy_provider.h" |
58 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 58 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
59 #include "chrome/browser/policy/device_management_backend_impl.h" | 59 #include "chrome/browser/policy/profile_policy_context.h" |
60 #include "chrome/browser/policy/device_management_policy_provider.h" | |
61 #include "chrome/browser/prefs/browser_prefs.h" | 60 #include "chrome/browser/prefs/browser_prefs.h" |
62 #include "chrome/browser/prefs/pref_value_store.h" | 61 #include "chrome/browser/prefs/pref_value_store.h" |
63 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 62 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
64 #include "chrome/browser/profile_manager.h" | 63 #include "chrome/browser/profile_manager.h" |
65 #include "chrome/browser/renderer_host/render_process_host.h" | 64 #include "chrome/browser/renderer_host/render_process_host.h" |
66 #include "chrome/browser/search_engines/template_url_fetcher.h" | 65 #include "chrome/browser/search_engines/template_url_fetcher.h" |
67 #include "chrome/browser/search_engines/template_url_model.h" | 66 #include "chrome/browser/search_engines/template_url_model.h" |
68 #include "chrome/browser/sessions/session_service.h" | 67 #include "chrome/browser/sessions/session_service.h" |
69 #include "chrome/browser/sessions/tab_restore_service.h" | 68 #include "chrome/browser/sessions/tab_restore_service.h" |
70 #include "chrome/browser/spellcheck_host.h" | 69 #include "chrome/browser/spellcheck_host.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 #if !defined(OS_CHROMEOS) | 347 #if !defined(OS_CHROMEOS) |
349 background_mode_manager_.reset(new BackgroundModeManager(this, | 348 background_mode_manager_.reset(new BackgroundModeManager(this, |
350 CommandLine::ForCurrentProcess())); | 349 CommandLine::ForCurrentProcess())); |
351 #endif | 350 #endif |
352 | 351 |
353 background_contents_service_.reset( | 352 background_contents_service_.reset( |
354 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); | 353 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); |
355 | 354 |
356 extension_info_map_ = new ExtensionInfoMap(); | 355 extension_info_map_ = new ExtensionInfoMap(); |
357 | 356 |
| 357 GetPolicyContext()->Initialize(); |
| 358 |
358 // Log the profile size after a reasonable startup delay. | 359 // Log the profile size after a reasonable startup delay. |
359 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, | 360 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, |
360 new ProfileSizeTask(path_), 112000); | 361 new ProfileSizeTask(path_), 112000); |
361 | 362 |
362 InstantController::RecordMetrics(this); | 363 InstantController::RecordMetrics(this); |
363 } | 364 } |
364 | 365 |
365 void ProfileImpl::InitExtensions() { | 366 void ProfileImpl::InitExtensions() { |
366 if (user_script_master_ || extensions_service_) | 367 if (user_script_master_ || extensions_service_) |
367 return; // Already initialized. | 368 return; // Already initialized. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 void ProfileImpl::set_last_selected_directory(const FilePath& path) { | 483 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
483 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 484 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
484 } | 485 } |
485 | 486 |
486 ProfileImpl::~ProfileImpl() { | 487 ProfileImpl::~ProfileImpl() { |
487 NotificationService::current()->Notify( | 488 NotificationService::current()->Notify( |
488 NotificationType::PROFILE_DESTROYED, | 489 NotificationType::PROFILE_DESTROYED, |
489 Source<Profile>(this), | 490 Source<Profile>(this), |
490 NotificationService::NoDetails()); | 491 NotificationService::NoDetails()); |
491 | 492 |
| 493 GetPolicyContext()->Shutdown(); |
| 494 |
492 tab_restore_service_ = NULL; | 495 tab_restore_service_ = NULL; |
493 | 496 |
494 StopCreateSessionServiceTimer(); | 497 StopCreateSessionServiceTimer(); |
495 // TemplateURLModel schedules a task on the WebDataService from its | 498 // TemplateURLModel schedules a task on the WebDataService from its |
496 // destructor. Delete it first to ensure the task gets scheduled before we | 499 // destructor. Delete it first to ensure the task gets scheduled before we |
497 // shut down the database. | 500 // shut down the database. |
498 template_url_model_.reset(); | 501 template_url_model_.reset(); |
499 | 502 |
500 // DownloadManager is lazily created, so check before accessing it. | 503 // DownloadManager is lazily created, so check before accessing it. |
501 if (download_manager_.get()) { | 504 if (download_manager_.get()) { |
502 // The download manager queries the history system and should be shutdown | 505 // The download manager queries the history system and should be shutdown |
503 // before the history is shutdown so it can properly cancel all requests. | 506 // before the history is shutdown so it can properly cancel all requests. |
504 download_manager_->Shutdown(); | 507 download_manager_->Shutdown(); |
505 download_manager_ = NULL; | 508 download_manager_ = NULL; |
506 } | 509 } |
507 | 510 |
508 // The theme provider provides bitmaps to whoever wants them. | 511 // The theme provider provides bitmaps to whoever wants them. |
509 theme_provider_.reset(); | 512 theme_provider_.reset(); |
510 | 513 |
511 // Remove pref observers | 514 // Remove pref observers |
512 pref_change_registrar_.RemoveAll(); | 515 pref_change_registrar_.RemoveAll(); |
513 | 516 |
514 // Delete the NTP resource cache so we can unregister pref observers. | 517 // Delete the NTP resource cache so we can unregister pref observers. |
515 ntp_resource_cache_.reset(); | 518 ntp_resource_cache_.reset(); |
516 | 519 |
517 // Shut down the DM policy provider before the token service dies. | |
518 if (device_management_policy_provider_.get()) | |
519 device_management_policy_provider_->Shutdown(); | |
520 | |
521 // The sync service needs to be deleted before the services it calls. | 520 // The sync service needs to be deleted before the services it calls. |
522 sync_service_.reset(); | 521 sync_service_.reset(); |
523 | 522 |
524 // Both HistoryService and WebDataService maintain threads for background | 523 // Both HistoryService and WebDataService maintain threads for background |
525 // processing. Its possible each thread still has tasks on it that have | 524 // processing. Its possible each thread still has tasks on it that have |
526 // increased the ref count of the service. In such a situation, when we | 525 // increased the ref count of the service. In such a situation, when we |
527 // decrement the refcount, it won't be 0, and the threads/databases aren't | 526 // decrement the refcount, it won't be 0, and the threads/databases aren't |
528 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the | 527 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the |
529 // databases are properly closed. | 528 // databases are properly closed. |
530 if (web_data_service_.get()) | 529 if (web_data_service_.get()) |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 NewRunnableMethod(blob_storage_context_.get(), | 1311 NewRunnableMethod(blob_storage_context_.get(), |
1313 &ChromeBlobStorageContext::InitializeOnIOThread)); | 1312 &ChromeBlobStorageContext::InitializeOnIOThread)); |
1314 } | 1313 } |
1315 return blob_storage_context_; | 1314 return blob_storage_context_; |
1316 } | 1315 } |
1317 | 1316 |
1318 ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() { | 1317 ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() { |
1319 return extension_info_map_.get(); | 1318 return extension_info_map_.get(); |
1320 } | 1319 } |
1321 | 1320 |
1322 policy::DeviceManagementPolicyProvider* | 1321 policy::ProfilePolicyContext* ProfileImpl::GetPolicyContext() { |
1323 ProfileImpl::GetDeviceManagementPolicyProvider() { | 1322 if (!profile_policy_context_.get()) |
1324 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1323 profile_policy_context_.reset(new policy::ProfilePolicyContext(this)); |
1325 if (!command_line->HasSwitch(switches::kDeviceManagementUrl)) | |
1326 return NULL; | |
1327 | 1324 |
1328 if (!device_management_policy_provider_.get()) { | 1325 return profile_policy_context_.get(); |
1329 device_management_policy_provider_.reset( | |
1330 new policy::DeviceManagementPolicyProvider( | |
1331 policy::ConfigurationPolicyPrefStore:: | |
1332 GetChromePolicyDefinitionList(), | |
1333 new policy::DeviceManagementBackendImpl( | |
1334 command_line->GetSwitchValueASCII( | |
1335 switches::kDeviceManagementUrl)), | |
1336 GetTokenService(), | |
1337 GetPath())); | |
1338 } | |
1339 return device_management_policy_provider_.get(); | |
1340 } | 1326 } |
1341 | 1327 |
1342 PromoCounter* ProfileImpl::GetInstantPromoCounter() { | 1328 PromoCounter* ProfileImpl::GetInstantPromoCounter() { |
1343 #if defined(OS_WIN) | 1329 #if defined(OS_WIN) |
1344 // TODO: enable this when we're ready to turn on the promo. | 1330 // TODO: enable this when we're ready to turn on the promo. |
1345 /* | 1331 /* |
1346 if (!checked_instant_promo_) { | 1332 if (!checked_instant_promo_) { |
1347 checked_instant_promo_ = true; | 1333 checked_instant_promo_ = true; |
1348 PrefService* prefs = GetPrefs(); | 1334 PrefService* prefs = GetPrefs(); |
1349 if (!prefs->GetBoolean(prefs::kInstantEnabledOnce) && | 1335 if (!prefs->GetBoolean(prefs::kInstantEnabledOnce) && |
(...skipping 14 matching lines...) Expand all Loading... |
1364 #if defined(OS_CHROMEOS) | 1350 #if defined(OS_CHROMEOS) |
1365 chromeos::ProxyConfigServiceImpl* | 1351 chromeos::ProxyConfigServiceImpl* |
1366 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { | 1352 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { |
1367 if (!chromeos_proxy_config_service_impl_) { | 1353 if (!chromeos_proxy_config_service_impl_) { |
1368 chromeos_proxy_config_service_impl_ = | 1354 chromeos_proxy_config_service_impl_ = |
1369 new chromeos::ProxyConfigServiceImpl(); | 1355 new chromeos::ProxyConfigServiceImpl(); |
1370 } | 1356 } |
1371 return chromeos_proxy_config_service_impl_; | 1357 return chromeos_proxy_config_service_impl_; |
1372 } | 1358 } |
1373 #endif // defined(OS_CHROMEOS) | 1359 #endif // defined(OS_CHROMEOS) |
OLD | NEW |