return web_contents_ != NULL;
}
+void WebContents::LoadURL(const GURL& url) {
+ content::NavigationController::LoadURLParams params(url);
+ params.transition_type = content::PAGE_TRANSITION_TYPED;
+ params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
+ web_contents_->GetController().LoadURLWithParams(params);
+}
+
GURL WebContents::GetURL() const {
return web_contents_->GetURL();
}
web_contents_->Stop();
}
+void WebContents::Reload() {
+ web_contents_->GetController().Reload(false);
+}
+
+void WebContents::ReloadIgnoringCache() {
+ web_contents_->GetController().ReloadIgnoringCache(false);
+}
+
+bool WebContents::CanGoBack() const {
+ return web_contents_->GetController().CanGoBack();
+}
+
+bool WebContents::CanGoForward() const {
+ return web_contents_->GetController().CanGoForward();
+}
+
+bool WebContents::CanGoToOffset(int offset) const {
+ return web_contents_->GetController().CanGoToOffset(offset);
+}
+
+void WebContents::GoBack() {
+ web_contents_->GetController().GoBack();
+}
+
+void WebContents::GoForward() {
+ web_contents_->GetController().GoForward();
+}
+
+void WebContents::GoToIndex(int index) {
+ web_contents_->GetController().GoToIndex(index);
+}
+
+void WebContents::GoToOffset(int offset) {
+ web_contents_->GetController().GoToOffset(offset);
+}
+
int WebContents::GetRoutingID() const {
return web_contents_->GetRoutingID();
}
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("isAlive", &WebContents::IsAlive)
+ .SetMethod("loadUrl", &WebContents::LoadURL)
.SetMethod("getUrl", &WebContents::GetURL)
.SetMethod("getTitle", &WebContents::GetTitle)
.SetMethod("isLoading", &WebContents::IsLoading)
.SetMethod("isWaitingForResponse", &WebContents::IsWaitingForResponse)
.SetMethod("stop", &WebContents::Stop)
+ .SetMethod("reload", &WebContents::Reload)
+ .SetMethod("reloadIgnoringCache", &WebContents::ReloadIgnoringCache)
+ .SetMethod("canGoBack", &WebContents::CanGoBack)
+ .SetMethod("canGoForward", &WebContents::CanGoForward)
+ .SetMethod("canGoToOffset", &WebContents::CanGoToOffset)
+ .SetMethod("goBack", &WebContents::GoBack)
+ .SetMethod("goForward", &WebContents::GoForward)
+ .SetMethod("goToIndex", &WebContents::GoToIndex)
+ .SetMethod("goToOffset", &WebContents::GoToOffset)
.SetMethod("getRoutingId", &WebContents::GetRoutingID)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("isCrashed", &WebContents::IsCrashed)
content::WebContents* web_contents);
bool IsAlive() const;
+ void LoadURL(const GURL& url);
GURL GetURL() const;
string16 GetTitle() const;
bool IsLoading() const;
bool IsWaitingForResponse() const;
void Stop();
+ void Reload();
+ void ReloadIgnoringCache();
+ bool CanGoBack() const;
+ bool CanGoForward() const;
+ bool CanGoToOffset(int offset) const;
+ void GoBack();
+ void GoForward();
+ void GoToIndex(int index);
+ void GoToOffset(int offset);
int GetRoutingID() const;
int GetProcessID() const;
bool IsCrashed() const;
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/native_window.h"
#include "atom/common/native_mate_converters/function_converter.h"
-#include "atom/common/native_mate_converters/gurl_converter.h"
-#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/bind.h"
#include "base/callback.h"
-#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/web_contents.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
-using content::NavigationController;
-
namespace mate {
template<>
return WebContents::Create(isolate, window_->GetDevToolsWebContents());
}
-void Window::LoadURL(const GURL& url) {
- NavigationController& controller = window_->GetWebContents()->GetController();
-
- content::NavigationController::LoadURLParams params(url);
- params.transition_type = content::PAGE_TRANSITION_TYPED;
- params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
- controller.LoadURLWithParams(params);
-}
-
-bool Window::CanGoBack() {
- return window_->GetWebContents()->GetController().CanGoBack();
-}
-
-bool Window::CanGoForward() {
- return window_->GetWebContents()->GetController().CanGoForward();
-}
-
-bool Window::CanGoToOffset(int offset) {
- return window_->GetWebContents()->GetController().CanGoToOffset(offset);
-}
-
-void Window::GoBack() {
- window_->GetWebContents()->GetController().GoBack();
-}
-
-void Window::GoForward() {
- window_->GetWebContents()->GetController().GoForward();
-}
-
-void Window::GoToIndex(int index) {
- window_->GetWebContents()->GetController().GoToIndex(index);
-}
-
-void Window::GoToOffset(int offset) {
- window_->GetWebContents()->GetController().GoToOffset(offset);
-}
-
-void Window::Reload() {
- window_->GetWebContents()->GetController().Reload(false);
-}
-
-void Window::ReloadIgnoringCache() {
- window_->GetWebContents()->GetController().ReloadIgnoringCache(false);
-}
-
// static
void Window::BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype) {
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
.SetMethod("capturePage", &Window::CapturePage)
.SetMethod("_getWebContents", &Window::GetWebContents)
- .SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents)
- .SetMethod("loadUrl", &Window::LoadURL)
- .SetMethod("canGoBack", &Window::CanGoBack)
- .SetMethod("canGoForward", &Window::CanGoForward)
- .SetMethod("canGoToOffset", &Window::CanGoToOffset)
- .SetMethod("goBack", &Window::GoBack)
- .SetMethod("goForward", &Window::GoForward)
- .SetMethod("goToIndex", &Window::GoToIndex)
- .SetMethod("goToOffset", &Window::GoToOffset)
- .SetMethod("reload", &Window::Reload)
- .SetMethod("reloadIgnoringCache", &Window::ReloadIgnoringCache);
+ .SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
}
} // namespace api
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
- // APIs for NavigationController.
- void LoadURL(const GURL& url);
- bool CanGoBack();
- bool CanGoForward();
- bool CanGoToOffset(int offset);
- void GoBack();
- void GoForward();
- void GoToIndex(int index);
- void GoToOffset(int offset);
- void Reload();
- void ReloadIgnoringCache();
-
scoped_ptr<NativeWindow> window_;
DISALLOW_COPY_AND_ASSIGN(Window);
devtools.routingId == routingId
# Be compatible with old API.
+BrowserWindow::loadUrl = (url) -> @webContents.loadUrl(url)
BrowserWindow::getUrl = -> @webContents.getUrl()
+BrowserWindow::reload = -> @webContents.reload()
+BrowserWindow::reloadIgnoringCache = -> @webContents.reloadIgnoringCache()
BrowserWindow::getPageTitle = -> @webContents.getTitle()
BrowserWindow::isLoading = -> @webContents.isLoading()
BrowserWindow::isWaitingForResponse = -> @webContents.isWaitingForResponse()