[M49_2623] Chromium upversion to m49_2623 branch.
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / web_contents_efl_delegate_ewk.cc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "web_contents_efl_delegate_ewk.h"
6
7 #include "eweb_view.h"
8
9 WebContentsEflDelegateEwk::WebContentsEflDelegateEwk(EWebView* wv)
10     : web_view_(wv) {
11 }
12
13 bool WebContentsEflDelegateEwk::ShouldCreateWebContentsAsync(
14     content::WebContentsEflDelegate::NewWindowDecideCallback callback,
15     const GURL& target_url) {
16   // this method is called ONLY when creating new window - no matter what type
17   scoped_ptr<_Ewk_Policy_Decision> pd(
18       new _Ewk_Policy_Decision(web_view_, callback));
19   pd->ParseUrl(target_url);
20   web_view_->SmartCallback<EWebViewCallbacks::NewWindowPolicyDecision>().call(pd.get());
21
22   if (pd->isSuspended()) {
23     // it will be deleted later after it's used/ignored/downloaded
24     ignore_result(pd.release());
25   } else if (!pd->isDecided()) {
26     pd->Use();
27   }
28   return true;
29 }
30
31 bool WebContentsEflDelegateEwk::WebContentsCreateAsync(
32     content::WebContentsEflDelegate::WebContentsCreateCallback callback) {
33   web_view_->CreateNewWindow(callback);
34   return true;
35 }
36
37 void WebContentsEflDelegateEwk::SetUpSmartObject(void* platform_data, void* native_view) {
38   EWebView* new_web_view = static_cast<EWebView*>(platform_data);
39   Evas_Object* _native_view = static_cast<Evas_Object*>(native_view);
40   evas_object_smart_member_add(_native_view, new_web_view->evas_object());
41 }