fixup! Implement initial native window 31/145931/7
authorYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 22 Aug 2017 11:44:17 +0000 (20:44 +0900)
committerSanghyup Lee <sh53.lee@samsung.com>
Mon, 4 Sep 2017 02:58:22 +0000 (02:58 +0000)
Change-Id: I52e57c4892d2985446e3710544d6723d61b3edd6
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
atom/browser/native_window_efl.cc [changed mode: 0755->0644]
atom/browser/native_window_efl.h [changed mode: 0755->0644]
vendor/brightray/brightray.gyp
vendor/brightray/browser/inspectable_web_contents_view_efl.cc
vendor/brightray/browser/inspectable_web_contents_view_efl.h

old mode 100755 (executable)
new mode 100644 (file)
index 031d5b7..de63057
@@ -27,56 +27,59 @@ NativeWindowEfl::NativeWindowEfl(
     brightray::InspectableWebContents* inspectable_web_contents,
     const mate::Dictionary& options,
     NativeWindow* parent)
-    : NativeWindow(inspectable_web_contents, options, parent) {
-//  options.Get(switches::kTitle, &title_);
+    : NativeWindow(inspectable_web_contents, options, parent),
+      fullscreenable_(true) {
+  options.Get(options::kTitle, &title_);
+  window_ = efl::WindowFactory::GetHostWindow(web_contents());
 
-  // Create Host window via elf::WindowFactory
-  window_ = efl::WindowFactory::GetHostWindow(web_contents_);
   DCHECK(window_);
 
-  gfx::Size size = gfx::Size(kDefaultWindowWidthDip, kDefaultWindowHeightDip);
-
   evas_object_smart_callback_add(window_, "delete,request",
       OnWindowDeleteRequest, this);
+  evas_object_resize(window_, kDefaultWindowWidthDip,
+      kDefaultWindowHeightDip);
 
-  evas_object_resize(window_, size.width(), size.height());
-
-  // Add a new box to the parent.
   Evas_Object* box = elm_box_add(window_);
   evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(window_, box);
   evas_object_show(box);
 
-  // Add view at the end of the pack list.
-  Evas_Object* view = static_cast<Evas_Object*>(web_contents_->GetNativeView());
-  evas_object_size_hint_align_set(view, EVAS_HINT_FILL, EVAS_HINT_FILL);
-  evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-  elm_box_pack_end(box, view);
+  web_view_ = static_cast<Evas_Object*>(web_contents()->GetNativeView());
+  evas_object_size_hint_align_set(web_view_, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  evas_object_size_hint_weight_set(web_view_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  elm_box_pack_end(box, web_view_);
 
-  web_contents_->Focus();
+  web_contents()->Focus();
 }
 
 void NativeWindowEfl::Close() {
   if(window_)
     evas_object_del(window_);
   window_ = nullptr;
+
+  CloseContents(web_contents());
 }
 
 void NativeWindowEfl::CloseImmediately() {
   NOTIMPLEMENTED();
+  if(window_)
+    evas_object_del(window_);
+  window_ = nullptr;
+  NotifyWindowClosed();
 }
 
 void NativeWindowEfl::Focus(bool focus) {
-  NOTIMPLEMENTED();
+  elm_object_focus_set(window_, focus);
 }
 
 bool NativeWindowEfl::IsFocused() {
-  NOTIMPLEMENTED();
-  return true;
+  return elm_object_focus_get(window_);
 }
 
 void NativeWindowEfl::Show() {
+  if (!window_ || !web_view_)
+    LOG(ERROR) << "There's no available window or webview.";
   evas_object_show(window_);
 }
 
@@ -179,12 +182,11 @@ bool NativeWindowEfl::IsMaximizable() {
 }
 
 void NativeWindowEfl::SetFullScreenable(bool fullscreenable) {
-  NOTIMPLEMENTED();
+  fullscreenable_ = fullscreenable;
 }
 
 bool NativeWindowEfl::IsFullScreenable() {
-  NOTIMPLEMENTED();
-  return true;
+  return fullscreenable_;
 }
 
 void NativeWindowEfl::SetClosable(bool closable) {
@@ -308,10 +310,9 @@ gfx::Rect NativeWindowEfl::WindowBoundsToContentBounds(const gfx::Rect& bounds)
 // static
 void NativeWindowEfl::OnWindowDeleteRequest(void* data, Evas_Object*, void*) {
   NativeWindowEfl* thiz = static_cast<NativeWindowEfl*>(data);
+  thiz->web_contents()->Close();
   if(!elm_win_autodel_get(thiz->window_))
     thiz->Close();
-  thiz->window_ = nullptr;
-  thiz->web_contents_->Close();
 }
 
 // static
old mode 100755 (executable)
new mode 100644 (file)
index ea2afd4..5546bf6
@@ -97,9 +97,10 @@ class NativeWindowEfl : public NativeWindow {
   static void OnWindowDeleteRequest(void* data, Evas_Object*, void*);
 
   Evas_Object* window_;
-  content::WebContents* web_contents_;
+  Evas_Object* web_view_;
 
   std::string title_;
+  bool fullscreenable_;
 
   DISALLOW_COPY_AND_ASSIGN(NativeWindowEfl);
 };
index e6d0ac6..972b432 100644 (file)
@@ -1,7 +1,7 @@
 {
   'variables': {
     # The libraries brightray will be compiled to.
-    'linux_system_libraries': 'dbus-1 x11 x11-xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss icu-i18n icu-uc'
+    'linux_system_libraries': 'dbus-1 evas x11 x11-xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss icu-i18n icu-uc'
   },
   'includes': [
     'filenames.gypi',
index 0dcec96..169cf7f 100644 (file)
@@ -6,12 +6,19 @@
 
 #include "browser/inspectable_web_contents_impl.h"
 #include "content/browser/web_contents/web_contents_impl.h"
+#include "efl/window_factory.h"
+#include "ui/gfx/geometry/size.h"
 
 namespace brightray {
 
+InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
+  return new InspectableWebContentsViewEfl(inspectable_web_contents);
+}
+
 InspectableWebContentsViewEfl::InspectableWebContentsViewEfl(
     InspectableWebContentsImpl* inspectable_web_contents)
-    : inspectable_web_contents_(inspectable_web_contents) {
+    : inspectable_web_contents_(inspectable_web_contents),
+      devtools_visible_(false) {
   content::WebContentsImpl* web_contents_impl = static_cast<
       content::WebContentsImpl*>(inspectable_web_contents->GetWebContents());
   web_contents_view_ = static_cast<content::WebContentsViewEfl*>(
@@ -22,19 +29,24 @@ InspectableWebContentsViewEfl::~InspectableWebContentsViewEfl() {
 }
 
 gfx::NativeView InspectableWebContentsViewEfl::GetNativeView() const {
-  if(web_contents_view_)
-    return web_contents_view_->GetNativeView();
+  return inspectable_web_contents_->GetWebContents()->GetNativeView();
 }
 
 void InspectableWebContentsViewEfl::ShowDevTools() {
-  NOTIMPLEMENTED();
+  if (devtools_visible_)
+    return;
 }
 
 void InspectableWebContentsViewEfl::CloseDevTools() {
-  NOTIMPLEMENTED();
+  if (devtools_visible_)
+    return;
 }
 
 bool InspectableWebContentsViewEfl::IsDevToolsViewShowing() {
+  return devtools_visible_;
+}
+
+bool InspectableWebContentsViewEfl::IsDevToolsViewFocused() {
   NOTIMPLEMENTED();
   return false;
 }
@@ -48,9 +60,8 @@ void InspectableWebContentsViewEfl::SetContentsResizingStrategy(
   NOTIMPLEMENTED();
 }
 
-InspectableWebContentsView* CreateInspectableContentsView(
-    InspectableWebContentsImpl* inspectable_web_contents) {
-  return nullptr;
+void InspectableWebContentsViewEfl::SetTitle(const base::string16& title) {
+  NOTIMPLEMENTED();
 }
 
 } // namespace brightray
index db703bc..f656054 100644 (file)
@@ -21,13 +21,15 @@ class InspectableWebContentsViewEfl : public InspectableWebContentsView {
   ~InspectableWebContentsViewEfl();
 
   // InspectableWebContentsView:
-  virtual gfx::NativeView GetNativeView() const override;
-  virtual void ShowDevTools() override;
-  virtual void CloseDevTools() override;
-  virtual bool IsDevToolsViewShowing() override;
-  virtual void SetIsDocked(bool docked) override;
-  virtual void SetContentsResizingStrategy(
+  gfx::NativeView GetNativeView() const override;
+  void ShowDevTools() override;
+  void CloseDevTools() override;
+  bool IsDevToolsViewShowing() override;
+  bool IsDevToolsViewFocused() override;
+  void SetIsDocked(bool docked) override;
+  void SetContentsResizingStrategy(
       const DevToolsContentsResizingStrategy& strategy) override;
+  void SetTitle(const base::string16& title) override;
 
   InspectableWebContentsImpl* inspectable_web_contents() {
     return inspectable_web_contents_;
@@ -37,6 +39,7 @@ class InspectableWebContentsViewEfl : public InspectableWebContentsView {
   // Owns us.
   InspectableWebContentsImpl* inspectable_web_contents_;
 
+  bool devtools_visible_;
   content::WebContentsViewEfl* web_contents_view_;
 
   DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewEfl);