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/device_management_service.h" |
60 #include "chrome/browser/policy/device_management_policy_provider.h" | 60 #include "chrome/browser/policy/device_management_policy_provider.h" |
61 #include "chrome/browser/prefs/browser_prefs.h" | 61 #include "chrome/browser/prefs/browser_prefs.h" |
62 #include "chrome/browser/prefs/pref_value_store.h" | 62 #include "chrome/browser/prefs/pref_value_store.h" |
63 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 63 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
64 #include "chrome/browser/profile_manager.h" | 64 #include "chrome/browser/profile_manager.h" |
65 #include "chrome/browser/renderer_host/render_process_host.h" | 65 #include "chrome/browser/renderer_host/render_process_host.h" |
66 #include "chrome/browser/search_engines/template_url_fetcher.h" | 66 #include "chrome/browser/search_engines/template_url_fetcher.h" |
67 #include "chrome/browser/search_engines/template_url_model.h" | 67 #include "chrome/browser/search_engines/template_url_model.h" |
68 #include "chrome/browser/sessions/session_service.h" | 68 #include "chrome/browser/sessions/session_service.h" |
69 #include "chrome/browser/sessions/tab_restore_service.h" | 69 #include "chrome/browser/sessions/tab_restore_service.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 #if !defined(OS_CHROMEOS) | 348 #if !defined(OS_CHROMEOS) |
349 background_mode_manager_.reset(new BackgroundModeManager(this, | 349 background_mode_manager_.reset(new BackgroundModeManager(this, |
350 CommandLine::ForCurrentProcess())); | 350 CommandLine::ForCurrentProcess())); |
351 #endif | 351 #endif |
352 | 352 |
353 background_contents_service_.reset( | 353 background_contents_service_.reset( |
354 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); | 354 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); |
355 | 355 |
356 extension_info_map_ = new ExtensionInfoMap(); | 356 extension_info_map_ = new ExtensionInfoMap(); |
357 | 357 |
| 358 policy::DeviceManagementService* device_management_service = |
| 359 GetDeviceManagementService(); |
| 360 if (device_management_service) |
| 361 device_management_service->Initialize(GetRequestContext()); |
| 362 |
358 // Log the profile size after a reasonable startup delay. | 363 // Log the profile size after a reasonable startup delay. |
359 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, | 364 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, |
360 new ProfileSizeTask(path_), 112000); | 365 new ProfileSizeTask(path_), 112000); |
361 | 366 |
362 InstantController::RecordMetrics(this); | 367 InstantController::RecordMetrics(this); |
363 } | 368 } |
364 | 369 |
365 void ProfileImpl::InitExtensions() { | 370 void ProfileImpl::InitExtensions() { |
366 if (user_script_master_ || extensions_service_) | 371 if (user_script_master_ || extensions_service_) |
367 return; // Already initialized. | 372 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) { | 487 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
483 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 488 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
484 } | 489 } |
485 | 490 |
486 ProfileImpl::~ProfileImpl() { | 491 ProfileImpl::~ProfileImpl() { |
487 NotificationService::current()->Notify( | 492 NotificationService::current()->Notify( |
488 NotificationType::PROFILE_DESTROYED, | 493 NotificationType::PROFILE_DESTROYED, |
489 Source<Profile>(this), | 494 Source<Profile>(this), |
490 NotificationService::NoDetails()); | 495 NotificationService::NoDetails()); |
491 | 496 |
| 497 if (device_management_service_.get()) |
| 498 device_management_service_->Shutdown(); |
| 499 |
492 tab_restore_service_ = NULL; | 500 tab_restore_service_ = NULL; |
493 | 501 |
494 StopCreateSessionServiceTimer(); | 502 StopCreateSessionServiceTimer(); |
495 // TemplateURLModel schedules a task on the WebDataService from its | 503 // TemplateURLModel schedules a task on the WebDataService from its |
496 // destructor. Delete it first to ensure the task gets scheduled before we | 504 // destructor. Delete it first to ensure the task gets scheduled before we |
497 // shut down the database. | 505 // shut down the database. |
498 template_url_model_.reset(); | 506 template_url_model_.reset(); |
499 | 507 |
500 // DownloadManager is lazily created, so check before accessing it. | 508 // DownloadManager is lazily created, so check before accessing it. |
501 if (download_manager_.get()) { | 509 if (download_manager_.get()) { |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 NewRunnableMethod(blob_storage_context_.get(), | 1320 NewRunnableMethod(blob_storage_context_.get(), |
1313 &ChromeBlobStorageContext::InitializeOnIOThread)); | 1321 &ChromeBlobStorageContext::InitializeOnIOThread)); |
1314 } | 1322 } |
1315 return blob_storage_context_; | 1323 return blob_storage_context_; |
1316 } | 1324 } |
1317 | 1325 |
1318 ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() { | 1326 ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() { |
1319 return extension_info_map_.get(); | 1327 return extension_info_map_.get(); |
1320 } | 1328 } |
1321 | 1329 |
| 1330 policy::DeviceManagementService* |
| 1331 ProfileImpl::GetDeviceManagementService() { |
| 1332 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1333 if (device_management_service_.get()) |
| 1334 return device_management_service_.get(); |
| 1335 |
| 1336 if (!command_line->HasSwitch(switches::kDeviceManagementUrl)); |
| 1337 return NULL; |
| 1338 |
| 1339 device_management_service_.reset( |
| 1340 new policy::DeviceManagementService( |
| 1341 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); |
| 1342 return device_management_service_.get(); |
| 1343 } |
| 1344 |
1322 policy::DeviceManagementPolicyProvider* | 1345 policy::DeviceManagementPolicyProvider* |
1323 ProfileImpl::GetDeviceManagementPolicyProvider() { | 1346 ProfileImpl::GetDeviceManagementPolicyProvider() { |
1324 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1347 policy::DeviceManagementService* service = GetDeviceManagementService(); |
1325 if (!command_line->HasSwitch(switches::kDeviceManagementUrl)) | 1348 if (!service) |
1326 return NULL; | 1349 return NULL; |
1327 | 1350 |
1328 if (!device_management_policy_provider_.get()) { | 1351 if (!device_management_policy_provider_.get()) { |
1329 device_management_policy_provider_.reset( | 1352 device_management_policy_provider_.reset( |
1330 new policy::DeviceManagementPolicyProvider( | 1353 new policy::DeviceManagementPolicyProvider( |
1331 policy::ConfigurationPolicyPrefStore:: | 1354 policy::ConfigurationPolicyPrefStore:: |
1332 GetChromePolicyDefinitionList(), | 1355 GetChromePolicyDefinitionList(), |
1333 new policy::DeviceManagementBackendImpl( | 1356 service->CreateBackend(), |
1334 command_line->GetSwitchValueASCII( | |
1335 switches::kDeviceManagementUrl)), | |
1336 GetTokenService(), | 1357 GetTokenService(), |
1337 GetPath())); | 1358 GetPath())); |
1338 } | 1359 } |
1339 return device_management_policy_provider_.get(); | 1360 return device_management_policy_provider_.get(); |
1340 } | 1361 } |
1341 | 1362 |
1342 PromoCounter* ProfileImpl::GetInstantPromoCounter() { | 1363 PromoCounter* ProfileImpl::GetInstantPromoCounter() { |
1343 #if defined(OS_WIN) | 1364 #if defined(OS_WIN) |
1344 // TODO: enable this when we're ready to turn on the promo. | 1365 // TODO: enable this when we're ready to turn on the promo. |
1345 /* | 1366 /* |
(...skipping 18 matching lines...) Expand all Loading... |
1364 #if defined(OS_CHROMEOS) | 1385 #if defined(OS_CHROMEOS) |
1365 chromeos::ProxyConfigServiceImpl* | 1386 chromeos::ProxyConfigServiceImpl* |
1366 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { | 1387 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { |
1367 if (!chromeos_proxy_config_service_impl_) { | 1388 if (!chromeos_proxy_config_service_impl_) { |
1368 chromeos_proxy_config_service_impl_ = | 1389 chromeos_proxy_config_service_impl_ = |
1369 new chromeos::ProxyConfigServiceImpl(); | 1390 new chromeos::ProxyConfigServiceImpl(); |
1370 } | 1391 } |
1371 return chromeos_proxy_config_service_impl_; | 1392 return chromeos_proxy_config_service_impl_; |
1372 } | 1393 } |
1373 #endif // defined(OS_CHROMEOS) | 1394 #endif // defined(OS_CHROMEOS) |
OLD | NEW |