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.
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(-)
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())) {
28 +EinaSharedString::EinaSharedString(const string16& str)
29 + : string_(eina_stringshare_add(std::string(str.begin(), str.end()).c_str())) {
32 EinaSharedString::~EinaSharedString() {
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
40 // Use of this source code is governed by a BSD-style license that can be
41 // found in the LICENSE file.
43 -#ifndef EINA_SHARED_STRING_H_
44 -#define EINA_SHARED_STRING_H_
46 -#include "base/base_export.h"
47 +#ifndef BASE_STRINGS_EFL_EINA_SHARED_STRING_H_
48 +#define BASE_STRINGS_EFL_EINA_SHARED_STRING_H_
54 +#include "base/base_export.h"
55 +#include "base/string16.h"
59 class BASE_EXPORT EinaSharedString {
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&);
70 @@ -39,14 +41,14 @@ public:
72 size_t Length() const { return string_ ? static_cast<size_t>(eina_stringshare_strlen(string_)) : 0; }
74 - static EinaSharedString Adopt(Eina_Stringshare*);
75 + static EinaSharedString Adopt(Eina_Stringshare* str);
85 using base::EinaSharedString;
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(
96 void WebContentsViewEfl::SetPageTitle(const string16& title) {
97 + delegate_->UpdateTitle(title);
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
107 #elif defined(OS_MACOSX)
108 #import <Cocoa/Cocoa.h>
109 +#elif defined(TOOLKIT_EFL)
110 +#include "base/string16.h"
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;
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);
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);
142 +void ShellWebContentsViewDelegate::UpdateTitle(const string16& title) {
145 gfx::NativeView ShellWebContentsViewDelegate::GetNativeView() const {
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. */
157 +on_title_changed(void *user_data, Evas_Object *xwalk_view, void *event_info)
159 + const char *title = (const char *)event_info;
160 + elm_win_title_set((Evas_Object*)user_data, title);
163 static void window_create()
165 /* Create elementary window */
166 @@ -128,6 +135,8 @@ static void window_create()
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);
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
180 // found in the LICENSE file.
182 #include "efl_webview/lib/web_contents_view_delegate_xwalk.h"
183 +#include "efl_webview/lib/webview.h"
185 #include <Elementary.h>
187 @@ -23,6 +24,11 @@ void WebContentsViewDelegateXWalk::Focus() {
188 elm_object_focus_set(native_view_, EINA_TRUE);
191 +void WebContentsViewDelegateXWalk::UpdateTitle(const string16& title) {
192 + ToWebViewPrivate(native_view_)->SmartCallback<webviewcallbacks::TitleChange>()
193 + .Call(EinaSharedString(title));
196 gfx::NativeView WebContentsViewDelegateXWalk::GetNativeView() const {
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;
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";
217 const Evas_Smart_Cb_Description g_smart_callbacks[] = {
218 {callbacks::CallbackName<callbacks::LoadProgress>(), "d"},
219 + {callbacks::CallbackName<callbacks::TitleChange>(), "s"},
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 {
236 template <CallbackType>
237 @@ -69,6 +70,7 @@ struct CallBackInfo<callbackType> { \
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*);
243 } // namespace webviewcallbacks