| 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 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/api/prefs/pref_change_registrar.h" | 8 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // NOTE: You MUST keep this in sync with the |menuItems| NSArray below. | 89 // NOTE: You MUST keep this in sync with the |menuItems| NSArray below. |
| 90 enum { | 90 enum { |
| 91 kExtensionContextName = 0, | 91 kExtensionContextName = 0, |
| 92 kExtensionContextOptions = 2, | 92 kExtensionContextOptions = 2, |
| 93 kExtensionContextDisable = 3, | 93 kExtensionContextDisable = 3, |
| 94 kExtensionContextUninstall = 4, | 94 kExtensionContextUninstall = 4, |
| 95 kExtensionContextHide = 5, | 95 kExtensionContextHide = 5, |
| 96 kExtensionContextManage = 7, | 96 kExtensionContextManage = 7, |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 int CurrentTabId() { | |
| 100 Browser* browser = browser::GetLastActiveBrowser(); | |
| 101 if(!browser) | |
| 102 return -1; | |
| 103 WebContents* contents = chrome::GetActiveWebContents(browser); | |
| 104 if (!contents) | |
| 105 return -1; | |
| 106 return ExtensionTabUtil::GetTabId(contents); | |
| 107 } | |
| 108 | |
| 109 } // namespace | 99 } // namespace |
| 110 | 100 |
| 111 - (id)initWithExtension:(const Extension*)extension | 101 - (id)initWithExtension:(const Extension*)extension |
| 112 browser:(Browser*)browser | 102 browser:(Browser*)browser |
| 113 extensionAction:(ExtensionAction*)action{ | 103 extensionAction:(ExtensionAction*)action{ |
| 114 if ((self = [super initWithTitle:@""])) { | 104 if ((self = [super initWithTitle:@""])) { |
| 115 action_ = action; | 105 action_ = action; |
| 116 extension_ = extension; | 106 extension_ = extension; |
| 117 browser_ = browser; | 107 browser_ = browser; |
| 118 | 108 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 195 |
| 206 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 196 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
| 207 if ([menuItem tag] == kExtensionContextOptions) { | 197 if ([menuItem tag] == kExtensionContextOptions) { |
| 208 // Disable 'Options' if there are no options to set. | 198 // Disable 'Options' if there are no options to set. |
| 209 return extension_->options_url().spec().length() > 0; | 199 return extension_->options_url().spec().length() > 0; |
| 210 } | 200 } |
| 211 return YES; | 201 return YES; |
| 212 } | 202 } |
| 213 | 203 |
| 214 @end | 204 @end |
| OLD | NEW |