| OLD | NEW |
| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 local_state->SetString(prefs::kProfileLastUsed, | 544 local_state->SetString(prefs::kProfileLastUsed, |
| 545 last_active->GetPath().BaseName().MaybeAsASCII()); | 545 last_active->GetPath().BaseName().MaybeAsASCII()); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { | 549 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { |
| 550 DoFinalInitForServices(profile, go_off_the_record); | 550 DoFinalInitForServices(profile, go_off_the_record); |
| 551 InitProfileUserPrefs(profile); | 551 InitProfileUserPrefs(profile); |
| 552 AddProfileToCache(profile); | 552 AddProfileToCache(profile); |
| 553 DoFinalInitLogging(profile); | 553 DoFinalInitLogging(profile); |
| 554 #if defined(OS_WIN) |
| 555 CreateDesktopShortcut(profile); |
| 556 #endif |
| 554 } | 557 } |
| 555 | 558 |
| 556 void ProfileManager::DoFinalInitForServices(Profile* profile, | 559 void ProfileManager::DoFinalInitForServices(Profile* profile, |
| 557 bool go_off_the_record) { | 560 bool go_off_the_record) { |
| 558 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 561 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 559 profile->InitExtensions(!go_off_the_record); | 562 profile->InitExtensions(!go_off_the_record); |
| 560 if (!command_line.HasSwitch(switches::kDisableWebResources)) | 563 if (!command_line.HasSwitch(switches::kDisableWebResources)) |
| 561 profile->InitPromoResources(); | 564 profile->InitPromoResources(); |
| 562 } | 565 } |
| 563 | 566 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 710 |
| 708 size_t icon_index = profile->GetPrefs()->GetInteger( | 711 size_t icon_index = profile->GetPrefs()->GetInteger( |
| 709 prefs::kProfileAvatarIndex); | 712 prefs::kProfileAvatarIndex); |
| 710 | 713 |
| 711 cache.AddProfileToCache(profile->GetPath(), | 714 cache.AddProfileToCache(profile->GetPath(), |
| 712 profile_name, | 715 profile_name, |
| 713 username, | 716 username, |
| 714 icon_index); | 717 icon_index); |
| 715 } | 718 } |
| 716 | 719 |
| 720 #if defined(OS_WIN) |
| 721 void ProfileManager::CreateDesktopShortcut(Profile* profile) { |
| 722 // Some distributions can not create desktop shortcuts, in which case |
| 723 // profile_shortcut_manager_ will not be set. |
| 724 if (!profile_shortcut_manager_.get()) |
| 725 return; |
| 726 |
| 727 bool shortcut_created = |
| 728 profile->GetPrefs()->GetBoolean(prefs::kProfileShortcutCreated); |
| 729 if (!shortcut_created && GetNumberOfProfiles() > 1) { |
| 730 profile_shortcut_manager_->AddProfileShortcut(profile->GetPath()); |
| 731 |
| 732 // We only ever create the shortcut for a profile once, so set a pref |
| 733 // reminding us to skip this in the future. |
| 734 profile->GetPrefs()->SetBoolean(prefs::kProfileShortcutCreated, true); |
| 735 } |
| 736 } |
| 737 #endif |
| 738 |
| 717 void ProfileManager::InitProfileUserPrefs(Profile* profile) { | 739 void ProfileManager::InitProfileUserPrefs(Profile* profile) { |
| 718 ProfileInfoCache& cache = GetProfileInfoCache(); | 740 ProfileInfoCache& cache = GetProfileInfoCache(); |
| 719 | 741 |
| 720 if (profile->GetPath().DirName() != cache.GetUserDataDir()) | 742 if (profile->GetPath().DirName() != cache.GetUserDataDir()) |
| 721 return; | 743 return; |
| 722 | 744 |
| 723 // Initialize the user preferences (name and avatar) only if the profile | 745 // Initialize the user preferences (name and avatar) only if the profile |
| 724 // doesn't have default preferenc values for them. | 746 // doesn't have default preferenc values for them. |
| 725 if (HasAnyDefaultUserPrefs(profile)) { | 747 if (HasAnyDefaultUserPrefs(profile)) { |
| 726 size_t profile_cache_index = | 748 size_t profile_cache_index = |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); | 866 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); |
| 845 } | 867 } |
| 846 #endif | 868 #endif |
| 847 | 869 |
| 848 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, | 870 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, |
| 849 Profile* profile, | 871 Profile* profile, |
| 850 Profile::CreateStatus status) { | 872 Profile::CreateStatus status) { |
| 851 for (size_t i = 0; i < callbacks.size(); ++i) | 873 for (size_t i = 0; i < callbacks.size(); ++i) |
| 852 callbacks[i].Run(profile, status); | 874 callbacks[i].Run(profile, status); |
| 853 } | 875 } |
| OLD | NEW |