New issue
Advanced search Search tips

Issue 857235 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 27
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 1
Type: Bug

Blocking:
issue 869996



Sign in to add a comment

Extensions Click-to-Script: Update extension context menu for sites that don't match requested hosts

Project Member Reported by rdevlin....@chromium.org, Jun 27 2018

Issue description

Extensions may have hosts withheld, but might not want to run on every host.  We should update the context menu to properly handle the case when the extension doesn't want to run on that site.  This is a little subtle, since we don't want context menu items to be *radically* different on different tabs.
 

Comment 1 by bklmn@chromium.org, Jun 30 2018

For this state, I'm thinking we should keep the context menus the same pre-platform, but disable the host when it doesn't want to run. 

For styling, we should default to the view platform value for this. I assume we get this for free, but if we need color/transparency values I can dig those up. 

*attached a mock for posterity and clarity. 
diabled-allow.png
366 KB View Download
Hmm... I still think the ability to choose "on all sites" when the extension only wants to run on, say, one is a bit odd.  But I have no better suggestion, so I'm fine with this for now. :)

Thanks, bklmn@!
Labels: Proj-Crx-Cts
Closing the loop here - per screenshot in comment #1, let's plan to gray out <on current site> when the extension does not request access to current site. SG?
Blocking: 869996
Updating this again, from our discussion last week - we'll actually just not show the irrelevant options at all.
Project Member

Comment 7 by bugdroid1@chromium.org, Sep 13

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d4d8bfcdf11c50e8febb09cba7838baba59c842b

commit d4d8bfcdf11c50e8febb09cba7838baba59c842b
Author: Devlin Cronin <rdevlin.cronin@chromium.org>
Date: Thu Sep 13 17:39:39 2018

[Extensions Click-to-Script] Adjust context menu options display logic

