diff --git a/cef1/include/capi/cef_app_capi.h b/cef1/include/capi/cef_app_capi.h index 8741966d6..c8762bede 100644 --- a/cef1/include/capi/cef_app_capi.h +++ b/cef1/include/capi/cef_app_capi.h @@ -87,6 +87,12 @@ CEF_EXPORT void cef_run_message_loop(); /// CEF_EXPORT void cef_quit_message_loop(); +/// +// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a +// modal message loop. Set to false (0) after exiting the modal message loop. +/// +CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop); + /// // Implement this structure to provide handler implementations. Methods will be // called on the thread indicated. diff --git a/cef1/include/capi/cef_browser_capi.h b/cef1/include/capi/cef_browser_capi.h index 18ded305b..e66763c5a 100644 --- a/cef1/include/capi/cef_browser_capi.h +++ b/cef1/include/capi/cef_browser_capi.h @@ -302,13 +302,6 @@ typedef struct _cef_browser_t { // Send a capture lost event to the browser. /// void (CEF_CALLBACK *send_capture_lost_event)(struct _cef_browser_t* self); - - /// - // Set to true (1) before calling Windows APIs like TrackPopupMenu that enter - // a modal message loop. - /// - void (CEF_CALLBACK *set_osmodal_loop)(struct _cef_browser_t* self, - int osModalLoop); } cef_browser_t; diff --git a/cef1/include/cef_app.h b/cef1/include/cef_app.h index 028bd71d1..213636883 100644 --- a/cef1/include/cef_app.h +++ b/cef1/include/cef_app.h @@ -91,6 +91,12 @@ void CefRunMessageLoop(); /*--cef()--*/ void CefQuitMessageLoop(); +/// +// Set to true before calling Windows APIs like TrackPopupMenu that enter a +// modal message loop. Set to false after exiting the modal message loop. +/// +/*--cef()--*/ +void CefSetOSModalLoop(bool osModalLoop); /// // Implement this interface to provide handler implementations. Methods will be diff --git a/cef1/include/cef_browser.h b/cef1/include/cef_browser.h index 9e0786d1b..4f3508f3d 100644 --- a/cef1/include/cef_browser.h +++ b/cef1/include/cef_browser.h @@ -339,13 +339,6 @@ class CefBrowser : public virtual CefBase { /// /*--cef()--*/ virtual void SendCaptureLostEvent() =0; - - /// - // Set to true before calling Windows APIs like TrackPopupMenu that enter a - // modal message loop. - /// - /*--cef()--*/ - virtual void SetOSModalLoop(bool osModalLoop) =0; }; #endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/cef1/libcef/browser_impl.cc b/cef1/libcef/browser_impl.cc index dcd9d60c9..fe54d04d5 100644 --- a/cef1/libcef/browser_impl.cc +++ b/cef1/libcef/browser_impl.cc @@ -361,11 +361,6 @@ void CefBrowserImpl::CloseDevTools() { base::Bind(&CefBrowserImpl::UIT_CloseDevTools, this)); } -#if !defined(OS_WIN) -void CefBrowserImpl::SetOSModalLoop(bool osModalLoop) { -} -#endif - WebKit::WebGeolocationClient* CefBrowserImpl::UIT_GetGeolocationClient() { if (!geolocation_client_) geolocation_client_ = new CefGeolocationClient(this); diff --git a/cef1/libcef/browser_impl.h b/cef1/libcef/browser_impl.h index b2ea92075..b08b1b551 100644 --- a/cef1/libcef/browser_impl.h +++ b/cef1/libcef/browser_impl.h @@ -116,7 +116,6 @@ class CefBrowserImpl : public CefBrowser { OVERRIDE; virtual void SendFocusEvent(bool setFocus) OVERRIDE; virtual void SendCaptureLostEvent() OVERRIDE; - virtual void SetOSModalLoop(bool osModalLoop) OVERRIDE; // Frame-related methods void Undo(CefRefPtr frame); diff --git a/cef1/libcef/browser_impl_win.cc b/cef1/libcef/browser_impl_win.cc index 3aded0abb..031a752cc 100644 --- a/cef1/libcef/browser_impl_win.cc +++ b/cef1/libcef/browser_impl_win.cc @@ -148,15 +148,6 @@ bool CefBrowserImpl::IsWindowRenderingDisabled() { return (window_info_.m_bWindowRenderingDisabled ? true : false); } -void CefBrowserImpl::SetOSModalLoop(bool osModalLoop) { - if (CefThread::CurrentlyOn(CefThread::UI)) { - MessageLoop::current()->set_os_modal_loop(osModalLoop); - } else { - CefThread::PostTask(CefThread::UI, FROM_HERE, - base::Bind(&CefBrowserImpl::SetOSModalLoop, this, osModalLoop)); - } -} - gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() { REQUIRE_UIT(); return window_info_.m_bWindowRenderingDisabled ? diff --git a/cef1/libcef/cef_context.cc b/cef1/libcef/cef_context.cc index 454e205de..1de4c9702 100644 --- a/cef1/libcef/cef_context.cc +++ b/cef1/libcef/cef_context.cc @@ -60,7 +60,7 @@ base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { : base::StringPiece(); } -#endif // defined(OS_MACOSX) +#endif // defined(OS_WIN) } // namespace @@ -215,6 +215,23 @@ void CefQuitMessageLoop() { _Context->process()->QuitMessageLoop(); } +void CefSetOSModalLoop(bool osModalLoop) { +#if defined(OS_WIN) + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (CefThread::CurrentlyOn(CefThread::UI)) { + MessageLoop::current()->set_os_modal_loop(osModalLoop); + } else { + CefThread::PostTask(CefThread::UI, FROM_HERE, + base::Bind(CefSetOSModalLoop, osModalLoop)); + } +#endif // defined(OS_WIN) +} + // CefContext diff --git a/cef1/libcef_dll/cpptoc/browser_cpptoc.cc b/cef1/libcef_dll/cpptoc/browser_cpptoc.cc index e8ecc591f..957427265 100644 --- a/cef1/libcef_dll/cpptoc/browser_cpptoc.cc +++ b/cef1/libcef_dll/cpptoc/browser_cpptoc.cc @@ -717,19 +717,6 @@ void CEF_CALLBACK browser_send_capture_lost_event(struct _cef_browser_t* self) { CefBrowserCppToC::Get(self)->SendCaptureLostEvent(); } -void CEF_CALLBACK browser_set_osmodal_loop(struct _cef_browser_t* self, - int osModalLoop) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserCppToC::Get(self)->SetOSModalLoop( - osModalLoop?true:false); -} - // CONSTRUCTOR - Do not edit by hand. @@ -776,7 +763,6 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls) struct_.struct_.send_mouse_wheel_event = browser_send_mouse_wheel_event; struct_.struct_.send_focus_event = browser_send_focus_event; struct_.struct_.send_capture_lost_event = browser_send_capture_lost_event; - struct_.struct_.set_osmodal_loop = browser_set_osmodal_loop; } #ifndef NDEBUG diff --git a/cef1/libcef_dll/ctocpp/browser_ctocpp.cc b/cef1/libcef_dll/ctocpp/browser_ctocpp.cc index 069fdb128..ea0b8408b 100644 --- a/cef1/libcef_dll/ctocpp/browser_ctocpp.cc +++ b/cef1/libcef_dll/ctocpp/browser_ctocpp.cc @@ -583,17 +583,6 @@ void CefBrowserCToCpp::SendCaptureLostEvent() { struct_->send_capture_lost_event(struct_); } -void CefBrowserCToCpp::SetOSModalLoop(bool osModalLoop) { - if (CEF_MEMBER_MISSING(struct_, set_osmodal_loop)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->set_osmodal_loop(struct_, - osModalLoop); -} - #ifndef NDEBUG template<> long CefCToCpp callback) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/cef1/tests/cefclient/cefclient_win.cpp b/cef1/tests/cefclient/cefclient_win.cpp index 88b0b3219..9703ecc0e 100644 --- a/cef1/tests/cefclient/cefclient_win.cpp +++ b/cef1/tests/cefclient/cefclient_win.cpp @@ -606,16 +606,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, break; case WM_ENTERMENULOOP: - if (!wParam && g_handler.get() && g_handler->GetBrowserHwnd()) { + if (!wParam) { // Entering the menu loop for the application menu. - g_handler->GetBrowser()->SetOSModalLoop(true); + CefSetOSModalLoop(true); } break; case WM_EXITMENULOOP: - if (!wParam && g_handler.get() && g_handler->GetBrowserHwnd()) { + if (!wParam) { // Exiting the menu loop for the application menu. - g_handler->GetBrowser()->SetOSModalLoop(false); + CefSetOSModalLoop(false); } break;