From 2344b20e38a9c5e30e7498735508cbeb48c278cd Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 28 Jan 2013 18:48:54 +0000 Subject: [PATCH] Windows: Change CefBrowser::SetOSModalLoop to CefSetOSModalLoop because the functionality is not connected with any particular browser (issue #194). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1062 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef1/include/capi/cef_app_capi.h | 6 ++++++ cef1/include/capi/cef_browser_capi.h | 7 ------- cef1/include/cef_app.h | 6 ++++++ cef1/include/cef_browser.h | 7 ------- cef1/libcef/browser_impl.cc | 5 ----- cef1/libcef/browser_impl.h | 1 - cef1/libcef/browser_impl_win.cc | 9 --------- cef1/libcef/cef_context.cc | 19 ++++++++++++++++++- cef1/libcef_dll/cpptoc/browser_cpptoc.cc | 14 -------------- cef1/libcef_dll/ctocpp/browser_ctocpp.cc | 11 ----------- cef1/libcef_dll/ctocpp/browser_ctocpp.h | 1 - cef1/libcef_dll/libcef_dll.cc | 8 ++++++++ cef1/libcef_dll/wrapper/libcef_dll_wrapper.cc | 8 ++++++++ cef1/tests/cefclient/cefclient_win.cpp | 8 ++++---- 14 files changed, 50 insertions(+), 60 deletions(-) diff --git a/cef1/include/capi/cef_app_capi.h b/cef1/include/capi/cef_app_capi.h index 72dba9d50..2b25a4ef8 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 b98455e6f..3a0ac0299 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 4382b78df..87f9fe61d 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 f90e92518..dcc2fafb4 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 2d58479a6..53b017e52 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 1462fd038..aefcac35c 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 541bf32c3..b8e99a5a9 100644 --- a/cef1/tests/cefclient/cefclient_win.cpp +++ b/cef1/tests/cefclient/cefclient_win.cpp @@ -610,16 +610,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;