| 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 const string16 short_product_name = | 77 AddItemWithStringId(ProfileMenuModel::COMMAND_CREATE_NEW_PROFILE, |
| 78 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 78 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); |
| 79 AddItem(ProfileMenuModel::COMMAND_CREATE_NEW_PROFILE, | |
| 80 l10n_util::GetStringFUTF16(IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, | |
| 81 short_product_name)); | |
| 82 } | 79 } |
| 83 | 80 |
| 84 void SwitchProfileMenuModel::ExecuteCommand(int command_id) { | 81 void SwitchProfileMenuModel::ExecuteCommand(int command_id) { |
| 85 ProfileInfoCache& cache = | 82 ProfileInfoCache& cache = |
| 86 g_browser_process->profile_manager()->GetProfileInfoCache(); | 83 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 87 if (IsSwitchProfileCommand(command_id)) { | 84 if (IsSwitchProfileCommand(command_id)) { |
| 88 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id); | 85 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id); |
| 89 FilePath profile_path = cache.GetPathOfProfileAtIndex(index); | 86 FilePath profile_path = cache.GetPathOfProfileAtIndex(index); |
| 90 ProfileSwitchObserver* observer = new ProfileSwitchObserver; | 87 ProfileSwitchObserver* observer = new ProfileSwitchObserver; |
| 91 // The observer is deleted by the manager when profile creation is finished. | 88 // The observer is deleted by the manager when profile creation is finished. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 143 |
| 147 // TODO(sail): Need to implement an icon chooser on other platforms too. | 144 // TODO(sail): Need to implement an icon chooser on other platforms too. |
| 148 #if defined(TOOLKIT_VIEWS) | 145 #if defined(TOOLKIT_VIEWS) |
| 149 AddItem(COMMAND_CHOOSE_AVATAR_ICON, string16()); | 146 AddItem(COMMAND_CHOOSE_AVATAR_ICON, string16()); |
| 150 #endif | 147 #endif |
| 151 | 148 |
| 152 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE, | 149 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE, |
| 153 IDS_PROFILES_CUSTOMIZE_PROFILE); | 150 IDS_PROFILES_CUSTOMIZE_PROFILE); |
| 154 AddSeparator(); | 151 AddSeparator(); |
| 155 | 152 |
| 156 const string16 short_product_name = | |
| 157 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | |
| 158 if (cache.GetNumberOfProfiles() > 1) { | 153 if (cache.GetNumberOfProfiles() > 1) { |
| 159 switch_profiles_sub_menu_model_.reset( | 154 switch_profiles_sub_menu_model_.reset( |
| 160 new SwitchProfileMenuModel(this, browser_)); | 155 new SwitchProfileMenuModel(this, browser_)); |
| 161 AddSubMenu(COMMAND_SWITCH_PROFILE_MENU, l10n_util::GetStringFUTF16( | 156 AddSubMenuWithStringId(COMMAND_SWITCH_PROFILE_MENU, IDS_PROFILES_MENU, |
| 162 IDS_PROFILES_MENU, short_product_name), | 157 switch_profiles_sub_menu_model_.get()); |
| 163 switch_profiles_sub_menu_model_.get()); | |
| 164 } else { | 158 } else { |
| 165 switch_profiles_sub_menu_model_.reset(); | 159 switch_profiles_sub_menu_model_.reset(); |
| 166 AddItem(COMMAND_CREATE_NEW_PROFILE, l10n_util::GetStringFUTF16( | 160 AddItemWithStringId(COMMAND_CREATE_NEW_PROFILE, |
| 167 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, short_product_name)); | 161 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); |
| 168 } | 162 } |
| 169 } | 163 } |
| 170 | 164 |
| 171 ProfileMenuModel::~ProfileMenuModel() { | 165 ProfileMenuModel::~ProfileMenuModel() { |
| 172 } | 166 } |
| 173 | 167 |
| 174 // ui::SimpleMenuModel::Delegate implementation | 168 // ui::SimpleMenuModel::Delegate implementation |
| 175 bool ProfileMenuModel::IsCommandIdChecked(int command_id) const { | 169 bool ProfileMenuModel::IsCommandIdChecked(int command_id) const { |
| 176 return false; | 170 return false; |
| 177 } | 171 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 198 case COMMAND_CHOOSE_AVATAR_ICON: | 192 case COMMAND_CHOOSE_AVATAR_ICON: |
| 199 break; | 193 break; |
| 200 case COMMAND_CREATE_NEW_PROFILE: | 194 case COMMAND_CREATE_NEW_PROFILE: |
| 201 ProfileManager::CreateMultiProfileAsync(); | 195 ProfileManager::CreateMultiProfileAsync(); |
| 202 break; | 196 break; |
| 203 default: | 197 default: |
| 204 NOTREACHED(); | 198 NOTREACHED(); |
| 205 break; | 199 break; |
| 206 } | 200 } |
| 207 } | 201 } |
| OLD | NEW |