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

Issue 1056533002: Implement <webview>.addContentScript/removeContentScript API [2] (Closed)

Created:
5 years, 8 months ago by Xi Han
Modified:
5 years, 8 months ago
Reviewers:
Fady Samuel, Devlin, xiyuan
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org, xiyuan
Base URL:
https://chromium.googlesource.com/chromium/src.git@webview_addremove_contentscripts_2
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Implement <webview>.addContentScript/removeContentScript API [2] This patch includes the changes that enables <webview>.addContentScript/removeContentScript API work on WebUI. -- Introduce WebUIURLFetcherGroup to manage a set of WebUIURLFetcher and response after all fetches are done. -- Move WebUIURLFetcher from web_view_internal_api.cc to a separate file. -- A refactoring is done in UserScriptLoader and ExtensionUserScriptLoader. Since webUI has different ways to load user script as extension does, so I revert some old refactoring in ExtensionUserScriptLoader and move all the loading related code from UserScriptLoader to ExtensionUserScriptLoader. This is the second patch in a series of patches: 1) Implement <webview>.addContentScript/removeContentScript API [1] (https://codereview.chromium.org/959413003) 2) Implement <webview>.addContentScript/removeContentScript API [2] (https://codereview.chromium.org/1056533002) 3) Implement <webview>.addContentScript/removeContentScript API [3] (https://codereview.chromium.org/1058113002) BUG=461052 Committed: https://crrev.com/feb6a64f153422f71952ec3a7cd4fc3c1a90e272 Cr-Commit-Position: refs/heads/master@{#326854}

Patch Set 1 : #

Patch Set 2 : Rebase and add more tests. #

Patch Set 3 : Fix a memory leak. #

Patch Set 4 : Rebase and move new added files to web_view directory. #

Patch Set 5 : Rebase. #

Patch Set 6 : #

Patch Set 7 : Fix a test. #

Total comments: 20

Patch Set 8 : Rebase after the first patch landed. #

Patch Set 9 : Refactoring in UserScriptLoader and etc. #

Total comments: 6

Patch Set 10 : #

Total comments: 16

Patch Set 11 : Another round of comments. #

Total comments: 18

Patch Set 12 : Revert the callback.reset() and etc. #

Total comments: 25

Patch Set 13 : nits. #

Patch Set 14 : Forward declaration and remove "<" overload. #

Total comments: 18

Patch Set 15 : Clean up. #

Total comments: 10

Patch Set 16 : nits. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1037 lines, -302 lines) Patch
M chrome/browser/extensions/api/declarative_content/content_action.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/ui/webui/webui_webview_browsertest.cc View 1 2 3 4 5 1 chunk +71 lines, -0 lines 0 comments Download
A + chrome/test/data/guest_from_opener.html View 1 0 chunks +-1 lines, --1 lines 0 comments Download
A + chrome/test/data/webui/inject_comm_channel.js View 2 chunks +1 line, -2 lines 0 comments Download
A + chrome/test/data/webui/inject_comm_channel_2.js View 1 2 chunks +0 lines, -4 lines 0 comments Download
M chrome/test/data/webui/webview_execute_script_test.js View 1 2 3 4 5 6 7 8 9 10 2 chunks +395 lines, -0 lines 0 comments Download
M extensions/browser/api/guest_view/web_view/web_view_internal_api.h View 1 2 3 4 5 6 11 3 chunks +2 lines, -8 lines 0 comments Download
M extensions/browser/api/guest_view/web_view/web_view_internal_api.cc View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +8 lines, -54 lines 0 comments Download
M extensions/browser/declarative_user_script_master.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +13 lines, -5 lines 0 comments Download
M extensions/browser/declarative_user_script_master.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +23 lines, -12 lines 0 comments Download
M extensions/browser/extension_user_script_loader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +22 lines, -2 lines 0 comments Download
M extensions/browser/extension_user_script_loader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 5 chunks +84 lines, -17 lines 0 comments Download
A extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +55 lines, -0 lines 0 comments Download
A extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +52 lines, -0 lines 0 comments Download
M extensions/browser/guest_view/web_view/web_view_content_script_manager.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M extensions/browser/guest_view/web_view/web_view_content_script_manager.cc View 1 2 3 4 5 6 2 chunks +2 lines, -1 line 0 comments Download
M extensions/browser/user_script_loader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 5 chunks +23 lines, -40 lines 0 comments Download
M extensions/browser/user_script_loader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +55 lines, -148 lines 0 comments Download
A extensions/browser/web_ui_user_script_loader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +71 lines, -0 lines 0 comments Download
A extensions/browser/web_ui_user_script_loader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +145 lines, -0 lines 0 comments Download
M extensions/extensions.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 8 chunks +14 lines, -10 lines 0 comments Download

Messages

