Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Add WebContents.insertCSS
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Oct 24, 2014
1 parent 1f08d50 commit e214ce6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_web_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions atom/renderer/lib/web-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,11 @@ registerWebViewElement = ->
"goToIndex"
"goToOffset"
"isCrashed"
"setUserAgent"
"executeJavaScript"
"insertCSS"
"send"
"setUserAgent"
# "getZoom"
# "insertCSS"
# "print"
# "setZoom"
# "terminate"
Expand Down
6 changes: 6 additions & 0 deletions docs/api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e214ce6

Please sign in to comment.