Add CefBrowserSettings.load_drops_disabled option for disabling default navigation resulting from drag & drop of URLs (issue #363).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@327 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-10-19 16:37:31 +00:00
parent 765e7b4c33
commit 026dacda76
5 changed files with 17 additions and 7 deletions

View File

@ -170,6 +170,11 @@ typedef struct _cef_browser_settings_t
/// ///
bool drag_drop_disabled; bool drag_drop_disabled;
///
// Disable default navigation resulting from drag & drop of URLs.
///
bool load_drops_disabled;
// The below values map to WebPreferences settings. // The below values map to WebPreferences settings.
/// ///

View File

@ -313,6 +313,7 @@ struct CefBrowserSettingsTraits {
static inline void set(const struct_type* src, struct_type* target, bool copy) static inline void set(const struct_type* src, struct_type* target, bool copy)
{ {
target->drag_drop_disabled = src->drag_drop_disabled; target->drag_drop_disabled = src->drag_drop_disabled;
target->load_drops_disabled = src->load_drops_disabled;
cef_string_set(src->standard_font_family.str, cef_string_set(src->standard_font_family.str,
src->standard_font_family.length, &target->standard_font_family, copy); src->standard_font_family.length, &target->standard_font_family, copy);

View File

@ -248,7 +248,7 @@ void BrowserDragDelegate::PrepareDragForFileContents(
} }
void BrowserDragDelegate::PrepareDragForUrl(const WebDropData& drop_data, void BrowserDragDelegate::PrepareDragForUrl(const WebDropData& drop_data,
ui::OSExchangeData* data) { ui::OSExchangeData* data) {
if (drop_data.url.SchemeIs("javascript")) { if (drop_data.url.SchemeIs("javascript")) {
// We don't want to allow javascript URLs to be dragged to the desktop. // We don't want to allow javascript URLs to be dragged to the desktop.
} else { } else {
@ -257,11 +257,11 @@ void BrowserDragDelegate::PrepareDragForUrl(const WebDropData& drop_data,
} }
void BrowserDragDelegate::DoDragging(const WebDropData& drop_data, void BrowserDragDelegate::DoDragging(const WebDropData& drop_data,
WebDragOperationsMask ops, WebDragOperationsMask ops,
const GURL& page_url, const GURL& page_url,
const std::string& page_encoding, const std::string& page_encoding,
const SkBitmap& image, const SkBitmap& image,
const gfx::Point& image_offset) { const gfx::Point& image_offset) {
ui::OSExchangeData data; ui::OSExchangeData data;
if (!drop_data.download_metadata.empty()) { if (!drop_data.download_metadata.empty()) {

View File

@ -441,6 +441,10 @@ void BrowserWebViewDelegate::setToolTipText(
GetWidgetHost()->SetTooltipText(tooltipStr); GetWidgetHost()->SetTooltipText(tooltipStr);
} }
bool BrowserWebViewDelegate::acceptsLoadDrops() {
return !browser_->settings().load_drops_disabled;
}
void BrowserWebViewDelegate::focusNext() { void BrowserWebViewDelegate::focusNext() {
CefRefPtr<CefClient> client = browser_->GetClient(); CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) { if (client.get()) {

View File

@ -109,7 +109,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
WebKit::WebDragOperationsMask mask, WebKit::WebDragOperationsMask mask,
const WebKit::WebImage& image, const WebKit::WebImage& image,
const WebKit::WebPoint& image_offset) OVERRIDE; const WebKit::WebPoint& image_offset) OVERRIDE;
virtual bool acceptsLoadDrops() OVERRIDE { return true; } virtual bool acceptsLoadDrops() OVERRIDE;
virtual void focusNext() OVERRIDE; virtual void focusNext() OVERRIDE;
virtual void focusPrevious() OVERRIDE; virtual void focusPrevious() OVERRIDE;
virtual void focusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; virtual void focusedNodeChanged(const WebKit::WebNode& node) OVERRIDE;