Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Issue 366024: Add stub functions for chrome.* APIs in content scripts. ... (Closed)

Created:
11 years, 1 month ago by asargent_no_longer_on_chrome
Modified:
9 years, 7 months ago
Reviewers:
Aaron Boodman, rafaelw
CC:
chromium-reviews_googlegroups.com, brettw+cc_chromium.org, ben+cc_chromium.org, Erik does not do reviews, jam, pam+watch_chromium.org, Paweł Hajdan Jr., darin (slow to review)
Visibility:
Public.

Description

Add stub functions for chrome.* APIs in content scripts. Most of the extensions API is not supported in content scripts for security purposes. Instead the typical pattern is to use messaging between content scripts and a background page which executes them on behalf of the script. This is not immediately obvious to many extension developers, so this change adds an error message to help them better understand what's going on. BUG=26128 TEST=Try writing a content script that uses some of the extensions API stuff in chrome.tabs, chrome.windows, etc. You should see errors in the console telling you that it isn't supported in content scripts. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=31958

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 19

Patch Set 3 : '' #

Patch Set 4 : '' #

Total comments: 20

Patch Set 5 : '' #

Patch Set 6 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+271 lines, -3 lines) Patch
A chrome/browser/extensions/stubs_apitest.cc View 1 2 3 4 5 1 chunk +30 lines, -0 lines 0 comments Download
M chrome/chrome.gyp View 1 2 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/common/extensions/api/extension_api.json View 3 6 chunks +6 lines, -0 lines 0 comments Download
M chrome/renderer/resources/extension_process_bindings.js View 1 2 2 chunks +5 lines, -1 line 0 comments Download
M chrome/renderer/resources/renderer_extension_bindings.js View 1 2 3 4 2 chunks +49 lines, -1 line 0 comments Download
M chrome/renderer/user_script_slave.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
A chrome/test/data/extensions/api_test/stubs/background.html View 1 2 1 chunk +16 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/stubs/content_script.js View 1 2 3 4 1 chunk +150 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/stubs/manifest.json View 1 chunk +11 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
asargent_no_longer_on_chrome
11 years, 1 month ago (2009-11-05 18:22:45 UTC) #1
Aaron Boodman
Drive by http://codereview.chromium.org/366024/diff/18/2002 File chrome/renderer/resources/extension_process_bindings.js (right): http://codereview.chromium.org/366024/diff/18/2002#newcode26 Line 26: if (chrome.test && !chrome.test.getAPIDefinition) { Maybe ...
11 years, 1 month ago (2009-11-05 19:10:49 UTC) #2
asargent_no_longer_on_chrome
I ended up rewriting this a bit in the following ways: -Added a 'unprivileged' property ...
11 years, 1 month ago (2009-11-12 23:17:59 UTC) #3
rafaelw
lgtm http://codereview.chromium.org/366024/diff/8001/9002 File chrome/renderer/resources/renderer_extension_bindings.js (right): http://codereview.chromium.org/366024/diff/8001/9002#newcode212 Line 212: function createStub(name) { One idea: I think ...
11 years, 1 month ago (2009-11-13 02:44:25 UTC) #4
asargent_no_longer_on_chrome
http://codereview.chromium.org/366024/diff/8001/9002 File chrome/renderer/resources/renderer_extension_bindings.js (right): http://codereview.chromium.org/366024/diff/8001/9002#newcode212 Line 212: function createStub(name) { On 2009/11/13 02:44:25, rafaelw wrote: ...
11 years, 1 month ago (2009-11-13 19:40:30 UTC) #5
Aaron Boodman
11 years, 1 month ago (2009-11-13 21:12:54 UTC) #6
Defer to raf.

Powered by Google App Engine
This is Rietveld 408576698