| 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/ui/profile_menu_model.h" | 5 #include "chrome/browser/ui/profile_menu_model.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile_info_cache.h" | 9 #include "chrome/browser/profiles/profile_info_cache.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ProfileInfoCache& cache = | 67 ProfileInfoCache& cache = |
| 68 g_browser_process->profile_manager()->GetProfileInfoCache(); | 68 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 69 size_t count = cache.GetNumberOfProfiles(); | 69 size_t count = cache.GetNumberOfProfiles(); |
| 70 for (size_t i = 0; i < count; ++i) { | 70 for (size_t i = 0; i < count; ++i) { |
| 71 AddCheckItem(ProfileMenuModel::COMMAND_SWITCH_TO_PROFILE + i, | 71 AddCheckItem(ProfileMenuModel::COMMAND_SWITCH_TO_PROFILE + i, |
| 72 cache.GetNameOfProfileAtIndex(i)); | 72 cache.GetNameOfProfileAtIndex(i)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 AddSeparator(); | 75 AddSeparator(); |
| 76 | 76 |
| 77 AddItemWithStringId(ProfileMenuModel::COMMAND_CREATE_NEW_PROFILE, | 77 const string16 short_product_name = |
| 78 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); | 78 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| 79 AddItem(ProfileMenuModel::COMMAND_CREATE_NEW_PROFILE, |
| 80 l10n_util::GetStringFUTF16(IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, |
| 81 short_product_name)); |
| 79 } | 82 } |
| 80 | 83 |
| 81 void SwitchProfileMenuModel::ExecuteCommand(int command_id) { | 84 void SwitchProfileMenuModel::ExecuteCommand(int command_id) { |
| 82 ProfileInfoCache& cache = | 85 ProfileInfoCache& cache = |
| 83 g_browser_process->profile_manager()->GetProfileInfoCache(); | 86 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 84 if (IsSwitchProfileCommand(command_id)) { | 87 if (IsSwitchProfileCommand(command_id)) { |
| 85 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id); | 88 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id); |
| 86 FilePath profile_path = cache.GetPathOfProfileAtIndex(index); | 89 FilePath profile_path = cache.GetPathOfProfileAtIndex(index); |
| 87 ProfileSwitchObserver* observer = new ProfileSwitchObserver; | 90 ProfileSwitchObserver* observer = new ProfileSwitchObserver; |
| 88 // The observer is deleted by the manager when profile creation is finished. | 91 // The observer is deleted by the manager when profile creation is finished. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 151 |
| 149 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE, | 152 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE, |
| 150 IDS_PROFILES_CUSTOMIZE_PROFILE); | 153 IDS_PROFILES_CUSTOMIZE_PROFILE); |
| 151 AddSeparator(); | 154 AddSeparator(); |
| 152 | 155 |
| 153 const string16 short_product_name = | 156 const string16 short_product_name = |
| 154 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 157 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| 155 if (cache.GetNumberOfProfiles() > 1) { | 158 if (cache.GetNumberOfProfiles() > 1) { |
| 156 switch_profiles_sub_menu_model_.reset( | 159 switch_profiles_sub_menu_model_.reset( |
| 157 new SwitchProfileMenuModel(this, browser_)); | 160 new SwitchProfileMenuModel(this, browser_)); |
| 158 AddSubMenuWithStringId(COMMAND_SWITCH_PROFILE_MENU, IDS_PROFILES_MENU, | 161 AddSubMenu(COMMAND_SWITCH_PROFILE_MENU, l10n_util::GetStringFUTF16( |
| 159 switch_profiles_sub_menu_model_.get()); | 162 IDS_PROFILES_MENU, short_product_name), |
| 163 switch_profiles_sub_menu_model_.get()); |
| 160 } else { | 164 } else { |
| 161 switch_profiles_sub_menu_model_.reset(); | 165 switch_profiles_sub_menu_model_.reset(); |
| 162 AddItem(COMMAND_CREATE_NEW_PROFILE, l10n_util::GetStringFUTF16( | 166 AddItem(COMMAND_CREATE_NEW_PROFILE, l10n_util::GetStringFUTF16( |
| 163 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, short_product_name)); | 167 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, short_product_name)); |
| 164 } | 168 } |
| 165 } | 169 } |
| 166 | 170 |
| 167 ProfileMenuModel::~ProfileMenuModel() { | 171 ProfileMenuModel::~ProfileMenuModel() { |
| 168 } | 172 } |
| 169 | 173 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 194 case COMMAND_CHOOSE_AVATAR_ICON: | 198 case COMMAND_CHOOSE_AVATAR_ICON: |
| 195 break; | 199 break; |
| 196 case COMMAND_CREATE_NEW_PROFILE: | 200 case COMMAND_CREATE_NEW_PROFILE: |
| 197 ProfileManager::CreateMultiProfileAsync(); | 201 ProfileManager::CreateMultiProfileAsync(); |
| 198 break; | 202 break; |
| 199 default: | 203 default: |
| 200 NOTREACHED(); | 204 NOTREACHED(); |
| 201 break; | 205 break; |
| 202 } | 206 } |
| 203 } | 207 } |
| OLD | NEW |