XWalk WebView patchset, README and LICENSE files.
[platform/framework/web/xwalk_webview.git] / patchset / 0016-Update-page-title-API.patch
1 From e991e5d9d5fb16a278a33109888bd182d83f554e Mon Sep 17 00:00:00 2001
2 From: Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
3 Date: Mon, 5 Aug 2013 14:47:28 +0300
4 Subject: [PATCH 16/33] Update page title API.
5
6 ---
7  base/strings/efl/eina_shared_string.cc               |  4 ++++
8  base/strings/efl/eina_shared_string.h                | 20 +++++++++++---------
9  .../browser/web_contents/web_contents_view_efl.cc    |  1 +
10  content/public/browser/web_contents_view_delegate.h  |  3 +++
11  content/shell/shell_web_contents_view_delegate.h     |  1 +
12  .../shell/shell_web_contents_view_delegate_efl.cc    |  3 +++
13  efl_webview/examples/main.cc                         |  9 +++++++++
14  efl_webview/lib/web_contents_view_delegate_xwalk.cc  |  6 ++++++
15  efl_webview/lib/web_contents_view_delegate_xwalk.h   |  1 +
16  efl_webview/lib/webview.cc                           |  1 +
17  efl_webview/lib/webview_callbacks.h                  |  4 +++-
18  11 files changed, 43 insertions(+), 10 deletions(-)
19
20 diff --git a/base/strings/efl/eina_shared_string.cc b/base/strings/efl/eina_shared_string.cc
21 index 48b4862..48bf291 100644
22 --- a/base/strings/efl/eina_shared_string.cc
23 +++ b/base/strings/efl/eina_shared_string.cc
24 @@ -16,6 +16,10 @@ EinaSharedString::EinaSharedString(const std::string& str)
25    : string_(eina_stringshare_add(str.c_str())) {
26  }
27  
28 +EinaSharedString::EinaSharedString(const string16& str)
29 +  : string_(eina_stringshare_add(std::string(str.begin(), str.end()).c_str())) {
30 +}
31 +
32  EinaSharedString::~EinaSharedString() {
33    if (string_)
34      eina_stringshare_del(string_);
35 diff --git a/base/strings/efl/eina_shared_string.h b/base/strings/efl/eina_shared_string.h
36 index 6fc0aee..b9752f1 100644
37 --- a/base/strings/efl/eina_shared_string.h
38 +++ b/base/strings/efl/eina_shared_string.h
39 @@ -2,23 +2,25 @@
40  // Use of this source code is governed by a BSD-style license that can be
41  // found in the LICENSE file.
42  
43 -#ifndef EINA_SHARED_STRING_H_
44 -#define EINA_SHARED_STRING_H_
45 -
46 -#include "base/base_export.h"
47 +#ifndef BASE_STRINGS_EFL_EINA_SHARED_STRING_H_
48 +#define BASE_STRINGS_EFL_EINA_SHARED_STRING_H_
49  
50  #include <Eina.h>
51  
52  #include <string>
53  
54 +#include "base/base_export.h"
55 +#include "base/string16.h"
56 +
57  namespace base {
58  
59  class BASE_EXPORT EinaSharedString {
60 -public:
61 + public:
62    EinaSharedString() : string_(0) { }
63    EinaSharedString(const EinaSharedString& other);
64    EinaSharedString(const char* str);
65    explicit EinaSharedString(const std::string&);
66 +  explicit EinaSharedString(const string16&);
67  
68    ~EinaSharedString();
69  
70 @@ -39,14 +41,14 @@ public:
71  
72    size_t Length() const { return string_ ? static_cast<size_t>(eina_stringshare_strlen(string_)) : 0; }
73  
74 -  static EinaSharedString Adopt(Eina_Stringshare*);
75 +  static EinaSharedString Adopt(Eina_Stringshare* str);
76  
77 -private:
78 + private:
79    const char* string_;
80  };
81  
82 -} // namespace base
83 +}  // namespace base
84  
85  using base::EinaSharedString;
86  
87 -#endif // EINA_SHARED_STRING_H_
88 +#endif  // BASE_STRINGS_EFL_EINA_SHARED_STRING_H_
89 diff --git a/content/browser/web_contents/web_contents_view_efl.cc b/content/browser/web_contents/web_contents_view_efl.cc
90 index 7c8a43a..371231c 100644
91 --- a/content/browser/web_contents/web_contents_view_efl.cc
92 +++ b/content/browser/web_contents/web_contents_view_efl.cc
93 @@ -147,6 +147,7 @@ RenderWidgetHostView* WebContentsViewEfl::CreateViewForPopupWidget(
94  }
95  
96  void WebContentsViewEfl::SetPageTitle(const string16& title) {
97 +  delegate_->UpdateTitle(title);
98  }
99  
100  void WebContentsViewEfl::SizeContents(const gfx::Size& size) {
101 diff --git a/content/public/browser/web_contents_view_delegate.h b/content/public/browser/web_contents_view_delegate.h
102 index 5d92ff4..7f13957 100644
103 --- a/content/public/browser/web_contents_view_delegate.h
104 +++ b/content/public/browser/web_contents_view_delegate.h
105 @@ -9,6 +9,8 @@
106  #include <gtk/gtk.h>
107  #elif defined(OS_MACOSX)
108  #import <Cocoa/Cocoa.h>
109 +#elif defined(TOOLKIT_EFL)
110 +#include "base/string16.h"
111  #endif
112  
113  #include "content/common/content_export.h"
114 @@ -84,6 +86,7 @@ class CONTENT_EXPORT WebContentsViewDelegate {
115  #elif defined(TOOLKIT_EFL)
116    virtual gfx::NativeView GetNativeView() const = 0;
117    virtual void Focus() = 0;
118 +  virtual void UpdateTitle(const string16& title) = 0;
119  #endif
120  };
121  
122 diff --git a/content/shell/shell_web_contents_view_delegate.h b/content/shell/shell_web_contents_view_delegate.h
123 index cb93fbf..2bdb6dd 100644
124 --- a/content/shell/shell_web_contents_view_delegate.h
125 +++ b/content/shell/shell_web_contents_view_delegate.h
126 @@ -49,6 +49,7 @@ class ShellWebContentsViewDelegate : public WebContentsViewDelegate {
127    virtual void SizeChanged(const gfx::Size& size) OVERRIDE;
128    void MenuItemSelected(int selection);
129  #elif defined(TOOLKIT_EFL)
130 +  virtual void UpdateTitle(const string16& title) OVERRIDE;
131    virtual gfx::NativeView GetNativeView() const OVERRIDE;
132    void SetNativeView(gfx::NativeView);
133  #endif
134 diff --git a/content/shell/shell_web_contents_view_delegate_efl.cc b/content/shell/shell_web_contents_view_delegate_efl.cc
135 index 0720a5c..8221da0 100644
136 --- a/content/shell/shell_web_contents_view_delegate_efl.cc
137 +++ b/content/shell/shell_web_contents_view_delegate_efl.cc
138 @@ -55,6 +55,9 @@ void ShellWebContentsViewDelegate::Focus() {
139      elm_object_focus_set(native_view_, EINA_TRUE);
140  }
141  
142 +void ShellWebContentsViewDelegate::UpdateTitle(const string16& title) {
143 +}
144 +
145  gfx::NativeView ShellWebContentsViewDelegate::GetNativeView() const {
146    return native_view_;
147  }
148 diff --git a/efl_webview/examples/main.cc b/efl_webview/examples/main.cc
149 index f1c06d2..0197d1a 100644
150 --- a/efl_webview/examples/main.cc
151 +++ b/efl_webview/examples/main.cc
152 @@ -52,6 +52,13 @@ on_progress(void *user_data, Evas_Object *xwalk_view, void *event_info)
153    /* FIXME : implement. */
154  }
155  
156 +static void
157 +on_title_changed(void *user_data, Evas_Object *xwalk_view, void *event_info)
158 +{
159 +    const char *title = (const char *)event_info;
160 +    elm_win_title_set((Evas_Object*)user_data, title);
161 +}
162 +
163  static void window_create()
164  {
165    /* Create elementary window */
166 @@ -128,6 +135,8 @@ static void window_create()
167  
168    evas_object_smart_callback_add(web_view, "load,progress",
169                                   on_progress, elm_window);
170 +  evas_object_smart_callback_add(web_view, "title,changed",
171 +                                 on_title_changed, elm_window);
172  
173    evas_object_resize(elm_window, window_width, window_height);
174    evas_object_show(elm_window);
175 diff --git a/efl_webview/lib/web_contents_view_delegate_xwalk.cc b/efl_webview/lib/web_contents_view_delegate_xwalk.cc
176 index 7160227..0b4c686 100644
177 --- a/efl_webview/lib/web_contents_view_delegate_xwalk.cc
178 +++ b/efl_webview/lib/web_contents_view_delegate_xwalk.cc
179 @@ -3,6 +3,7 @@
180  // found in the LICENSE file.
181  
182  #include "efl_webview/lib/web_contents_view_delegate_xwalk.h"
183 +#include "efl_webview/lib/webview.h"
184  
185  #include <Elementary.h>
186  
187 @@ -23,6 +24,11 @@ void WebContentsViewDelegateXWalk::Focus() {
188    elm_object_focus_set(native_view_, EINA_TRUE);
189  }
190  
191 +void WebContentsViewDelegateXWalk::UpdateTitle(const string16& title) {
192 +  ToWebViewPrivate(native_view_)->SmartCallback<webviewcallbacks::TitleChange>()
193 +                                  .Call(EinaSharedString(title));
194 +}
195 +
196  gfx::NativeView WebContentsViewDelegateXWalk::GetNativeView() const {
197    return native_view_;
198  }
199 diff --git a/efl_webview/lib/web_contents_view_delegate_xwalk.h b/efl_webview/lib/web_contents_view_delegate_xwalk.h
200 index ef0fa59..7de4723 100644
201 --- a/efl_webview/lib/web_contents_view_delegate_xwalk.h
202 +++ b/efl_webview/lib/web_contents_view_delegate_xwalk.h
203 @@ -25,6 +25,7 @@ class WebContentsViewDelegateXWalk : public content::WebContentsViewDelegate {
204        content::ContextMenuSourceType type) OVERRIDE;
205    virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
206    virtual void Focus() OVERRIDE;
207 +  virtual void UpdateTitle(const string16& title) OVERRIDE;
208    virtual gfx::NativeView GetNativeView() const OVERRIDE;
209  
210    void SetNativeView(Evas_Object*);
211 diff --git a/efl_webview/lib/webview.cc b/efl_webview/lib/webview.cc
212 index c9d559f..e9d51f9 100644
213 --- a/efl_webview/lib/webview.cc
214 +++ b/efl_webview/lib/webview.cc
215 @@ -22,6 +22,7 @@ const char evas_smart_xwalk_view_type[] = "Evas_Smart_Xwalk_View";
216  
217  const Evas_Smart_Cb_Description g_smart_callbacks[] = {
218    {callbacks::CallbackName<callbacks::LoadProgress>(), "d"},
219 +  {callbacks::CallbackName<callbacks::TitleChange>(), "s"},
220    {NULL, NULL}};
221  
222  struct XWalk_View_Smart_Data {
223 diff --git a/efl_webview/lib/webview_callbacks.h b/efl_webview/lib/webview_callbacks.h
224 index af67471..a5f6092 100644
225 --- a/efl_webview/lib/webview_callbacks.h
226 +++ b/efl_webview/lib/webview_callbacks.h
227 @@ -12,7 +12,8 @@ namespace xwalk {
228  namespace webviewcallbacks {
229  
230  enum CallbackType {
231 -    LoadProgress
232 +  LoadProgress,
233 +  TitleChange
234  };
235  
236  template <CallbackType>
237 @@ -69,6 +70,7 @@ struct CallBackInfo<callbackType> {                              \
238  
239  // Note: type 'void' means that no arguments are expected.
240  DECLARE_XWALK_VIEW_CALLBACK(LoadProgress, "load,progress", double*);
241 +DECLARE_XWALK_VIEW_CALLBACK(TitleChange, "title,changed", const char*);
242  
243  }  // namespace webviewcallbacks
244  
245 -- 
246 1.8.1.2
247