Check that platform_delegate_ is non-NULL

This commit is contained in:
Marshall Greenblatt 2016-08-15 12:30:17 +03:00
parent cc24f60779
commit e0a22fe9fa
1 changed files with 45 additions and 29 deletions

View File

@ -596,7 +596,7 @@ void CefBrowserHostImpl::SetFocus(bool focus) {
if (focus) if (focus)
OnSetFocus(FOCUS_SOURCE_SYSTEM); OnSetFocus(FOCUS_SOURCE_SYSTEM);
else else if (platform_delegate_)
platform_delegate_->SendFocusEvent(false); platform_delegate_->SendFocusEvent(false);
} }
@ -940,7 +940,7 @@ void CefBrowserHostImpl::WasResized() {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->WasResized(); platform_delegate_->WasResized();
@ -958,7 +958,7 @@ void CefBrowserHostImpl::WasHidden(bool hidden) {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->WasHidden(hidden); platform_delegate_->WasHidden(hidden);
@ -976,7 +976,7 @@ void CefBrowserHostImpl::NotifyScreenInfoChanged() {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->NotifyScreenInfoChanged(); platform_delegate_->NotifyScreenInfoChanged();
@ -994,7 +994,7 @@ void CefBrowserHostImpl::Invalidate(PaintElementType type) {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->Invalidate(type); platform_delegate_->Invalidate(type);
@ -1007,7 +1007,7 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
content::NativeWebKeyboardEvent web_event; content::NativeWebKeyboardEvent web_event;
@ -1024,7 +1024,7 @@ void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
blink::WebMouseEvent web_event; blink::WebMouseEvent web_event;
@ -1042,7 +1042,7 @@ void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
blink::WebMouseEvent web_event; blink::WebMouseEvent web_event;
@ -1059,7 +1059,7 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
blink::WebMouseWheelEvent web_event; blink::WebMouseWheelEvent web_event;
@ -1078,7 +1078,7 @@ void CefBrowserHostImpl::SendCaptureLostEvent() {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->SendCaptureLostEvent(); platform_delegate_->SendCaptureLostEvent();
@ -1092,7 +1092,7 @@ void CefBrowserHostImpl::NotifyMoveOrResizeStarted() {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->NotifyMoveOrResizeStarted(); platform_delegate_->NotifyMoveOrResizeStarted();
@ -1118,6 +1118,8 @@ void CefBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {
} }
settings_.windowless_frame_rate = frame_rate; settings_.windowless_frame_rate = frame_rate;
if (platform_delegate_)
platform_delegate_->SetWindowlessFrameRate(frame_rate); platform_delegate_->SetWindowlessFrameRate(frame_rate);
} }
@ -1421,12 +1423,14 @@ void CefBrowserHostImpl::DestroyBrowser() {
#if defined(USE_AURA) #if defined(USE_AURA)
views::Widget* CefBrowserHostImpl::GetWindowWidget() const { views::Widget* CefBrowserHostImpl::GetWindowWidget() const {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!platform_delegate_)
return nullptr;
return platform_delegate_->GetWindowWidget(); return platform_delegate_->GetWindowWidget();
} }
CefRefPtr<CefBrowserView> CefBrowserHostImpl::GetBrowserView() const { CefRefPtr<CefBrowserView> CefBrowserHostImpl::GetBrowserView() const {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (IsViewsHosted()) if (IsViewsHosted() && platform_delegate_)
return platform_delegate_->GetBrowserView(); return platform_delegate_->GetBrowserView();
return nullptr; return nullptr;
} }
@ -1665,6 +1669,7 @@ void CefBrowserHostImpl::ViewText(const std::string& text) {
return; return;
} }
if (platform_delegate_)
platform_delegate_->ViewText(text); platform_delegate_->ViewText(text);
} }
@ -1678,7 +1683,7 @@ void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
handler->OnProtocolExecution(this, url.spec(), allow_os_execution); handler->OnProtocolExecution(this, url.spec(), allow_os_execution);
} }
if (allow_os_execution) if (allow_os_execution && platform_delegate_)
platform_delegate_->HandleExternalProtocol(url); platform_delegate_->HandleExternalProtocol(url);
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
@ -1708,6 +1713,7 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
} }
} }
if (platform_delegate_)
platform_delegate_->SendFocusEvent(true); platform_delegate_->SendFocusEvent(true);
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
@ -1780,7 +1786,7 @@ CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() {
return nullptr; return nullptr;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return nullptr; return nullptr;
return platform_delegate_->GetNSTextInputContext(); return platform_delegate_->GetNSTextInputContext();
@ -1802,7 +1808,7 @@ void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient(
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->HandleKeyEventBeforeTextInputClient(keyEvent); platform_delegate_->HandleKeyEventBeforeTextInputClient(keyEvent);
@ -1822,7 +1828,7 @@ void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient(
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
return platform_delegate_->HandleKeyEventAfterTextInputClient(keyEvent); return platform_delegate_->HandleKeyEventAfterTextInputClient(keyEvent);
@ -1849,7 +1855,7 @@ void CefBrowserHostImpl::DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->DragTargetDragEnter(drag_data, event, allowed_ops); platform_delegate_->DragTargetDragEnter(drag_data, event, allowed_ops);
@ -1869,7 +1875,7 @@ void CefBrowserHostImpl::DragTargetDragOver(const CefMouseEvent& event,
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->DragTargetDragOver(event, allowed_ops); platform_delegate_->DragTargetDragOver(event, allowed_ops);
@ -1887,7 +1893,7 @@ void CefBrowserHostImpl::DragTargetDragLeave() {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->DragTargetDragLeave(); platform_delegate_->DragTargetDragLeave();
@ -1905,7 +1911,7 @@ void CefBrowserHostImpl::DragTargetDrop(const CefMouseEvent& event) {
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->DragTargetDrop(event); platform_delegate_->DragTargetDrop(event);
@ -1923,6 +1929,9 @@ void CefBrowserHostImpl::DragSourceSystemDragEnded() {
return; return;
} }
if (!web_contents() || !platform_delegate_)
return;
platform_delegate_->DragSourceSystemDragEnded(); platform_delegate_->DragSourceSystemDragEnded();
} }
@ -1939,7 +1948,7 @@ void CefBrowserHostImpl::DragSourceEndedAt(
return; return;
} }
if (!web_contents()) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->DragSourceEndedAt(x, y, op); platform_delegate_->DragSourceEndedAt(x, y, op);
@ -2109,6 +2118,9 @@ bool CefBrowserHostImpl::PreHandleKeyboardEvent(
content::WebContents* source, content::WebContents* source,
const content::NativeWebKeyboardEvent& event, const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) { bool* is_keyboard_shortcut) {
if (!platform_delegate_)
return false;
if (client_.get()) { if (client_.get()) {
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler(); CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
if (handler.get()) { if (handler.get()) {
@ -2134,6 +2146,9 @@ void CefBrowserHostImpl::HandleKeyboardEvent(
if (event.skip_in_browser) if (event.skip_in_browser)
return; return;
if (!platform_delegate_)
return;
if (client_.get()) { if (client_.get()) {
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler(); CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
if (handler.get()) { if (handler.get()) {
@ -2235,7 +2250,7 @@ void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
content::JavaScriptDialogManager* content::JavaScriptDialogManager*
CefBrowserHostImpl::GetJavaScriptDialogManager( CefBrowserHostImpl::GetJavaScriptDialogManager(
content::WebContents* source) { content::WebContents* source) {
if (!javascript_dialog_manager_.get()) { if (!javascript_dialog_manager_.get() && platform_delegate_) {
javascript_dialog_manager_.reset( javascript_dialog_manager_.reset(
new CefJavaScriptDialogManager(this, new CefJavaScriptDialogManager(this,
platform_delegate_->CreateJavaScriptDialogRunner())); platform_delegate_->CreateJavaScriptDialogRunner()));
@ -2254,7 +2269,7 @@ bool CefBrowserHostImpl::HandleContextMenu(
content::WebContents* web_contents, content::WebContents* web_contents,
const content::ContextMenuParams& params) { const content::ContextMenuParams& params) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!menu_manager_.get()) { if (!menu_manager_.get() && platform_delegate_) {
menu_manager_.reset( menu_manager_.reset(
new CefMenuManager(this, new CefMenuManager(this,
platform_delegate_->CreateMenuRunner())); platform_delegate_->CreateMenuRunner()));
@ -2266,6 +2281,7 @@ void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source,
const gfx::Size& pref_size) { const gfx::Size& pref_size) {
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX)) #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (platform_delegate_)
platform_delegate_->SizeTo(pref_size.width(), pref_size.height()); platform_delegate_->SizeTo(pref_size.width(), pref_size.height());
#endif #endif
} }
@ -2932,7 +2948,7 @@ void CefBrowserHostImpl::SetFocusedFrame(int64 frame_id) {
gfx::Point CefBrowserHostImpl::GetScreenPoint(const gfx::Point& view) const { gfx::Point CefBrowserHostImpl::GetScreenPoint(const gfx::Point& view) const {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (platform_delegate_.get()) if (platform_delegate_)
return platform_delegate_->GetScreenPoint(view); return platform_delegate_->GetScreenPoint(view);
return gfx::Point(); return gfx::Point();
} }
@ -3018,7 +3034,7 @@ void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() {
void CefBrowserHostImpl::EnsureFileDialogManager() { void CefBrowserHostImpl::EnsureFileDialogManager() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!file_dialog_manager_.get()) { if (!file_dialog_manager_.get() && platform_delegate_) {
file_dialog_manager_.reset( file_dialog_manager_.reset(
new CefFileDialogManager(this, new CefFileDialogManager(this,
platform_delegate_->CreateFileDialogRunner())); platform_delegate_->CreateFileDialogRunner()));