User agent getter was returning a pointer to a local variable, that was already
out of scope, when the pointer was returned and the pointed memory was often
overridden, so it wasn't possible to read valid user agent string. This patch
adds local string that holds current user agent, what partly fixes this issue.
After second call of user agent string getter, the string is overridden, so the
previously returned pointer is no longer valid, but fixing that requires
changing the architecture of the EWK API
Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=10844
Reviewed by: Jaesik Chang, Janusz Majnert, Piotr Tworek
Change-Id: I6eacce32b521254f5171f51e8ac7efb011df004e
Signed-off-by: Tomasz Czekala <t.czekala@partner.samsung.com>
const char* EWebView::GetUserAgent() const {
if (!web_contents_->GetUserAgentOverride().empty())
- return web_contents_->GetUserAgentOverride().c_str();
- return GetContentClient()->GetUserAgent().c_str();
+ user_agent_ = web_contents_->GetUserAgentOverride();
+ else
+ user_agent_ = GetContentClient()->GetUserAgent();
+ return user_agent_.c_str();
}
const char* EWebView::GetUserAgentAppName() const {
- return EflWebView::VersionInfo::GetInstance()->Name().c_str();
+ user_agent_app_name_ = EflWebView::VersionInfo::GetInstance()->Name();
+ return user_agent_app_name_.c_str();
}
const char* EWebView::GetSelectedText() const {
bool mouse_events_enabled_;
double text_zoom_factor_;
mutable std::string selected_text_;
+ mutable std::string user_agent_;
+ mutable std::string user_agent_app_name_;
scoped_ptr<_Ewk_Auth_Challenge> auth_challenge_;
#if defined(OS_TIZEN)