'atom/browser/api/atom_api_power_monitor.h',
'atom/browser/api/atom_api_protocol.cc',
'atom/browser/api/atom_api_protocol.h',
+ 'atom/browser/api/atom_api_web_contents.cc',
+ 'atom/browser/api/atom_api_web_contents.h',
'atom/browser/api/atom_api_window.cc',
'atom/browser/api/atom_api_window.h',
'atom/browser/api/atom_browser_bindings.cc',
--- /dev/null
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/api/atom_api_web_contents.h"
+
+#include "content/public/browser/web_contents.h"
+#include "native_mate/object_template_builder.h"
+
+namespace atom {
+
+namespace api {
+
+WebContents::WebContents(content::WebContents* web_contents)
+ : web_contents_(web_contents) {
+}
+
+WebContents::~WebContents() {
+}
+
+mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ return mate::ObjectTemplateBuilder(isolate);
+}
+
+// static
+mate::Handle<WebContents> WebContents::Create(
+ v8::Isolate* isolate, content::WebContents* web_contents) {
+ return CreateHandle(isolate, new WebContents(web_contents));
+}
+
+} // namespace api
+
+} // namespace atom
--- /dev/null
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
+#define ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
+
+#include "atom/browser/api/event_emitter.h"
+#include "native_mate/handle.h"
+
+namespace content {
+class WebContents;
+}
+
+namespace atom {
+
+namespace api {
+
+class WebContents : public mate::EventEmitter {
+ public:
+ static mate::Handle<WebContents> Create(v8::Isolate* isolate,
+ content::WebContents* web_contents);
+
+ protected:
+ explicit WebContents(content::WebContents* web_contents);
+ virtual ~WebContents();
+
+ // mate::Wrappable implementations:
+ virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
+ v8::Isolate* isolate);
+
+ private:
+ content::WebContents* web_contents_; // Weak.
+
+ DISALLOW_COPY_AND_ASSIGN(WebContents);
+};
+
+} // namespace api
+
+} // namespace atom
+
+#endif // ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
#include "atom/browser/api/atom_api_window.h"
+#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"
window_->CapturePage(rect, base::Bind(&OnCapturePageDone, callback));
}
+mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
+ return WebContents::Create(isolate, window_->GetWebContents());
+}
+
+mate::Handle<WebContents> Window::GetDevToolsWebContents(
+ v8::Isolate* isolate) const {
+ return WebContents::Create(isolate, window_->GetDevToolsWebContents());
+}
+
string16 Window::GetPageTitle() {
return window_->GetWebContents()->GetTitle();
}
.SetMethod("blurWebView", &Window::BlurWebView)
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
.SetMethod("capturePage", &Window::CapturePage)
+ .SetMethod("getWebContents", &Window::GetWebContents)
+ .SetMethod("getDevToolsWebContents", &Window::GetDevToolsWebContents)
.SetMethod("getPageTitle", &Window::GetPageTitle)
.SetMethod("isLoading", &Window::IsLoading)
.SetMethod("isWaitingForResponse", &Window::IsWaitingForResponse)
#include "base/memory/scoped_ptr.h"
#include "atom/browser/native_window_observer.h"
#include "atom/browser/api/event_emitter.h"
+#include "native_mate/handle.h"
class GURL;
namespace api {
+class WebContents;
+
class Window : public mate::EventEmitter,
public NativeWindowObserver {
public:
void CapturePage(mate::Arguments* args);
// APIs for WebContents.
+ mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
+ mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
string16 GetPageTitle();
bool IsLoading();
bool IsWaitingForResponse();