| 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 14 matching lines...) Expand all Loading... |
| 25 #include "extensions/browser/management_policy.h" | 25 #include "extensions/browser/management_policy.h" |
| 26 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 27 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 | 30 |
| 31 using content::OpenURLParams; | 31 using content::OpenURLParams; |
| 32 using content::Referrer; | 32 using content::Referrer; |
| 33 using content::WebContents; | 33 using content::WebContents; |
| 34 using extensions::Extension; | 34 using extensions::Extension; |
| 35 using extensions::UninstalledExtensionInfo; |
| 35 | 36 |
| 36 ExtensionContextMenuModel::ExtensionContextMenuModel(const Extension* extension, | 37 ExtensionContextMenuModel::ExtensionContextMenuModel(const Extension* extension, |
| 37 Browser* browser, | 38 Browser* browser, |
| 38 PopupDelegate* delegate) | 39 PopupDelegate* delegate) |
| 39 : SimpleMenuModel(this), | 40 : SimpleMenuModel(this), |
| 40 extension_id_(extension->id()), | 41 extension_id_(extension->id()), |
| 41 browser_(browser), | 42 browser_(browser), |
| 42 profile_(browser->profile()), | 43 profile_(browser->profile()), |
| 43 delegate_(delegate) { | 44 delegate_(delegate) { |
| 44 InitMenu(extension); | 45 InitMenu(extension); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 NOTREACHED() << "Unknown option"; | 141 NOTREACHED() << "Unknown option"; |
| 141 break; | 142 break; |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 | 145 |
| 145 void ExtensionContextMenuModel::ExtensionUninstallAccepted() { | 146 void ExtensionContextMenuModel::ExtensionUninstallAccepted() { |
| 146 if (GetExtension()) { | 147 if (GetExtension()) { |
| 147 extensions::ExtensionSystem::Get(profile_) | 148 extensions::ExtensionSystem::Get(profile_) |
| 148 ->extension_service() | 149 ->extension_service() |
| 149 ->UninstallExtension(extension_id_, | 150 ->UninstallExtension(extension_id_, |
| 150 ExtensionService::UNINSTALL_REASON_USER_INITIATED, | 151 UninstalledExtensionInfo::REASON_USER_INITIATED, |
| 151 NULL); | 152 NULL); |
| 152 } | 153 } |
| 153 Release(); | 154 Release(); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void ExtensionContextMenuModel::ExtensionUninstallCanceled() { | 157 void ExtensionContextMenuModel::ExtensionUninstallCanceled() { |
| 157 Release(); | 158 Release(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 ExtensionContextMenuModel::~ExtensionContextMenuModel() {} | 161 ExtensionContextMenuModel::~ExtensionContextMenuModel() {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 180 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); | 181 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); |
| 181 AddSeparator(ui::NORMAL_SEPARATOR); | 182 AddSeparator(ui::NORMAL_SEPARATOR); |
| 182 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSION); | 183 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSION); |
| 183 } | 184 } |
| 184 | 185 |
| 185 const Extension* ExtensionContextMenuModel::GetExtension() const { | 186 const Extension* ExtensionContextMenuModel::GetExtension() const { |
| 186 ExtensionService* extension_service = | 187 ExtensionService* extension_service = |
| 187 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 188 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 188 return extension_service->GetExtensionById(extension_id_, false); | 189 return extension_service->GetExtensionById(extension_id_, false); |
| 189 } | 190 } |
| OLD | NEW |