cefclient: Don't create multiple DevTools windows (issue #1920)

This commit is contained in:
Marshall Greenblatt
2016-06-10 14:33:07 -04:00
parent a11780730b
commit daac89badd
8 changed files with 96 additions and 35 deletions

View File

@@ -687,14 +687,33 @@ int ClientHandler::GetBrowserCount() const {
void ClientHandler::ShowDevTools(CefRefPtr<CefBrowser> browser,
const CefPoint& inspect_element_at) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute this method on the UI thread.
CefPostTask(TID_UI, base::Bind(&ClientHandler::ShowDevTools, this, browser,
inspect_element_at));
return;
}
CefWindowInfo windowInfo;
CefRefPtr<CefClient> client;
CefBrowserSettings settings;
if (CreatePopupWindow(browser, true, CefPopupFeatures(), windowInfo, client,
settings)) {
browser->GetHost()->ShowDevTools(windowInfo, client, settings,
inspect_element_at);
CefRefPtr<CefBrowserHost> host = browser->GetHost();
// Test if the DevTools browser already exists.
bool has_devtools = host->HasDevTools();
if (!has_devtools) {
// Create a new RootWindow for the DevTools browser that will be created
// by ShowDevTools().
has_devtools = CreatePopupWindow(browser, true, CefPopupFeatures(),
windowInfo, client, settings);
}
if (has_devtools) {
// Create the DevTools browser if it doesn't already exist.
// Otherwise, focus the existing DevTools browser and inspect the element
// at |inspect_element_at| if non-empty.
host->ShowDevTools(windowInfo, client, settings, inspect_element_at);
}
}