2013-04-14 15:36:48 +08: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 23:01:12 +08:00
|
|
|
#ifndef ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
2013-04-14 15:36:48 +08:00
|
|
|
|
2013-11-22 14:23:19 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2013-04-18 23:50:47 +08:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "browser/native_window_observer.h"
|
2014-01-07 19:32:40 +08:00
|
|
|
#include "common/api/atom_api_event_emitter.h"
|
2013-12-11 15:48:19 +08:00
|
|
|
#include "common/v8/scoped_persistent.h"
|
2013-04-16 00:25:08 +08:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class DictionaryValue;
|
|
|
|
}
|
2013-04-14 15:36:48 +08:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2013-04-16 00:25:08 +08:00
|
|
|
class NativeWindow;
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2013-04-18 23:50:47 +08:00
|
|
|
class Window : public EventEmitter,
|
|
|
|
public NativeWindowObserver {
|
2013-04-16 00:25:08 +08: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 23:50:47 +08:00
|
|
|
// Implementations of NativeWindowObserver.
|
|
|
|
virtual void OnPageTitleUpdated(bool* prevent_default,
|
|
|
|
const std::string& title) OVERRIDE;
|
2013-08-29 11:47:07 +08:00
|
|
|
virtual void OnLoadingStateChanged(bool is_loading) OVERRIDE;
|
2013-05-01 23:28:01 +08:00
|
|
|
virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
|
|
|
|
virtual void OnWindowClosed() OVERRIDE;
|
2013-05-24 17:58:39 +08:00
|
|
|
virtual void OnWindowBlur() OVERRIDE;
|
2013-06-06 19:45:48 +08:00
|
|
|
virtual void OnRendererUnresponsive() OVERRIDE;
|
|
|
|
virtual void OnRendererResponsive() OVERRIDE;
|
2013-12-06 15:53:40 +08:00
|
|
|
virtual void OnRenderViewDeleted(int process_id, int routing_id) OVERRIDE;
|
2013-06-10 20:50:25 +08:00
|
|
|
virtual void OnRendererCrashed() OVERRIDE;
|
2013-04-18 23:50:47 +08:00
|
|
|
|
2013-04-16 00:25:08 +08:00
|
|
|
private:
|
2013-12-11 15:48:19 +08:00
|
|
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-17 22:49:49 +08:00
|
|
|
|
|
|
|
// APIs for NativeWindow.
|
2013-12-11 15:48:19 +08: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);
|
|
|
|
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-16 00:25:08 +08:00
|
|
|
|
2013-04-18 15:09:53 +08:00
|
|
|
// APIs for WebContents.
|
2013-12-11 15:48:19 +08:00
|
|
|
static void GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-12-15 17:09:35 +08:00
|
|
|
static void IsWaitingForResponse(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-12-11 15:48:19 +08: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 15:09:53 +08:00
|
|
|
|
|
|
|
// APIs for NavigationController.
|
2013-12-11 15:48:19 +08: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 17:09:35 +08:00
|
|
|
static void ReloadIgnoringCache(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-18 15:09:53 +08:00
|
|
|
|
2013-11-22 14:23:19 +08:00
|
|
|
// Called when capturePage is done.
|
2013-12-11 15:48:19 +08:00
|
|
|
void OnCapturePageDone(const RefCountedV8Function& callback,
|
2013-11-22 14:23:19 +08:00
|
|
|
const std::vector<unsigned char>& data);
|
|
|
|
|
2013-04-16 00:25:08 +08:00
|
|
|
scoped_ptr<NativeWindow> window_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Window);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
2013-04-14 15:36:48 +08:00
|
|
|
} // namespace atom
|
|
|
|
|
2013-04-15 23:01:12 +08:00
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|