} // namespace
CommonWebContentsDelegate::CommonWebContentsDelegate()
- : owner_window_(nullptr),
- html_fullscreen_(false),
+ : html_fullscreen_(false),
native_fullscreen_(false) {
}
void CommonWebContentsDelegate::InitWithWebContents(
content::WebContents* web_contents,
NativeWindow* owner_window) {
- owner_window_ = owner_window;
+ owner_window_ = owner_window->GetWeakPtr();
web_contents->SetDelegate(this);
- NativeWindowRelay* relay = new NativeWindowRelay(owner_window_->GetWeakPtr());
+ NativeWindowRelay* relay = new NativeWindowRelay(owner_window_);
web_contents->SetUserData(relay->key, relay);
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
content::WebContents* guest,
const content::FileChooserParams& params) {
if (!web_dialog_helper_)
- web_dialog_helper_.reset(new WebDialogHelper(owner_window_));
+ web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
web_dialog_helper_->RunFileChooser(guest, params);
}
int request_id,
const base::FilePath& path) {
if (!web_dialog_helper_)
- web_dialog_helper_.reset(new WebDialogHelper(owner_window_));
+ web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
}
} else {
file_dialog::Filters filters;
base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
- if (!file_dialog::ShowSaveDialog(owner_window_, url, default_path,
+ if (!file_dialog::ShowSaveDialog(owner_window(), url, default_path,
filters, &path)) {
base::StringValue url_value(url);
web_contents_->CallClientFunction(
base::FilePath default_path;
std::vector<base::FilePath> paths;
int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
- if (!file_dialog::ShowOpenDialog(owner_window_, "", default_path,
+ if (!file_dialog::ShowOpenDialog(owner_window(), "", default_path,
filters, flag, &paths))
return;
return web_contents_.get();
}
+ NativeWindow* owner_window() const { return owner_window_.get(); }
+
protected:
// content::WebContentsDelegate:
content::WebContents* OpenURLFromTab(
void SetHtmlApiFullscreen(bool enter_fullscreen);
// The window that this WebContents belongs to.
- NativeWindow* owner_window_;
+ base::WeakPtr<NativeWindow> owner_window_;
// Whether window is fullscreened by HTML5 api.
bool html_fullscreen_;