Merge pull request #2297 from atom/get-user-agent
Implement getUserAgent API.
This commit is contained in:
commit
3250764e72
5 changed files with 15 additions and 0 deletions
|
@ -563,6 +563,10 @@ void WebContents::SetUserAgent(const std::string& user_agent) {
|
|||
base::Bind(&SetUserAgentInIO, getter, user_agent));
|
||||
}
|
||||
|
||||
std::string WebContents::GetUserAgent() {
|
||||
return web_contents()->GetUserAgentOverride();
|
||||
}
|
||||
|
||||
void WebContents::InsertCSS(const std::string& css) {
|
||||
web_contents()->InsertCSS(css);
|
||||
}
|
||||
|
@ -767,6 +771,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
|||
.SetMethod("_goToOffset", &WebContents::GoToOffset)
|
||||
.SetMethod("isCrashed", &WebContents::IsCrashed)
|
||||
.SetMethod("setUserAgent", &WebContents::SetUserAgent)
|
||||
.SetMethod("getUserAgent", &WebContents::GetUserAgent)
|
||||
.SetMethod("insertCSS", &WebContents::InsertCSS)
|
||||
.SetMethod("_executeJavaScript", &WebContents::ExecuteJavaScript)
|
||||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||
|
|
|
@ -63,6 +63,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void GoToOffset(int offset);
|
||||
bool IsCrashed() const;
|
||||
void SetUserAgent(const std::string& user_agent);
|
||||
std::string GetUserAgent();
|
||||
void InsertCSS(const std::string& css);
|
||||
void ExecuteJavaScript(const base::string16& code);
|
||||
void OpenDevTools(mate::Arguments* args);
|
||||
|
|
|
@ -269,6 +269,7 @@ registerWebViewElement = ->
|
|||
"goToOffset"
|
||||
"isCrashed"
|
||||
"setUserAgent"
|
||||
"getUserAgent"
|
||||
"executeJavaScript"
|
||||
"insertCSS"
|
||||
"openDevTools"
|
||||
|
|
|
@ -875,6 +875,10 @@ Whether the renderer process has crashed.
|
|||
|
||||
Overrides the user agent for this page.
|
||||
|
||||
### WebContents.getUserAgent()
|
||||
|
||||
Returns a `String` represents the user agent for this page.
|
||||
|
||||
### WebContents.insertCSS(css)
|
||||
|
||||
* `css` String
|
||||
|
|
|
@ -215,6 +215,10 @@ Whether the renderer process has crashed.
|
|||
|
||||
Overrides the user agent for guest page.
|
||||
|
||||
### `<webview>`.getUserAgent()
|
||||
|
||||
Returns a `String` represents the user agent for guest page.
|
||||
|
||||
### `<webview>`.insertCSS(css)
|
||||
|
||||
* `css` String
|
||||
|
|
Loading…
Reference in a new issue