Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / runtime.h
index 52427a1..461f238 100644 (file)
@@ -10,7 +10,7 @@
 #include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/weak_ptr.h"
-#include "xwalk/runtime/browser/ui/native_app_window.h"
+#include "xwalk/runtime/browser/runtime_ui_delegate.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
 #include "content/public/browser/web_contents_delegate.h"
 namespace content {
 class ColorChooser;
 struct FileChooserParams;
+class RenderProcessHost;
+class SiteInstance;
 class WebContents;
 }
 
 namespace xwalk {
 
-class NativeAppWindow;
-class RuntimeContext;
+class XWalkBrowserContext;
+class RuntimeUIDelegate;
 
 // Runtime represents the running environment for a web page. It is responsible
-// for maintaning its owned WebContents and handling any communication between
-// WebContents and native app window.
+// for maintaning its owned WebContents.
 class Runtime : public content::WebContentsDelegate,
                 public content::WebContentsObserver,
-                public content::NotificationObserver,
-                public NativeAppWindowDelegate {
+                public content::NotificationObserver {
  public:
   // New "Runtimes" are also created from Runtime::WebContentsCreated which
   // is overridden WebContentsDelegate method. The "observer" is needed to
   // observe appearance and removal of such Runtime instances.
   class Observer {
-    public:
+   public:
       // Called when a new Runtime instance is added.
-      virtual void OnRuntimeAdded(Runtime* runtime) = 0;
+      virtual void OnNewRuntimeAdded(Runtime* new_runtime) = 0;
 
       // Called when a Runtime instance is removed.
-      virtual void OnRuntimeRemoved(Runtime* runtime) = 0;
+      virtual void OnRuntimeClosed(Runtime* runtime) = 0;
 
-    protected:
+   protected:
       virtual ~Observer() {}
   };
 
-  void SetObserver(Observer* observer) { observer_ = observer; }
+  // Fullscreen options.
+  enum FullscreenOptions {
+    NO_FULLSCREEN = 0,
+    // Fullscreen entered by launch with "--fullscreen".
+    FULLSCREEN_FOR_LAUNCH = 1,
+    // Fullscreen entered by HTML requestFullscreen.
+    FULLSCREEN_FOR_TAB = 1 << 1,
+  };
+  virtual ~Runtime();
 
-  // Create a new Runtime instance which binds to a default app window.
-  static Runtime* CreateWithDefaultWindow(RuntimeContext*,
-                                          const GURL&, Observer* = NULL);
-  // Create a new Runtime instance with the given browsing context.
-  static Runtime* Create(RuntimeContext*, Observer* = NULL);
+  void set_ui_delegate(RuntimeUIDelegate* ui_delegate) {
+    ui_delegate_ = ui_delegate;
+  }
+  void set_observer(Observer* observer) { observer_ = observer; }
 
-  // Attach to a default app window.
-  void AttachDefaultWindow();
-  // Attach to a app window created with 'params'.
-  void AttachWindow(const NativeAppWindow::CreateParams& params);
+  // Create a new Runtime instance with the given browsing context.
+  static Runtime* Create(XWalkBrowserContext* context,
+                         content::SiteInstance* site = nullptr);
 
   void LoadURL(const GURL& url);
+  void Show();
   void Close();
 
   content::WebContents* web_contents() const { return web_contents_.get(); }
-  NativeAppWindow* window() const;
-  RuntimeContext* runtime_context() const { return runtime_context_; }
+  // FIXME : This method should be removed.
+  NativeAppWindow* window();
   gfx::Image app_icon() const { return app_icon_; }
+  unsigned int fullscreen_options() { return fullscreen_options_; }
+  void set_fullscreen_options(unsigned int options) {
+    fullscreen_options_ = options;
+  }
+
+  content::RenderProcessHost* GetRenderProcessHost();
 
-#if defined(OS_TIZEN)
-  void CloseRootWindow();
-#endif
+  void set_remote_debugging_enabled(bool enable) {
+    remote_debugging_enabled_ = enable;
+  }
+  bool remote_debugging_enabled() const { return remote_debugging_enabled_; }
 
  protected:
-  Runtime(content::WebContents* web_contents, Observer* observer);
-  virtual ~Runtime();
+  explicit Runtime(content::WebContents* web_contents);
 
     // Overridden from content::WebContentsDelegate:
-  virtual content::WebContents* OpenURLFromTab(
+  content::WebContents* OpenURLFromTab(
       content::WebContents* source,
-      const content::OpenURLParams& params) OVERRIDE;
-  virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
-  virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents,
-                                          bool enter_fullscreen) OVERRIDE;
-  virtual bool IsFullscreenForTabOrPending(
-      const content::WebContents* web_contents) const OVERRIDE;
-  virtual void RequestToLockMouse(content::WebContents* web_contents,
-                                  bool user_gesture,
-                                  bool last_unlocked_by_target) OVERRIDE;
-  virtual void CloseContents(content::WebContents* source) OVERRIDE;
-  virtual void WebContentsCreated(content::WebContents* source_contents,
-                                  int64 source_frame_id,
-                                  const base::string16& frame_name,
-                                  const GURL& target_url,
-                                  content::WebContents* new_contents) OVERRIDE;
-  virtual void DidNavigateMainFramePostCommit(
-      content::WebContents* web_contents) OVERRIDE;
-  virtual content::JavaScriptDialogManager*
-      GetJavaScriptDialogManager() OVERRIDE;
-  virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
-  virtual void DeactivateContents(content::WebContents* contents) OVERRIDE;
-  virtual bool CanOverscrollContent() const OVERRIDE;
-  virtual bool PreHandleKeyboardEvent(
+      const content::OpenURLParams& params) override;
+  void LoadingStateChanged(content::WebContents* source,
+                           bool to_different_document) override;
+  void ToggleFullscreenModeForTab(content::WebContents* web_contents,
+                                  bool enter_fullscreen) override;
+  bool IsFullscreenForTabOrPending(
+      const content::WebContents* web_contents) const override;
+  void RequestToLockMouse(content::WebContents* web_contents,
+                          bool user_gesture,
+                          bool last_unlocked_by_target) override;
+  void CloseContents(content::WebContents* source) override;
+  void WebContentsCreated(content::WebContents* source_contents,
+                          int opener_render_frame_id,
+                          const base::string16& frame_name,
+                          const GURL& target_url,
+                          content::WebContents* new_contents) override;
+  void DidNavigateMainFramePostCommit(
+      content::WebContents* web_contents) override;
+  content::JavaScriptDialogManager*
+      GetJavaScriptDialogManager() override;
+  void ActivateContents(content::WebContents* contents) override;
+  void DeactivateContents(content::WebContents* contents) override;
+  bool CanOverscrollContent() const override;
+  bool PreHandleKeyboardEvent(
       content::WebContents* source,
       const content::NativeWebKeyboardEvent& event,
-      bool* is_keyboard_shortcut) OVERRIDE;
-  virtual void HandleKeyboardEvent(
+      bool* is_keyboard_shortcut) override;
+  void HandleKeyboardEvent(
       content::WebContents* source,
-      const content::NativeWebKeyboardEvent& event) OVERRIDE;
-  virtual content::ColorChooser* OpenColorChooser(
+      const content::NativeWebKeyboardEvent& event) override;
+  content::ColorChooser* OpenColorChooser(
       content::WebContents* web_contents,
       SkColor initial_color,
-      const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE;
-  virtual void RunFileChooser(
+      const std::vector<content::ColorSuggestion>& suggestions) override;
+  void RunFileChooser(
       content::WebContents* web_contents,
-      const content::FileChooserParams& params) OVERRIDE;
-  virtual void EnumerateDirectory(content::WebContents* web_contents,
-                                  int request_id,
-                                  const base::FilePath& path) OVERRIDE;
-  virtual void RequestMediaAccessPermission(
+      const content::FileChooserParams& params) override;
+  void EnumerateDirectory(content::WebContents* web_contents,
+                          int request_id,
+                          const base::FilePath& path) override;
+  void RequestMediaAccessPermission(
       content::WebContents* web_contents,
       const content::MediaStreamRequest& request,
-      const content::MediaResponseCallback& callback) OVERRIDE;
+      const content::MediaResponseCallback& callback) override;
 
   // Overridden from content::WebContentsObserver.
-  virtual void DidUpdateFaviconURL(int32 page_id,
-      const std::vector<content::FaviconURL>& candidates) OVERRIDE;
-  virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
+  void DidUpdateFaviconURL(
+      const std::vector<content::FaviconURL>& candidates) override;
 
   // Callback method for WebContents::DownloadImage.
   void DidDownloadFavicon(int id,
@@ -142,24 +155,9 @@ class Runtime : public content::WebContentsDelegate,
                           const std::vector<gfx::Size>& sizes);
 
   // NotificationObserver
-  virtual void Observe(int type,
-                       const content::NotificationSource& source,
-                       const content::NotificationDetails& details) OVERRIDE;
-
-  // NativeAppWindowDelegate implementation.
-  virtual void OnWindowDestroyed() OVERRIDE;
-
-  void ApplyWindowDefaultParams(NativeAppWindow::CreateParams* params);
-  void ApplyFullScreenParam(NativeAppWindow::CreateParams* params);
-
-#if defined(OS_TIZEN)
-  void ApplyRootWindowParams(NativeAppWindow::CreateParams* params);
-  void SetRootWindow(NativeAppWindow* window);
-  void InitRootWindow();
-#endif
-
-  // The browsing context.
-  xwalk::RuntimeContext* runtime_context_;
+  void Observe(int type,
+               const content::NotificationSource& source,
+               const content::NotificationDetails& details) override;
 
   // Notification manager.
   content::NotificationRegistrar registrar_;
@@ -167,28 +165,13 @@ class Runtime : public content::WebContentsDelegate,
   // The WebContents owned by this runtime.
   scoped_ptr<content::WebContents> web_contents_;
 
-  NativeAppWindow* window_;
-
-#if defined(OS_TIZEN)
-  NativeAppWindow* root_window_;
-#endif
-
   gfx::Image app_icon_;
 
-  base::WeakPtrFactory<Runtime> weak_ptr_factory_;
-
-  // Fullscreen options.
-  enum FullscreenOptions {
-    NO_FULLSCREEN = 0,
-    // Fullscreen entered by launch with "--fullscreen".
-    FULLSCREEN_FOR_LAUNCH = 1,
-    // Fullscreen entered by HTML requestFullscreen.
-    FULLSCREEN_FOR_TAB = 1 << 1,
-  };
-
   unsigned int fullscreen_options_;
-
+  bool remote_debugging_enabled_;
+  RuntimeUIDelegate* ui_delegate_;
   Observer* observer_;
+  base::WeakPtrFactory<Runtime> weak_ptr_factory_;
 };
 
 }  // namespace xwalk