#include "browser/javascript_dialog_manager_efl.h"
#include "browser/javascript_modal_dialog_efl.h"
+#include <content/public/browser/browser_thread.h>
+
+using content::BrowserThread;
+
JavaScriptModalCallbacksData::JavaScriptModalCallbacksData(content::JavaScriptMessageType javascript_message_type,
void* user_data)
: alert_callback_(NULL), user_data_(user_data), javascript_message_type_(javascript_message_type)
const base::string16& default_prompt_text,
const DialogClosedCallback& callback,
bool* did_suppress_message) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(web_contents);
dialog_closed_callback_ = callback;
content::WebContentsDelegateEfl* web_contents_delegate =
}
WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view)
- : web_view_(view),
- document_created_(false),
- should_open_new_window_(true),
- forward_backward_list_count_(0),
- weak_ptr_factory_(this) {
+ : web_view_(view)
+ , is_fullscreen_(false)
+ , web_contents_(NULL)
+ , document_created_(false)
+ , should_open_new_window_(true)
+ , dialog_manager_(NULL)
+ , forward_backward_list_count_(0)
+ , weak_ptr_factory_(this) {
BrowserContext* browser_context = web_view_->context()->browser_context();
- web_contents_.reset(WebContents::Create(WebContents::CreateParams(browser_context)));
+ web_contents_ = WebContents::Create(WebContents::CreateParams(browser_context));
web_contents_->SetDelegate(this);
- Observe(web_contents_.get());
+ Observe(web_contents_);
#ifdef TIZEN_AUTOFILL_SUPPORT
- AutofillManagerDelegateEfl::CreateForWebContents(web_contents_.get());
+ AutofillManagerDelegateEfl::CreateForWebContents(web_contents_);
AutofillManagerDelegateEfl * autofill_manager =
- AutofillManagerDelegateEfl::FromWebContents(web_contents_.get());
+ AutofillManagerDelegateEfl::FromWebContents(web_contents_);
autofill_manager->SetEWebView(view);
- AutofillDriverImpl::CreateForWebContentsAndDelegate(web_contents_.get(),
+ AutofillDriverImpl::CreateForWebContentsAndDelegate(web_contents_,
autofill_manager, EWebView::GetPlatformLocale(), AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER);
- PasswordManagerClientEfl::CreateForWebContents(web_contents_.get());
+ PasswordManagerClientEfl::CreateForWebContents(web_contents_);
#endif
}
WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view, WebContents* contents)
- : WebContentsObserver(contents),
- web_view_(view),
- web_contents_(contents),
- document_created_(false),
- should_open_new_window_(true),
- forward_backward_list_count_(0),
- weak_ptr_factory_(this) {
+ : WebContentsObserver(contents)
+ , web_view_(view)
+ , is_fullscreen_(false)
+ , web_contents_(contents)
+ , document_created_(false)
+ , should_open_new_window_(true)
+ , dialog_manager_(NULL)
+ , forward_backward_list_count_(0)
+ , weak_ptr_factory_(this) {
web_contents_->SetDelegate(this);
}
+WebContentsDelegateEfl::~WebContentsDelegateEfl() {
+ // It's important to delete web_contents_ before dialog_manager_
+ // destructor of web contents uses dialog_manager_
+
+ delete web_contents_;
+ delete dialog_manager_;
+}
+
void WebContentsDelegateEfl::NavigationStateChanged(const WebContents* source, unsigned changed_flags) {
if (changed_flags & content::INVALIDATE_TYPE_URL) {
const char* url = source->GetVisibleURL().spec().c_str();
JavaScriptDialogManager* WebContentsDelegateEfl::GetJavaScriptDialogManager() {
if (!dialog_manager_)
- dialog_manager_.reset(new JavaScriptDialogManagerEfl());
- return dialog_manager_.get();
+ dialog_manager_ = new JavaScriptDialogManagerEfl();
+ return dialog_manager_;
}
bool WebContentsDelegateEfl::OnMessageReceived(const IPC::Message& message) {
public WebContentsObserver {
public:
WebContentsDelegateEfl(EWebView*);
+ ~WebContentsDelegateEfl();
// Reusing the given WebContents instead of creating a new one.
WebContentsDelegateEfl(EWebView*, WebContents*);
CertificateRequestResultType* result);
EWebView* web_view() const { return web_view_; }
- WebContents* web_contents() const { return web_contents_.get(); }
+ WebContents* web_contents() const { return web_contents_; }
virtual void DidStartProvisionalLoadForFrame(int64 frame_id,
int64 parent_frame_id,
EWebView* web_view_;
bool is_fullscreen_;
- scoped_ptr<WebContents> web_contents_;
+ WebContents* web_contents_;
struct ContentSecurityPolicy {
ContentSecurityPolicy(const std::string& p, tizen_webview::ContentSecurityPolicyType type)
scoped_ptr<ContentSecurityPolicy> pending_content_security_policy_;
bool document_created_;
bool should_open_new_window_;
- scoped_ptr<JavaScriptDialogManagerEfl> dialog_manager_;
+ JavaScriptDialogManagerEfl* dialog_manager_;
int forward_backward_list_count_;
scoped_ptr<FaviconDownloader> favicon_downloader_;
base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;