Total messages: 58 (28 generated)
Xi Han
Hi Fady: this is the follow-up patch that makes the API work on webUI, PTAL. ...
5 years, 8 months ago (2015-04-01 15:43:05 UTC) #4
Xi Han
rdevlin.cronin@chromium.org: Fady is not familiar with these code, so I send this CL directly to ...
5 years, 8 months ago (2015-04-08 22:09:30 UTC) #7
Xi Han
Hi Fady: as discussed offline, I moved the new added files to web_view directory. PTAL, ...
5 years, 8 months ago (2015-04-09 21:43:13 UTC) #11
Fady Samuel
I don't fully understand the URLFetcher code so I can't really review that, but overall ...
5 years, 8 months ago (2015-04-16 19:30:56 UTC) #14
Xi Han
+ xiyuan@chromium.org: Please review webUI related changes.
5 years, 8 months ago (2015-04-16 19:32:46 UTC) #16
Devlin
High-level comments first. https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h File extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h (right): https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h#newcode23 extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h:23: class WebUIURLFetcherGroup : public base::RefCounted<WebUIURLFetcherGroup> { ...
5 years, 8 months ago (2015-04-16 20:19:29 UTC) #17
xiyuan
https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js File chrome/test/data/webui/webview_execute_script_test.js (right): https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js#newcode5 chrome/test/data/webui/webview_execute_script_test.js:5: var request_to_comm_channel_1 = 'connect'; nit: const var name should ...
5 years, 8 months ago (2015-04-16 21:07:58 UTC) #18
Xi Han
Take sometimes to answer all the questions and update my CL, PTAL, thanks. https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js File ...
5 years, 8 months ago (2015-04-17 21:44:21 UTC) #24
Devlin
https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h File extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h (right): https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h#newcode23 extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h:23: class WebUIURLFetcherGroup : public base::RefCounted<WebUIURLFetcherGroup> { On 2015/04/17 21:44:20, ...
5 years, 8 months ago (2015-04-17 22:05:06 UTC) #25
Xi Han
https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h File extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h (right): https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h#newcode23 extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h:23: class WebUIURLFetcherGroup : public base::RefCounted<WebUIURLFetcherGroup> { On 2015/04/17 22:05:05, ...
5 years, 8 months ago (2015-04-17 22:28:24 UTC) #26
Devlin
https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h File extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h (right): https://codereview.chromium.org/1056533002/diff/280001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h#newcode23 extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h:23: class WebUIURLFetcherGroup : public base::RefCounted<WebUIURLFetcherGroup> { On 2015/04/17 22:28:24, ...
5 years, 8 months ago (2015-04-17 22:40:15 UTC) #27
xiyuan
https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js File chrome/test/data/webui/webview_execute_script_test.js (right): https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js#newcode66 chrome/test/data/webui/webview_execute_script_test.js:66: [{"name": 'myrule', On 2015/04/17 21:44:20, Xi Han wrote: > ...
5 years, 8 months ago (2015-04-17 22:40:55 UTC) #28
Fady Samuel
https://codereview.chromium.org/1056533002/diff/420001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h File extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h (right): https://codereview.chromium.org/1056533002/diff/420001/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h#newcode5 extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h:5: #ifndef EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_H Update this?
5 years, 8 months ago (2015-04-20 13:01:04 UTC) #29
Xi Han
Even though there are tests failed, I would like send the update first, so you ...
5 years, 8 months ago (2015-04-20 22:40:10 UTC) #32
xiyuan
webui related LGTM with nits https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js File chrome/test/data/webui/webview_execute_script_test.js (right): https://codereview.chromium.org/1056533002/diff/280001/chrome/test/data/webui/webview_execute_script_test.js#newcode5 chrome/test/data/webui/webview_execute_script_test.js:5: var request_to_comm_channel_1 = 'connect'; ...
5 years, 8 months ago (2015-04-20 23:00:19 UTC) #33
Devlin
https://codereview.chromium.org/1056533002/diff/480001/extensions/browser/extension_user_script_loader.cc File extensions/browser/extension_user_script_loader.cc (right): https://codereview.chromium.org/1056533002/diff/480001/extensions/browser/extension_user_script_loader.cc#newcode201 extensions/browser/extension_user_script_loader.cc:201: void ExtensionUserScriptLoader::LoadScripts( This would be cleaner if we kept ...
5 years, 8 months ago (2015-04-20 23:48:25 UTC) #34
Xi Han
There are some refacotring in this patch: 1) make |user_scripts_| as a private member in ...
5 years, 8 months ago (2015-04-21 21:18:58 UTC) #38
Devlin
https://codereview.chromium.org/1056533002/diff/560001/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc File extensions/browser/api/guest_view/web_view/web_view_internal_api.cc (right): https://codereview.chromium.org/1056533002/diff/560001/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc#newcode359 extensions/browser/api/guest_view/web_view/web_view_internal_api.cc:359: base::Unretained(this), file))) I think I liked this better the ...
5 years, 8 months ago (2015-04-21 22:32:21 UTC) #39
Xi Han
PTAL, thanks! https://codereview.chromium.org/1056533002/diff/560001/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc File extensions/browser/api/guest_view/web_view/web_view_internal_api.cc (right): https://codereview.chromium.org/1056533002/diff/560001/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc#newcode359 extensions/browser/api/guest_view/web_view/web_view_internal_api.cc:359: base::Unretained(this), file))) On 2015/04/21 22:32:20, Devlin wrote: ...
5 years, 8 months ago (2015-04-22 15:32:11 UTC) #41
Devlin
https://codereview.chromium.org/1056533002/diff/600001/extensions/browser/declarative_user_script_master.h File extensions/browser/declarative_user_script_master.h (right): https://codereview.chromium.org/1056533002/diff/600001/extensions/browser/declarative_user_script_master.h#newcode9 extensions/browser/declarative_user_script_master.h:9: #include "extensions/browser/user_script_loader.h" I think a forward declaration would work ...
5 years, 8 months ago (2015-04-22 21:15:33 UTC) #42
Xi Han
PTAL, thanks! https://codereview.chromium.org/1056533002/diff/600001/extensions/browser/declarative_user_script_master.h File extensions/browser/declarative_user_script_master.h (right): https://codereview.chromium.org/1056533002/diff/600001/extensions/browser/declarative_user_script_master.h#newcode9 extensions/browser/declarative_user_script_master.h:9: #include "extensions/browser/user_script_loader.h" On 2015/04/22 21:15:33, Devlin wrote: ...
5 years, 8 months ago (2015-04-22 22:34:00 UTC) #45
Devlin
https://codereview.chromium.org/1056533002/diff/600001/extensions/browser/declarative_user_script_master.h File extensions/browser/declarative_user_script_master.h (right): https://codereview.chromium.org/1056533002/diff/600001/extensions/browser/declarative_user_script_master.h#newcode9 extensions/browser/declarative_user_script_master.h:9: #include "extensions/browser/user_script_loader.h" On 2015/04/22 22:33:59, Xi Han wrote: > ...
5 years, 8 months ago (2015-04-22 23:20:51 UTC) #46
Xi Han
Hi Devlin, please see my comments to see whether we are on the same page. ...
5 years, 8 months ago (2015-04-23 15:01:56 UTC) #49
Devlin
Also, please note for comments like preferring forward declarations over includes, or removing extraneous includes, ...
5 years, 8 months ago (2015-04-23 16:34:38 UTC) #50
Xi Han
PTAL, thanks! https://codereview.chromium.org/1056533002/diff/700001/extensions/browser/user_script_loader.cc File extensions/browser/user_script_loader.cc (left): https://codereview.chromium.org/1056533002/diff/700001/extensions/browser/user_script_loader.cc#oldcode37 extensions/browser/user_script_loader.cc:37: UserScriptLoader::SubstitutionMap* GetLocalizationMessages( On 2015/04/23 16:34:38, Devlin wrote: ...
5 years, 8 months ago (2015-04-23 17:50:40 UTC) #51
Devlin
LGTM with nits https://codereview.chromium.org/1056533002/diff/720001/extensions/browser/extension_user_script_loader.h File extensions/browser/extension_user_script_loader.h (right): https://codereview.chromium.org/1056533002/diff/720001/extensions/browser/extension_user_script_loader.h#newcode25 extensions/browser/extension_user_script_loader.h:25: using PathAndDefaultLocale = std::pair<base::FilePath, std::string>; Why ...
5 years, 8 months ago (2015-04-24 17:51:00 UTC) #52
Xi Han
https://codereview.chromium.org/1056533002/diff/720001/extensions/browser/extension_user_script_loader.h File extensions/browser/extension_user_script_loader.h (right): https://codereview.chromium.org/1056533002/diff/720001/extensions/browser/extension_user_script_loader.h#newcode25 extensions/browser/extension_user_script_loader.h:25: using PathAndDefaultLocale = std::pair<base::FilePath, std::string>; On 2015/04/24 17:50:59, Devlin ...
5 years, 8 months ago (2015-04-24 18:28:54 UTC) #53
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056533002/740001
5 years, 8 months ago (2015-04-24 18:32:35 UTC) #56
commit-bot: I haz the power
Committed patchset #16 (id:740001)
5 years, 8 months ago (2015-04-24 19:22:03 UTC) #57
commit-bot: I haz the power
5 years, 8 months ago (2015-04-24 19:22:57 UTC) #58
Message was sent while issue was closed.
Patchset 16 (id:??) landed as
https://crrev.com/feb6a64f153422f71952ec3a7cd4fc3c1a90e272
Cr-Commit-Position: refs/heads/master@{#326854}

Powered by Google App Engine
This is Rietveld 408576698