2013-04-14 07:36:48 +00:00
|
|
|
// Copyright (c) 2013 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.
|
|
|
|
|
2013-04-15 15:01:12 +00:00
|
|
|
#ifndef ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
2013-04-14 07:36:48 +00:00
|
|
|
|
2013-11-22 06:23:19 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/native_window_observer.h"
|
|
|
|
#include "atom/common/api/atom_api_event_emitter.h"
|
|
|
|
#include "atom/common/v8/scoped_persistent.h"
|
2013-04-15 16:25:08 +00:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class DictionaryValue;
|
|
|
|
}
|
2013-04-14 07:36:48 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
class NativeWindow;
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
class Window : public EventEmitter,
|
|
|
|
public NativeWindowObserver {
|
2013-04-15 16:25:08 +00:00
|
|
|
public:
|
|
|
|
virtual ~Window();
|
|
|
|
|
|
|
|
static void Initialize(v8::Handle<v8::Object> target);
|
|
|
|
|
|
|
|
NativeWindow* window() { return window_.get(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit Window(v8::Handle<v8::Object> wrapper,
|
|
|
|
base::DictionaryValue* options);
|
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
// Implementations of NativeWindowObserver.
|
|
|
|
virtual void OnPageTitleUpdated(bool* prevent_default,
|
|
|
|
const std::string& title) OVERRIDE;
|
2013-08-29 03:47:07 +00:00
|
|
|
virtual void OnLoadingStateChanged(bool is_loading) OVERRIDE;
|
2013-05-01 15:28:01 +00:00
|
|
|
virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
|
|
|
|
virtual void OnWindowClosed() OVERRIDE;
|
2013-05-24 09:58:39 +00:00
|
|
|
virtual void OnWindowBlur() OVERRIDE;
|
2013-06-06 11:45:48 +00:00
|
|
|
virtual void OnRendererUnresponsive() OVERRIDE;
|
|
|
|
virtual void OnRendererResponsive() OVERRIDE;
|
2013-12-06 07:53:40 +00:00
|
|
|
virtual void OnRenderViewDeleted(int process_id, int routing_id) OVERRIDE;
|
2013-06-10 12:50:25 +00:00
|
|
|
virtual void OnRendererCrashed() OVERRIDE;
|
2013-04-18 15:50:47 +00:00
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
private:
|
2013-12-11 07:48:19 +00:00
|
|
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-17 14:49:49 +00:00
|
|
|
|
|
|
|
// APIs for NativeWindow.
|
2013-12-11 07:48:19 +00:00
|
|
|
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Show(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Hide(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Maximize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Minimize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Center(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2014-02-24 04:08:33 +00:00
|
|
|
static void DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-12-11 07:48:19 +00:00
|
|
|
static void FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-15 16:25:08 +00:00
|
|
|
|
2013-04-18 07:09:53 +00:00
|
|
|
// APIs for WebContents.
|
2013-12-11 07:48:19 +00:00
|
|
|
static void GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-12-15 09:09:35 +00:00
|
|
|
static void IsWaitingForResponse(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-12-11 07:48:19 +00:00
|
|
|
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
// APIs for NavigationController.
|
2013-12-11 07:48:19 +00:00
|
|
|
static void LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GetURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Reload(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-12-15 09:09:35 +00:00
|
|
|
static void ReloadIgnoringCache(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-18 07:09:53 +00:00
|
|
|
|
2013-11-22 06:23:19 +00:00
|
|
|
// Called when capturePage is done.
|
2013-12-11 07:48:19 +00:00
|
|
|
void OnCapturePageDone(const RefCountedV8Function& callback,
|
2013-11-22 06:23:19 +00:00
|
|
|
const std::vector<unsigned char>& data);
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
scoped_ptr<NativeWindow> window_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Window);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
2013-04-14 07:36:48 +00:00
|
|
|
} // namespace atom
|
|
|
|
|
2013-04-15 15:01:12 +00:00
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|