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/extensions/extension_context_menu_model.h" | 5 #include "chrome/browser/extensions/extension_context_menu_model.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_action.h" | 14 #include "chrome/common/extensions/extension_action.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "grit/chromium_strings.h" | 19 #include "grit/chromium_strings.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
22 | 22 |
23 using content::OpenURLParams; | 23 using content::OpenURLParams; |
24 using content::Referrer; | 24 using content::Referrer; |
| 25 using content::WebContents; |
25 | 26 |
26 enum MenuEntries { | 27 enum MenuEntries { |
27 NAME = 0, | 28 NAME = 0, |
28 CONFIGURE, | 29 CONFIGURE, |
29 HIDE, | 30 HIDE, |
30 DISABLE, | 31 DISABLE, |
31 UNINSTALL, | 32 UNINSTALL, |
32 MANAGE, | 33 MANAGE, |
33 INSPECT_POPUP | 34 INSPECT_POPUP |
34 }; | 35 }; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (!extension) | 87 if (!extension) |
87 return false; | 88 return false; |
88 | 89 |
89 if (command_id == CONFIGURE) { | 90 if (command_id == CONFIGURE) { |
90 return extension->options_url().spec().length() > 0; | 91 return extension->options_url().spec().length() > 0; |
91 } else if (command_id == NAME) { | 92 } else if (command_id == NAME) { |
92 // The NAME links to the Homepage URL. If the extension doesn't have a | 93 // The NAME links to the Homepage URL. If the extension doesn't have a |
93 // homepage, we just disable this menu item. | 94 // homepage, we just disable this menu item. |
94 return extension->GetHomepageURL().is_valid(); | 95 return extension->GetHomepageURL().is_valid(); |
95 } else if (command_id == INSPECT_POPUP) { | 96 } else if (command_id == INSPECT_POPUP) { |
96 TabContents* contents = browser_->GetSelectedTabContents(); | 97 WebContents* contents = browser_->GetSelectedWebContents(); |
97 if (!contents) | 98 if (!contents) |
98 return false; | 99 return false; |
99 | 100 |
100 return extension_action_->HasPopup(ExtensionTabUtil::GetTabId(contents)); | 101 return extension_action_->HasPopup(ExtensionTabUtil::GetTabId(contents)); |
101 } else if (command_id == DISABLE || command_id == UNINSTALL) { | 102 } else if (command_id == DISABLE || command_id == UNINSTALL) { |
102 // Some extension types can not be disabled or uninstalled. | 103 // Some extension types can not be disabled or uninstalled. |
103 return Extension::UserMayDisable(extension->location()); | 104 return Extension::UserMayDisable(extension->location()); |
104 } | 105 } |
105 return true; | 106 return true; |
106 } | 107 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 169 } |
169 | 170 |
170 void ExtensionContextMenuModel::ExtensionUninstallCanceled() { | 171 void ExtensionContextMenuModel::ExtensionUninstallCanceled() { |
171 Release(); | 172 Release(); |
172 } | 173 } |
173 | 174 |
174 const Extension* ExtensionContextMenuModel::GetExtension() const { | 175 const Extension* ExtensionContextMenuModel::GetExtension() const { |
175 ExtensionService* extension_service = profile_->GetExtensionService(); | 176 ExtensionService* extension_service = profile_->GetExtensionService(); |
176 return extension_service->GetExtensionById(extension_id_, false); | 177 return extension_service->GetExtensionById(extension_id_, false); |
177 } | 178 } |
OLD | NEW |