diff --git a/cef1/libcef/browser_webview_delegate_gtk.cc b/cef1/libcef/browser_webview_delegate_gtk.cc index fe1ab1e62..6829baa59 100644 --- a/cef1/libcef/browser_webview_delegate_gtk.cc +++ b/cef1/libcef/browser_webview_delegate_gtk.cc @@ -14,6 +14,7 @@ #include "net/base/net_errors.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" @@ -200,6 +201,18 @@ bool ShowJSFileChooser(GtkWidget* window, FilePath* path) { return (result == GTK_RESPONSE_ACCEPT); } +std::string GetDialogLabel(WebKit::WebFrame* webframe, + const std::string& label) { + const GURL& url = webframe->document().url(); + std::string urlStr; + if (!url.is_empty()) + urlStr = url.host(); + std::string labelStr = label; + if (!urlStr.empty()) + labelStr += " - " + urlStr; + return labelStr; +} + } // namespace // WebViewClient --------------------------------------------------------------- @@ -489,27 +502,27 @@ void BrowserWebViewDelegate::RegisterDragDrop() { void BrowserWebViewDelegate::ShowJavaScriptAlert( WebKit::WebFrame* webframe, const CefString& message) { std::string messageStr(message); - std::string urlStr(browser_->GetMainFrame()->GetURL()); + std::string labelStr(GetDialogLabel(webframe, "JavaScript Alert")); gfx::NativeView view = browser_->UIT_GetMainWndHandle(); GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(view)); ShowJSAlertDialog(window, - static_cast(urlStr.c_str()), + static_cast(labelStr.c_str()), static_cast(messageStr.c_str())); } bool BrowserWebViewDelegate::ShowJavaScriptConfirm( WebKit::WebFrame* webframe, const CefString& message) { std::string messageStr(message); - std::string urlStr(browser_->GetMainFrame()->GetURL()); + std::string labelStr(GetDialogLabel(webframe, "JavaScript Confirm")); gfx::NativeView view = browser_->UIT_GetMainWndHandle(); GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(view)); return ShowJSConfirmDialog( window, - static_cast(urlStr.c_str()), + static_cast(labelStr.c_str()), static_cast(messageStr.c_str())); } @@ -518,7 +531,7 @@ bool BrowserWebViewDelegate::ShowJavaScriptPrompt( const CefString& default_value, CefString* result) { std::string messageStr(message); std::string defaultStr(default_value); - std::string urlStr(browser_->GetMainFrame()->GetURL()); + std::string labelStr(GetDialogLabel(webframe, "JavaScript Prompt")); gfx::NativeView view = browser_->UIT_GetMainWndHandle(); GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(view)); @@ -526,7 +539,7 @@ bool BrowserWebViewDelegate::ShowJavaScriptPrompt( std::string return_val; bool resp = ShowJSPromptDialog( window, - static_cast(urlStr.c_str()), + static_cast(labelStr.c_str()), static_cast(messageStr.c_str()), static_cast(defaultStr.c_str()), &return_val);