| 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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 9 #include "chrome/common/url_constants.h" |
| 9 #include "grit/chromium_strings.h" | 10 #include "grit/chromium_strings.h" |
| 10 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 12 | 13 |
| 13 ProfileMenuModel::ProfileMenuModel(Profile* profile) | 14 ProfileMenuModel::ProfileMenuModel(Browser* browser) |
| 14 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 15 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| 15 profile_(profile) { | 16 browser_(browser) { |
| 17 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE, |
| 18 IDS_PROFILES_CUSTOMIZE_PROFILE); |
| 19 AddSeparator(); |
| 20 |
| 16 const string16 short_product_name = | 21 const string16 short_product_name = |
| 17 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 22 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| 18 AddItem(COMMAND_CREATE_NEW_PROFILE, l10n_util::GetStringFUTF16( | 23 AddItem(COMMAND_CREATE_NEW_PROFILE, l10n_util::GetStringFUTF16( |
| 19 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, short_product_name)); | 24 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION, short_product_name)); |
| 20 AddItemWithStringId(COMMAND_DELETE_PROFILE, | 25 AddItemWithStringId(COMMAND_DELETE_PROFILE, |
| 21 IDS_PROFILES_DELETE_PROFILE); | 26 IDS_PROFILES_DELETE_PROFILE); |
| 22 } | 27 } |
| 23 | 28 |
| 24 ProfileMenuModel::~ProfileMenuModel() { | 29 ProfileMenuModel::~ProfileMenuModel() { |
| 25 } | 30 } |
| 26 | 31 |
| 27 // ui::SimpleMenuModel::Delegate implementation | 32 // ui::SimpleMenuModel::Delegate implementation |
| 28 bool ProfileMenuModel::IsCommandIdChecked(int command_id) const { | 33 bool ProfileMenuModel::IsCommandIdChecked(int command_id) const { |
| 29 return false; | 34 return false; |
| 30 } | 35 } |
| 31 | 36 |
| 32 bool ProfileMenuModel::IsCommandIdEnabled(int command_id) const { | 37 bool ProfileMenuModel::IsCommandIdEnabled(int command_id) const { |
| 33 return true; | 38 return true; |
| 34 } | 39 } |
| 35 | 40 |
| 36 bool ProfileMenuModel::GetAcceleratorForCommandId(int command_id, | 41 bool ProfileMenuModel::GetAcceleratorForCommandId(int command_id, |
| 37 ui::Accelerator* accelerator) { | 42 ui::Accelerator* accelerator) { |
| 38 return false; | 43 return false; |
| 39 } | 44 } |
| 40 | 45 |
| 41 void ProfileMenuModel::ExecuteCommand(int command_id) { | 46 void ProfileMenuModel::ExecuteCommand(int command_id) { |
| 42 switch (command_id) { | 47 switch (command_id) { |
| 48 case COMMAND_CUSTOMIZE_PROFILE: |
| 49 browser_->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 50 break; |
| 43 case COMMAND_CREATE_NEW_PROFILE: | 51 case COMMAND_CREATE_NEW_PROFILE: |
| 44 ProfileManager::CreateMultiProfileAsync(); | 52 ProfileManager::CreateMultiProfileAsync(); |
| 45 break; | 53 break; |
| 46 case COMMAND_DELETE_PROFILE: | 54 case COMMAND_DELETE_PROFILE: |
| 47 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 55 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
| 48 profile_->GetPath()); | 56 browser_->profile()->GetPath()); |
| 49 break; | 57 break; |
| 50 default: | 58 default: |
| 51 NOTREACHED(); | 59 NOTREACHED(); |
| 52 break; | 60 break; |
| 53 } | 61 } |
| 54 } | 62 } |
| OLD | NEW |