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

Unified Diff: extensions/browser/guest_view/web_view/web_view_guest.h

Issue 959413003: Implement <webview>.addContentScript/removeContentScript API [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/guest_view/web_view/web_view_guest.h
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.h b/extensions/browser/guest_view/web_view/web_view_guest.h
index cb190d9230b27414932897b33d77a9821599d5b6..408ce0acb3429bb6570d5cd4d8a66651b0917d1c 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.h
+++ b/extensions/browser/guest_view/web_view/web_view_guest.h
@@ -25,6 +25,7 @@ struct WebFindOptions;
namespace extensions {
+class DeclarativeUserScriptMaster;
class WebViewInternalFindFunction;
// A WebViewGuest provides the browser-side implementation of the <webview> API
@@ -235,11 +236,27 @@ class WebViewGuest : public GuestView<WebViewGuest>,
uint32 removal_mask,
const base::Closure& callback);
+ // Adds content script to inject on the guest.
+ void AddContentScripts(const std::string& script_name,
+ const UserScript& script);
+
+ // Removes content script by |script_name|.
+ void RemoveContentScripts(const std::string& script_name);
+
+ // Removes all content scripts added by the guest.
+ void RemoveAllContentScripts();
+
ScriptExecutor* script_executor() { return script_executor_.get(); }
+ const HostID* host_id() const { return host_id_.get(); }
+ void set_host_id(scoped_ptr<const HostID> host_id) {
+ host_id_ = host_id.Pass();
+ }
private:
friend class WebViewPermissionHelper;
+ using UserScriptMap = std::map<std::string, UserScript>;
+
explicit WebViewGuest(content::WebContents* owner_web_contents);
~WebViewGuest() override;
@@ -372,6 +389,13 @@ class WebViewGuest : public GuestView<WebViewGuest>,
// Determines if this guest accepts pinch-zoom gestures.
bool allow_scaling_;
+ // The ID of the injection host of the guest.
+ scoped_ptr<const HostID> host_id_;
+
+ DeclarativeUserScriptMaster* master_;
+
+ UserScriptMap user_script_map_;
+
// This is used to ensure pending tasks will not fire after this object is
// destroyed.
base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698