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 "chrome/browser/extensions/extension_context_menu_model.h" | 5 #include "chrome/browser/extensions/extension_context_menu_model.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
10 #include "chrome/browser/extensions/extension_action.h" | 10 #include "chrome/browser/extensions/extension_action.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 extensions::ExtensionActionManager* extension_action_manager = | 163 extensions::ExtensionActionManager* extension_action_manager = |
164 extensions::ExtensionActionManager::Get(profile_); | 164 extensions::ExtensionActionManager::Get(profile_); |
165 extension_action_ = extension_action_manager->GetBrowserAction(*extension); | 165 extension_action_ = extension_action_manager->GetBrowserAction(*extension); |
166 if (!extension_action_) | 166 if (!extension_action_) |
167 extension_action_ = extension_action_manager->GetPageAction(*extension); | 167 extension_action_ = extension_action_manager->GetPageAction(*extension); |
168 | 168 |
169 std::string extension_name = extension->name(); | 169 std::string extension_name = extension->name(); |
170 // Ampersands need to be escaped to avoid being treated like | 170 // Ampersands need to be escaped to avoid being treated like |
171 // mnemonics in the menu. | 171 // mnemonics in the menu. |
172 ReplaceChars(extension_name, "&", "&&", &extension_name); | 172 base::ReplaceChars(extension_name, "&", "&&", &extension_name); |
173 AddItem(NAME, UTF8ToUTF16(extension_name)); | 173 AddItem(NAME, UTF8ToUTF16(extension_name)); |
174 AddSeparator(ui::NORMAL_SEPARATOR); | 174 AddSeparator(ui::NORMAL_SEPARATOR); |
175 AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM); | 175 AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM); |
176 AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); | 176 AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); |
177 if (extension_action_manager->GetBrowserAction(*extension)) | 177 if (extension_action_manager->GetBrowserAction(*extension)) |
178 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); | 178 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); |
179 AddSeparator(ui::NORMAL_SEPARATOR); | 179 AddSeparator(ui::NORMAL_SEPARATOR); |
180 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSION); | 180 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSION); |
181 } | 181 } |
182 | 182 |
183 const Extension* ExtensionContextMenuModel::GetExtension() const { | 183 const Extension* ExtensionContextMenuModel::GetExtension() const { |
184 ExtensionService* extension_service = | 184 ExtensionService* extension_service = |
185 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 185 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
186 return extension_service->GetExtensionById(extension_id_, false); | 186 return extension_service->GetExtensionById(extension_id_, false); |
187 } | 187 } |
OLD | NEW |