OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
18 #include "chrome/browser/autofill/personal_data_manager.h" | 18 #include "chrome/browser/autofill/personal_data_manager.h" |
19 #include "chrome/browser/background/background_contents_service_factory.h" | 19 #include "chrome/browser/background/background_contents_service_factory.h" |
20 #include "chrome/browser/background/background_mode_manager.h" | 20 #include "chrome/browser/background/background_mode_manager.h" |
21 #include "chrome/browser/bookmarks/bookmark_model.h" | 21 #include "chrome/browser/bookmarks/bookmark_model.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/browsing_data_remover.h" | 23 #include "chrome/browser/browsing_data_remover.h" |
24 #include "chrome/browser/chrome_plugin_service_filter.h" | 24 #include "chrome/browser/chrome_plugin_service_filter.h" |
25 #include "chrome/browser/content_settings/host_content_settings_map.h" | 25 #include "chrome/browser/content_settings/host_content_settings_map.h" |
26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
27 #include "chrome/browser/defaults.h" | 27 #include "chrome/browser/defaults.h" |
28 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 28 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 29 #include "chrome/browser/extensions/crx_installer.h" |
29 #include "chrome/browser/extensions/extension_devtools_manager.h" | 30 #include "chrome/browser/extensions/extension_devtools_manager.h" |
30 #include "chrome/browser/extensions/extension_error_reporter.h" | 31 #include "chrome/browser/extensions/extension_error_reporter.h" |
31 #include "chrome/browser/extensions/extension_event_router.h" | 32 #include "chrome/browser/extensions/extension_event_router.h" |
32 #include "chrome/browser/extensions/extension_info_map.h" | 33 #include "chrome/browser/extensions/extension_info_map.h" |
33 #include "chrome/browser/extensions/extension_message_service.h" | 34 #include "chrome/browser/extensions/extension_message_service.h" |
34 #include "chrome/browser/extensions/extension_pref_store.h" | 35 #include "chrome/browser/extensions/extension_pref_store.h" |
35 #include "chrome/browser/extensions/extension_process_manager.h" | 36 #include "chrome/browser/extensions/extension_process_manager.h" |
36 #include "chrome/browser/extensions/extension_service.h" | 37 #include "chrome/browser/extensions/extension_service.h" |
37 #include "chrome/browser/extensions/extension_settings.h" | 38 #include "chrome/browser/extensions/extension_settings.h" |
38 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 39 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
39 #include "chrome/browser/extensions/user_script_master.h" | 40 #include "chrome/browser/extensions/user_script_master.h" |
40 #include "chrome/browser/favicon/favicon_service.h" | 41 #include "chrome/browser/favicon/favicon_service.h" |
| 42 #include "chrome/browser/first_run/first_run.h" |
41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 43 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
42 #include "chrome/browser/history/history.h" | 44 #include "chrome/browser/history/history.h" |
43 #include "chrome/browser/history/shortcuts_backend.h" | 45 #include "chrome/browser/history/shortcuts_backend.h" |
44 #include "chrome/browser/history/top_sites.h" | 46 #include "chrome/browser/history/top_sites.h" |
45 #include "chrome/browser/instant/instant_controller.h" | 47 #include "chrome/browser/instant/instant_controller.h" |
| 48 #include "chrome/browser/mac/keystone_glue.h" |
46 #include "chrome/browser/metrics/metrics_service.h" | 49 #include "chrome/browser/metrics/metrics_service.h" |
47 #include "chrome/browser/net/chrome_url_request_context.h" | 50 #include "chrome/browser/net/chrome_url_request_context.h" |
48 #include "chrome/browser/net/gaia/token_service.h" | 51 #include "chrome/browser/net/gaia/token_service.h" |
49 #include "chrome/browser/net/net_pref_observer.h" | 52 #include "chrome/browser/net/net_pref_observer.h" |
50 #include "chrome/browser/net/predictor.h" | 53 #include "chrome/browser/net/predictor.h" |
51 #include "chrome/browser/net/pref_proxy_config_service.h" | 54 #include "chrome/browser/net/pref_proxy_config_service.h" |
52 #include "chrome/browser/net/ssl_config_service_manager.h" | 55 #include "chrome/browser/net/ssl_config_service_manager.h" |
53 #include "chrome/browser/password_manager/password_store_default.h" | 56 #include "chrome/browser/password_manager/password_store_default.h" |
54 #include "chrome/browser/plugin_prefs.h" | 57 #include "chrome/browser/plugin_prefs.h" |
55 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 58 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
(...skipping 24 matching lines...) Expand all Loading... |
80 #include "chrome/common/chrome_constants.h" | 83 #include "chrome/common/chrome_constants.h" |
81 #include "chrome/common/chrome_notification_types.h" | 84 #include "chrome/common/chrome_notification_types.h" |
82 #include "chrome/common/chrome_paths.h" | 85 #include "chrome/common/chrome_paths.h" |
83 #include "chrome/common/chrome_paths_internal.h" | 86 #include "chrome/common/chrome_paths_internal.h" |
84 #include "chrome/common/chrome_switches.h" | 87 #include "chrome/common/chrome_switches.h" |
85 #include "chrome/common/extensions/extension_permission_set.h" | 88 #include "chrome/common/extensions/extension_permission_set.h" |
86 #include "chrome/common/json_pref_store.h" | 89 #include "chrome/common/json_pref_store.h" |
87 #include "chrome/common/pref_names.h" | 90 #include "chrome/common/pref_names.h" |
88 #include "chrome/common/render_messages.h" | 91 #include "chrome/common/render_messages.h" |
89 #include "chrome/common/spellcheck_messages.h" | 92 #include "chrome/common/spellcheck_messages.h" |
| 93 #include "chrome/installer/util/google_update_settings.h" |
90 #include "content/browser/appcache/chrome_appcache_service.h" | 94 #include "content/browser/appcache/chrome_appcache_service.h" |
91 #include "content/browser/browser_thread.h" | 95 #include "content/browser/browser_thread.h" |
92 #include "content/browser/chrome_blob_storage_context.h" | 96 #include "content/browser/chrome_blob_storage_context.h" |
93 #include "content/browser/download/download_manager.h" | 97 #include "content/browser/download/download_manager.h" |
94 #include "content/browser/file_system/browser_file_system_helper.h" | 98 #include "content/browser/file_system/browser_file_system_helper.h" |
95 #include "content/browser/host_zoom_map.h" | 99 #include "content/browser/host_zoom_map.h" |
96 #include "content/browser/in_process_webkit/webkit_context.h" | 100 #include "content/browser/in_process_webkit/webkit_context.h" |
97 #include "content/browser/renderer_host/render_process_host.h" | 101 #include "content/browser/renderer_host/render_process_host.h" |
98 #include "content/browser/speech/speech_input_manager.h" | 102 #include "content/browser/speech/speech_input_manager.h" |
99 #include "content/browser/ssl/ssl_host_state.h" | 103 #include "content/browser/ssl/ssl_host_state.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 extension_service_.reset(new ExtensionService( | 497 extension_service_.reset(new ExtensionService( |
494 this, | 498 this, |
495 CommandLine::ForCurrentProcess(), | 499 CommandLine::ForCurrentProcess(), |
496 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 500 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
497 extension_prefs_.get(), | 501 extension_prefs_.get(), |
498 extension_settings_.get(), | 502 extension_settings_.get(), |
499 autoupdate_enabled, | 503 autoupdate_enabled, |
500 extensions_enabled)); | 504 extensions_enabled)); |
501 | 505 |
502 RegisterComponentExtensions(); | 506 RegisterComponentExtensions(); |
| 507 |
| 508 #if defined(GOOGLE_CHROME_BUILD) |
| 509 // If first run and brand code not equal to ECDB, install default apps. |
| 510 #if defined(OS_WIN) |
| 511 string16 brand; |
| 512 GoogleUpdateSettings::GetBrand(&brand); |
| 513 #elif defined(OS_MACOSX) |
| 514 std::string brand = keystone_glue::BrandCode(); |
| 515 #else |
| 516 std::string brand; |
| 517 #endif |
| 518 // TODO(caitkp): when we move to multi-profiles (M16) we will want to change |
| 519 // this check, as |FirstRun::IsChromeFirstRun()| checks for the first run |
| 520 // ever, not first run per profile. |
| 521 if (FirstRun::IsChromeFirstRun() && |
| 522 !LowerCaseEqualsASCII(brand, "ecdb")) { |
| 523 InstallDefaultApps(); |
| 524 } |
| 525 #endif |
| 526 |
503 extension_service_->Init(); | 527 extension_service_->Init(); |
504 | 528 |
505 if (extensions_enabled) { | 529 if (extensions_enabled) { |
506 // Load any extensions specified with --load-extension. | 530 // Load any extensions specified with --load-extension. |
507 if (command_line->HasSwitch(switches::kLoadExtension)) { | 531 if (command_line->HasSwitch(switches::kLoadExtension)) { |
508 FilePath path = command_line->GetSwitchValuePath( | 532 FilePath path = command_line->GetSwitchValuePath( |
509 switches::kLoadExtension); | 533 switches::kLoadExtension); |
510 extension_service_->LoadExtensionFromCommandLine(path); | 534 extension_service_->LoadExtensionFromCommandLine(path); |
511 } | 535 } |
512 } | 536 } |
(...skipping 16 matching lines...) Expand all Loading... |
529 if (!command_line->HasSwitch(switches::kImport) && | 553 if (!command_line->HasSwitch(switches::kImport) && |
530 !command_line->HasSwitch(switches::kImportFromFile)) { | 554 !command_line->HasSwitch(switches::kImportFromFile)) { |
531 if (g_browser_process->profile_manager()->will_import()) { | 555 if (g_browser_process->profile_manager()->will_import()) { |
532 extension_service_->InitEventRoutersAfterImport(); | 556 extension_service_->InitEventRoutersAfterImport(); |
533 } else { | 557 } else { |
534 extension_service_->InitEventRouters(); | 558 extension_service_->InitEventRouters(); |
535 } | 559 } |
536 } | 560 } |
537 } | 561 } |
538 | 562 |
| 563 void ProfileImpl::InstallDefaultApps() { |
| 564 FilePath apps_dir; |
| 565 FilePath file; |
| 566 std::list<FilePath> crx_path_list; |
| 567 |
| 568 if (PathService::Get(chrome::DIR_DEFAULT_APPS, &apps_dir)) { |
| 569 file_util::FileEnumerator file_enumerator(apps_dir, false, |
| 570 file_util::FileEnumerator::FILES); |
| 571 while (!(file = file_enumerator.Next()).value().empty()) { |
| 572 if (LowerCaseEqualsASCII(file.Extension(), ".crx")) |
| 573 crx_path_list.push_back(file); |
| 574 } |
| 575 } |
| 576 |
| 577 for (std::list<FilePath>::iterator iter = crx_path_list.begin(); |
| 578 iter != crx_path_list.end(); ++iter) { |
| 579 scoped_refptr<CrxInstaller> crx_installer = |
| 580 extension_service_->MakeCrxInstaller(NULL); |
| 581 crx_installer->set_allow_silent_install(true); |
| 582 crx_installer->set_delete_source(false); |
| 583 crx_installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
| 584 crx_installer->InstallCrx(*iter); |
| 585 } |
| 586 } |
| 587 |
539 void ProfileImpl::RegisterComponentExtensions() { | 588 void ProfileImpl::RegisterComponentExtensions() { |
540 // Register the component extensions. | 589 // Register the component extensions. |
541 // | 590 // |
542 // Component extension manifest must contain a 'key' property with a unique | 591 // Component extension manifest must contain a 'key' property with a unique |
543 // public key, serialized in base64. You can create a suitable value with the | 592 // public key, serialized in base64. You can create a suitable value with the |
544 // following commands on a unixy system: | 593 // following commands on a unixy system: |
545 // | 594 // |
546 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem | 595 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem |
547 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 | 596 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 |
548 typedef std::list<std::pair<FilePath::StringType, int> > | 597 typedef std::list<std::pair<FilePath::StringType, int> > |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 | 1802 |
1754 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { | 1803 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { |
1755 return predictor_; | 1804 return predictor_; |
1756 } | 1805 } |
1757 | 1806 |
1758 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1807 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1759 if (!spellcheck_profile_.get()) | 1808 if (!spellcheck_profile_.get()) |
1760 spellcheck_profile_.reset(new SpellCheckProfile()); | 1809 spellcheck_profile_.reset(new SpellCheckProfile()); |
1761 return spellcheck_profile_.get(); | 1810 return spellcheck_profile_.get(); |
1762 } | 1811 } |
OLD | NEW |