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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | public/web/WebViewClient.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 // There isn't actually an image at these coordinates. Might be because 3284 // There isn't actually an image at these coordinates. Might be because
3285 // the window scrolled while the context menu was open or because the pa ge 3285 // the window scrolled while the context menu was open or because the pa ge
3286 // changed itself between when we thought there was an image here and wh en 3286 // changed itself between when we thought there was an image here and wh en
3287 // we actually tried to retreive the image. 3287 // we actually tried to retreive the image.
3288 // 3288 //
3289 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving 3289 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving
3290 // to do two hit tests. 3290 // to do two hit tests.
3291 return; 3291 return;
3292 } 3292 }
3293 3293
3294 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); 3294 m_page->deprecatedLocalMainFrame()->editor().copyImage(result);
Justin Novosad 2014/09/05 17:22:46 Don't we have the same bug here too?
zino 2014/09/05 18:00:25 On 2014/09/05 17:22:46, junov wrote: Internally,
3295 } 3295 }
3296 3296
3297 void WebViewImpl::saveImageAt(const WebPoint& point) 3297 void WebViewImpl::saveImageAt(const WebPoint& point)
3298 { 3298 {
3299 if (!m_page) 3299 if (!m_client)
3300 return; 3300 return;
3301 3301
3302 KURL url = hitTestResultForWindowPos(point).absoluteImageURLIncludingCanvasD ataURL(); 3302 Node* node = hitTestResultForWindowPos(point).innerNonSharedNode();
3303 3303 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node)))
3304 if (url.isEmpty())
3305 return; 3304 return;
3306 3305
3307 ResourceRequest request(url); 3306 String url = toElement(*node).imageSourceURL();
3308 request.setRequestContext(WebURLRequest::RequestContextDownload); 3307 if (!KURL(KURL(), url).protocolIsData())
3309 m_page->deprecatedLocalMainFrame()->loader().client()->loadURLExternally( 3308 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.
3310 request, NavigationPolicyDownloadTo, WebString()); 3309
3310 m_client->saveImageFromDataURL(url);
3311 } 3311 }
3312 3312
3313 void WebViewImpl::dragSourceEndedAt( 3313 void WebViewImpl::dragSourceEndedAt(
3314 const WebPoint& clientPoint, 3314 const WebPoint& clientPoint,
3315 const WebPoint& screenPoint, 3315 const WebPoint& screenPoint,
3316 WebDragOperation operation) 3316 WebDragOperation operation)
3317 { 3317 {
3318 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent:: MouseMoved, 3318 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent:: MouseMoved,
3319 0, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishab le, 0); 3319 0, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishab le, 0);
3320 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, 3320 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme,
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
4278 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4278 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4279 4279
4280 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4280 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4281 return false; 4281 return false;
4282 4282
4283 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4283 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4284 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4284 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4285 } 4285 }
4286 4286
4287 } // namespace blink 4287 } // namespace blink
OLDNEW
« 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