Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1628)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 518043003: Add saveImageFromDataURL() and use it in saveImageAt(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | public/web/WebViewClient.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 572e42bd4c3d09d6e3479a593b63e3b8d3a00b5e..e7ffa0fc2bd3df2950bc6a1519b5ffe63e9b0350 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -3296,18 +3296,18 @@ void WebViewImpl::copyImageAt(const WebPoint& point)
void WebViewImpl::saveImageAt(const WebPoint& point)
{
- if (!m_page)
+ if (!m_client)
return;
- KURL url = hitTestResultForWindowPos(point).absoluteImageURLIncludingCanvasDataURL();
+ Node* node = hitTestResultForWindowPos(point).innerNonSharedNode();
+ if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node)))
+ return;
- if (url.isEmpty())
+ String url = toElement(*node).imageSourceURL();
+ if (!KURL(KURL(), url).protocolIsData())
return;
Justin Novosad 2014/09/05 17:22:46 If the user attempts to save an image with an http
zino 2014/09/05 18:00:26 On 2014/09/05 17:22:46, junov wrote: If the user
Ken Russell (switch to Gerrit) 2014/09/11 00:43:06 Thanks for clarifying this.
- ResourceRequest request(url);
- request.setRequestContext(WebURLRequest::RequestContextDownload);
- m_page->deprecatedLocalMainFrame()->loader().client()->loadURLExternally(
- request, NavigationPolicyDownloadTo, WebString());
+ m_client->saveImageFromDataURL(url);
}
void WebViewImpl::dragSourceEndedAt(
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | public/web/WebViewClient.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698