| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_contro
ller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu_contro
ller.h" |
| 6 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "chrome/browser/extensions/active_script_controller.h" |
| 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
| 12 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
| 17 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 18 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // The current profile. Weak. | 72 // The current profile. Weak. |
| 72 Profile* profile_; | 73 Profile* profile_; |
| 73 | 74 |
| 74 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; | 75 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(AsyncUninstaller); | 77 DISALLOW_COPY_AND_ASSIGN(AsyncUninstaller); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 @interface ExtensionActionContextMenuController () | 80 @interface ExtensionActionContextMenuController () |
| 80 - (void)onExtensionName:(id)sender; | 81 - (void)onExtensionName:(id)sender; |
| 82 - (void)onAlwaysRun:(id)sender; |
| 81 - (void)onOptions:(id)sender; | 83 - (void)onOptions:(id)sender; |
| 82 - (void)onUninstall:(id)sender; | 84 - (void)onUninstall:(id)sender; |
| 83 - (void)onHide:(id)sender; | 85 - (void)onHide:(id)sender; |
| 84 - (void)onManage:(id)sender; | 86 - (void)onManage:(id)sender; |
| 85 - (void)onInspect:(id)sender; | 87 - (void)onInspect:(id)sender; |
| 86 @end | 88 @end |
| 87 | 89 |
| 88 @implementation ExtensionActionContextMenuController | 90 @implementation ExtensionActionContextMenuController |
| 89 | 91 |
| 90 - (id)initWithExtension:(const Extension*)extension | 92 - (id)initWithExtension:(const Extension*)extension |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 [menu addItemWithTitle:base::SysUTF8ToNSString(extension_->name()) | 108 [menu addItemWithTitle:base::SysUTF8ToNSString(extension_->name()) |
| 107 action:@selector(onExtensionName:) | 109 action:@selector(onExtensionName:) |
| 108 keyEquivalent:@""]; | 110 keyEquivalent:@""]; |
| 109 [item setTarget:self]; | 111 [item setTarget:self]; |
| 110 [item setEnabled:extensions::ManifestURL::GetHomepageURL( | 112 [item setEnabled:extensions::ManifestURL::GetHomepageURL( |
| 111 extension_).is_valid()]; | 113 extension_).is_valid()]; |
| 112 | 114 |
| 113 // Separator. | 115 // Separator. |
| 114 [menu addItem:[NSMenuItem separatorItem]]; | 116 [menu addItem:[NSMenuItem separatorItem]]; |
| 115 | 117 |
| 118 // Always Run. Only displayed if there is an active script injection action. |
| 119 content::WebContents* activeTab = |
| 120 browser_->tab_strip_model()->GetActiveWebContents(); |
| 121 if (activeTab && |
| 122 extensions::ActiveScriptController::GetForWebContents(activeTab) |
| 123 ->HasActiveScriptAction(extension_)) { |
| 124 item = [menu addItemWithTitle: |
| 125 l10n_util::GetNSStringWithFixup(IDS_EXTENSIONS_ALWAYS_RUN) |
| 126 action:@selector(onAlwaysRun:) |
| 127 keyEquivalent:@""]; |
| 128 [item setTarget:self]; |
| 129 } |
| 130 |
| 116 // Options. | 131 // Options. |
| 117 item = [menu addItemWithTitle: | 132 item = [menu addItemWithTitle: |
| 118 l10n_util::GetNSStringWithFixup(IDS_EXTENSIONS_OPTIONS_MENU_ITEM) | 133 l10n_util::GetNSStringWithFixup(IDS_EXTENSIONS_OPTIONS_MENU_ITEM) |
| 119 action:@selector(onOptions:) | 134 action:@selector(onOptions:) |
| 120 keyEquivalent:@""]; | 135 keyEquivalent:@""]; |
| 121 [item setTarget:self]; | 136 [item setTarget:self]; |
| 122 [item setEnabled:extensions::ManifestURL::GetOptionsPage( | 137 [item setEnabled:extensions::ManifestURL::GetOptionsPage( |
| 123 extension_).spec().length() > 0]; | 138 extension_).spec().length() > 0]; |
| 124 | 139 |
| 125 | 140 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 GURL url(std::string(extension_urls::kGalleryBrowsePrefix) + | 181 GURL url(std::string(extension_urls::kGalleryBrowsePrefix) + |
| 167 std::string("/detail/") + extension_->id()); | 182 std::string("/detail/") + extension_->id()); |
| 168 OpenURLParams params(url, | 183 OpenURLParams params(url, |
| 169 Referrer(), | 184 Referrer(), |
| 170 NEW_FOREGROUND_TAB, | 185 NEW_FOREGROUND_TAB, |
| 171 content::PAGE_TRANSITION_LINK, | 186 content::PAGE_TRANSITION_LINK, |
| 172 false); | 187 false); |
| 173 browser_->OpenURL(params); | 188 browser_->OpenURL(params); |
| 174 } | 189 } |
| 175 | 190 |
| 191 - (void)onAlwaysRun:(id)sender { |
| 192 content::WebContents* activeTab = |
| 193 browser_->tab_strip_model()->GetActiveWebContents(); |
| 194 if (activeTab) { |
| 195 extensions::ActiveScriptController::GetForWebContents(activeTab) |
| 196 ->AlwaysRunOnVisibleOrigin(extension_); |
| 197 } |
| 198 } |
| 199 |
| 176 - (void)onOptions:(id)sender { | 200 - (void)onOptions:(id)sender { |
| 177 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension_).is_empty()); | 201 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension_).is_empty()); |
| 178 extensions::ExtensionTabUtil::OpenOptionsPage(extension_, browser_); | 202 extensions::ExtensionTabUtil::OpenOptionsPage(extension_, browser_); |
| 179 } | 203 } |
| 180 | 204 |
| 181 - (void)onUninstall:(id)sender { | 205 - (void)onUninstall:(id)sender { |
| 182 uninstaller_.reset(new AsyncUninstaller(extension_, browser_)); | 206 uninstaller_.reset(new AsyncUninstaller(extension_, browser_)); |
| 183 } | 207 } |
| 184 | 208 |
| 185 - (void)onHide:(id)sender { | 209 - (void)onHide:(id)sender { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return; | 249 return; |
| 226 | 250 |
| 227 [ExtensionPopupController showURL:url | 251 [ExtensionPopupController showURL:url |
| 228 inBrowser:browser_ | 252 inBrowser:browser_ |
| 229 anchoredAt:popupPoint | 253 anchoredAt:popupPoint |
| 230 arrowLocation:info_bubble::kTopRight | 254 arrowLocation:info_bubble::kTopRight |
| 231 devMode:YES]; | 255 devMode:YES]; |
| 232 } | 256 } |
| 233 | 257 |
| 234 @end | 258 @end |
| OLD | NEW |