Currently, all page access context menu options will display on all
pages. This isn't very helpful, because it will display the options on
all pages, whether the extension can run there or not (including on
restricted pages, like chrome://settings). Instead, we should only
display the run options on pages the extension can run on. Additionally,
we should only display the "On all sites" option if the extension can
run on all sites (or on a pattern sufficiently close to all sites, like
*://*.com/*).

Tweak the context menu logic so that the menu options are only shown if
the extension either wants to run or has been granted permission to run
on the current site. Only show the "all sites" option if the extension
has been granted all-sites-like permission or has requested
all-sites-like permission.

For the purposes of determining if an extension can run or wants to run
on a site, look at the origin only, rather than the path. This is
because if an extension has access to any part of the origin, it has
effective access to the full origin (through being able to XHR, etc).

Additionally, when revoking an extension's access to the site, we now
revoke any permissions that grant access to that origin. For instance,
if an extension has access to *.google.com, revoking access on
mail.google.com will revoke the entirety of the *.google.com pattern.

Add significant unit tests to ScriptingPermissionsModifier (for a new
method to get the page access for a given site) and
ExtensionContextMenuModel (for the menu options to display).

Bug:  857235 , 879383

Change-Id: I258e1a92b3b2957243d74d6204c9b2a1748cf5bd
Reviewed-on: https://chromium-review.googlesource.com/1208030
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591061}
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/chrome/browser/extensions/extension_action_runner.cc
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/chrome/browser/extensions/extension_context_menu_model.cc
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/chrome/browser/extensions/extension_context_menu_model_unittest.cc
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/chrome/browser/extensions/scripting_permissions_modifier.cc
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/chrome/browser/extensions/scripting_permissions_modifier.h
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/chrome/browser/extensions/scripting_permissions_modifier_unittest.cc
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/extensions/common/permissions/permission_set.cc
[modify] https://crrev.com/d4d8bfcdf11c50e8febb09cba7838baba59c842b/extensions/common/permissions/permission_set.h

Project Member

Comment 8 by bugdroid1@chromium.org, Sep 19

Labels: merge-merged-3538
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d

commit 9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d
Author: Devlin Cronin <rdevlin.cronin@chromium.org>
Date: Wed Sep 19 01:35:50 2018

[Merge M70] [Extensions Click-to-Script] Adjust context menu options display logic

Currently, all page access context menu options will display on all
pages. This isn't very helpful, because it will display the options on
all pages, whether the extension can run there or not (including on
restricted pages, like chrome://settings). Instead, we should only
display the run options on pages the extension can run on. Additionally,
we should only display the "On all sites" option if the extension can
run on all sites (or on a pattern sufficiently close to all sites, like
*://*.com/*).

Tweak the context menu logic so that the menu options are only shown if
the extension either wants to run or has been granted permission to run
on the current site. Only show the "all sites" option if the extension
has been granted all-sites-like permission or has requested
all-sites-like permission.

For the purposes of determining if an extension can run or wants to run
on a site, look at the origin only, rather than the path. This is
because if an extension has access to any part of the origin, it has
effective access to the full origin (through being able to XHR, etc).

Additionally, when revoking an extension's access to the site, we now
revoke any permissions that grant access to that origin. For instance,
if an extension has access to *.google.com, revoking access on
mail.google.com will revoke the entirety of the *.google.com pattern.

Add significant unit tests to ScriptingPermissionsModifier (for a new
method to get the page access for a given site) and
ExtensionContextMenuModel (for the menu options to display).

Bug:  857235 , 879383

TBR=rdevlin.cronin@chromium.org

(cherry picked from commit d4d8bfcdf11c50e8febb09cba7838baba59c842b)

Change-Id: I258e1a92b3b2957243d74d6204c9b2a1748cf5bd
Reviewed-on: https://chromium-review.googlesource.com/1208030
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#591061}
Reviewed-on: https://chromium-review.googlesource.com/1232889
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/branch-heads/3538@{#518}
Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811}
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/chrome/browser/extensions/extension_action_runner.cc
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/chrome/browser/extensions/extension_context_menu_model.cc
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/chrome/browser/extensions/extension_context_menu_model_unittest.cc
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/chrome/browser/extensions/scripting_permissions_modifier.cc
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/chrome/browser/extensions/scripting_permissions_modifier.h
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/chrome/browser/extensions/scripting_permissions_modifier_unittest.cc
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/extensions/common/permissions/permission_set.cc
[modify] https://crrev.com/9945f1ebbe27b559e25deb6cb0982ec3c6a55b5d/extensions/common/permissions/permission_set.h

Project Member

Comment 9 by bugdroid1@chromium.org, Sep 19

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/045564c1f7e3f70820d2a483bcf4fb468bd2e30c

commit 045564c1f7e3f70820d2a483bcf4fb468bd2e30c
Author: Devlin Cronin <rdevlin.cronin@chromium.org>
Date: Wed Sep 19 02:14:34 2018

[Merge M70] Compile fix for merge changes

M70 doesn't have revision b6a37c6678838985cc63448f10ca9414bc2462bb,
which renamed namespaces ::extensions::features to
::extensions_features (to avoid jumbo build failures). To make the
merge builds clean, update references to their old values
(::extensions::features::kRuntimeHostPermissions). This shouldn't
exacerbate any issues, since it doesn't change the values or contents
of the namespaces.

TBR=karandeepb@chromium.org (followup from previous merges to fix compile)

Bug: 878939,  857235 , 879383
Change-Id: I846953913f08c2b182946876622e75b77adb9b78
Reviewed-on: https://chromium-review.googlesource.com/1233116
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/branch-heads/3538@{#519}
Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811}
[modify] https://crrev.com/045564c1f7e3f70820d2a483bcf4fb468bd2e30c/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
[modify] https://crrev.com/045564c1f7e3f70820d2a483bcf4fb468bd2e30c/chrome/browser/extensions/extension_context_menu_model_unittest.cc

Status: Fixed (was: Assigned)
I think this should all be fixed.

Sign in to add a comment