Add "Always Run" menu item for script injection requests on Mac

BUG=405682

Review URL: https://codereview.chromium.org/495723002

Cr-Commit-Position: refs/heads/master@{#291228}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291228 0039d316-1c4b-4281-b951-d872f2087c98
parent 68d6080e
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu_controller.h" #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu_controller.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "chrome/browser/extensions/active_script_controller.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h" #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/extension_action_manager.h" #include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
...@@ -78,6 +79,7 @@ class AsyncUninstaller : public extensions::ExtensionUninstallDialog::Delegate { ...@@ -78,6 +79,7 @@ class AsyncUninstaller : public extensions::ExtensionUninstallDialog::Delegate {
@interface ExtensionActionContextMenuController () @interface ExtensionActionContextMenuController ()
- (void)onExtensionName:(id)sender; - (void)onExtensionName:(id)sender;
- (void)onAlwaysRun:(id)sender;
- (void)onOptions:(id)sender; - (void)onOptions:(id)sender;
- (void)onUninstall:(id)sender; - (void)onUninstall:(id)sender;
- (void)onHide:(id)sender; - (void)onHide:(id)sender;
...@@ -113,6 +115,19 @@ class AsyncUninstaller : public extensions::ExtensionUninstallDialog::Delegate { ...@@ -113,6 +115,19 @@ class AsyncUninstaller : public extensions::ExtensionUninstallDialog::Delegate {
// Separator. // Separator.
[menu addItem:[NSMenuItem separatorItem]]; [menu addItem:[NSMenuItem separatorItem]];
// Always Run. Only displayed if there is an active script injection action.
content::WebContents* activeTab =
browser_->tab_strip_model()->GetActiveWebContents();
if (activeTab &&
extensions::ActiveScriptController::GetForWebContents(activeTab)
->HasActiveScriptAction(extension_)) {
item = [menu addItemWithTitle:
l10n_util::GetNSStringWithFixup(IDS_EXTENSIONS_ALWAYS_RUN)
action:@selector(onAlwaysRun:)
keyEquivalent:@""];
[item setTarget:self];
}
// Options. // Options.
item = [menu addItemWithTitle: item = [menu addItemWithTitle:
l10n_util::GetNSStringWithFixup(IDS_EXTENSIONS_OPTIONS_MENU_ITEM) l10n_util::GetNSStringWithFixup(IDS_EXTENSIONS_OPTIONS_MENU_ITEM)
...@@ -173,6 +188,15 @@ class AsyncUninstaller : public extensions::ExtensionUninstallDialog::Delegate { ...@@ -173,6 +188,15 @@ class AsyncUninstaller : public extensions::ExtensionUninstallDialog::Delegate {
browser_->OpenURL(params); browser_->OpenURL(params);
} }
- (void)onAlwaysRun:(id)sender {
content::WebContents* activeTab =
browser_->tab_strip_model()->GetActiveWebContents();
if (activeTab) {
extensions::ActiveScriptController::GetForWebContents(activeTab)
->AlwaysRunOnVisibleOrigin(extension_);
}
}
- (void)onOptions:(id)sender { - (void)onOptions:(id)sender {
DCHECK(!extensions::ManifestURL::GetOptionsPage(extension_).is_empty()); DCHECK(!extensions::ManifestURL::GetOptionsPage(extension_).is_empty());
extensions::ExtensionTabUtil::OpenOptionsPage(extension_, browser_); extensions::ExtensionTabUtil::OpenOptionsPage(extension_, browser_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment