]> khamidou — GitHub mirrors - electron.git/commitdiff
Add WebContents.insertCSS
authorCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 13:04:50 +0000 (21:04 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 13:04:50 +0000 (21:04 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/renderer/lib/web-view.coffee
docs/api/browser-window.md

index 7f8db5855bb0866fcbe0e88a6b4b739bf74843e8..5d732cc97f3ca59b72da8aea69b5606a2423fe10 100644 (file)
@@ -293,6 +293,10 @@ void WebContents::SetUserAgent(const std::string& user_agent) {
   web_contents()->SetUserAgentOverride(user_agent);
 }
 
+void WebContents::InsertCSS(const std::string& css) {
+  web_contents()->InsertCSS(css);
+}
+
 void WebContents::ExecuteJavaScript(const base::string16& code) {
   web_contents()->GetMainFrame()->ExecuteJavaScript(code);
 }
@@ -365,6 +369,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
         .SetMethod("getProcessId", &WebContents::GetProcessID)
         .SetMethod("isCrashed", &WebContents::IsCrashed)
         .SetMethod("setUserAgent", &WebContents::SetUserAgent)
+        .SetMethod("insertCSS", &WebContents::InsertCSS)
         .SetMethod("_executeJavaScript", &WebContents::ExecuteJavaScript)
         .SetMethod("_send", &WebContents::SendIPCMessage)
         .SetMethod("setAutoSize", &WebContents::SetAutoSize)
index 6ee1184a53396109dcf0f9c671f729b91c9ebda5..393fd4969d1626baa5fbba7eb39ae7c047a58b2e 100644 (file)
@@ -55,6 +55,7 @@ class WebContents : public mate::EventEmitter,
   int GetProcessID() const;
   bool IsCrashed() const;
   void SetUserAgent(const std::string& user_agent);
+  void InsertCSS(const std::string& css);
   void ExecuteJavaScript(const base::string16& code);
   bool SendIPCMessage(const base::string16& channel,
                       const base::ListValue& args);
index 2a637fcf8460598e86a8b12ee5049ca3c0ec9671..0c16485d1d41f38c63cfdce6c8ae8b3dc41992ae 100644 (file)
@@ -511,11 +511,11 @@ registerWebViewElement = ->
     "goToIndex"
     "goToOffset"
     "isCrashed"
+    "setUserAgent"
     "executeJavaScript"
+    "insertCSS"
     "send"
-    "setUserAgent"
     # "getZoom"
-    # "insertCSS"
     # "print"
     # "setZoom"
     # "terminate"
index 72280a88c6edff86d08403525241a3ff65bdb30d..94c638a779022add91e4863c4aecf23bcdcd8708 100644 (file)
@@ -612,6 +612,12 @@ Whether the renderer process has crashed.
 
 Overrides the user agent for this page.
 
+### WebContents.insertCSS(css)
+
+* `css` String
+
+Injects CSS into this page.
+
 ### WebContents.executeJavaScript(code)
 
 * `code` String