Changeset 149923 in webkit
- Timestamp:
- May 10, 2013 10:03:10 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/mac/ChangeLog
r149922 r149923 1 2013-05-10 Brian J. Burg <burg@cs.washington.edu> 2 3 Web Inspector: Implement WK2 version of WebInspectorFrontendClient::save 4 https://bugs.webkit.org/show_bug.cgi?id=115564 5 6 Reviewed by Benjamin Poulain. 7 8 Clean up save() and append() implementations. 9 10 * WebCoreSupport/WebInspectorClient.h: 11 * WebCoreSupport/WebInspectorClient.mm: 12 (WebInspectorFrontendClient::save): 13 (WebInspectorFrontendClient::append): 14 1 15 2013-05-10 Laszlo Gombos <l.gombos@samsung.com> 2 16 -
trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h
r147482 r149923 124 124 RetainPtr<WebInspectorWindowController> m_windowController; 125 125 String m_inspectedURL; 126 HashMap<String, RetainPtr<NSURL>> m_s aveURLs;126 HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap; 127 127 }; -
trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
r149255 r149923 299 299 } 300 300 301 void WebInspectorFrontendClient::save(const String& refURL, const String& refContent, bool forceSaveAs) 302 { 303 String url = refURL; 304 String content = refContent; 305 auto saveToURL = ^(NSURL *URL) { 306 m_saveURLs.set(url, URL); 307 308 [content writeToURL:URL atomically:YES encoding:NSUTF8StringEncoding error:NULL]; 309 core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.savedURL(\"%@\")", URL.absoluteString]); 301 void WebInspectorFrontendClient::save(const String& suggestedURL, const String& content, bool forceSaveDialog) 302 { 303 ASSERT(!suggestedURL.isEmpty()); 304 305 NSURL *platformURL = m_suggestedToActualURLMap.get(suggestedURL).get(); 306 if (!platformURL) { 307 platformURL = [NSURL URLWithString:suggestedURL]; 308 // The user must confirm new filenames before we can save to them. 309 forceSaveDialog = true; 310 } 311 312 ASSERT(platformURL); 313 if (!platformURL) 314 return; 315 316 // Necessary for the block below. 317 String suggestedURLCopy = suggestedURL; 318 String contentCopy = content; 319 320 auto saveToURL = ^(NSURL *actualURL) { 321 ASSERT(actualURL); 322 323 m_suggestedToActualURLMap.set(suggestedURLCopy, actualURL); 324 [contentCopy writeToURL:actualURL atomically:YES encoding:NSUTF8StringEncoding error:NULL]; 325 core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.savedURL(\"%@\")", actualURL.absoluteString]); 310 326 }; 311 327 312 NSURL *URL = m_saveURLs.get(url).get(); 313 if (!URL) 314 URL = [NSURL URLWithString:url]; 315 else if (!forceSaveAs) { 316 saveToURL(URL); 328 if (!forceSaveDialog) { 329 saveToURL(platformURL); 317 330 return; 318 331 } 319 332 320 333 NSSavePanel *panel = [NSSavePanel savePanel]; 321 panel.nameFieldStringValue = URL.lastPathComponent;322 panel.directoryURL = [ URL URLByDeletingLastPathComponent];334 panel.nameFieldStringValue = platformURL.lastPathComponent; 335 panel.directoryURL = [platformURL URLByDeletingLastPathComponent]; 323 336 324 337 [panel beginSheetModalForWindow:[[m_windowController webView] window] completionHandler:^(NSInteger result) { … … 330 343 } 331 344 332 void WebInspectorFrontendClient::append(const String& url, const String& content) 333 { 334 RetainPtr<NSURL> URL = m_saveURLs.get(url); 335 if (!URL) 336 URL = [NSURL URLWithString:url]; 337 338 NSFileHandle *handle = [NSFileHandle fileHandleForWritingToURL:URL.get() error:NULL]; 345 void WebInspectorFrontendClient::append(const String& suggestedURL, const String& content) 346 { 347 ASSERT(!suggestedURL.isEmpty()); 348 349 RetainPtr<NSURL> actualURL = m_suggestedToActualURLMap.get(suggestedURL); 350 // do not append unless the user has already confirmed this filename in save(). 351 if (!actualURL) 352 return; 353 354 NSFileHandle *handle = [NSFileHandle fileHandleForWritingToURL:actualURL.get() error:NULL]; 339 355 [handle seekToEndOfFile]; 340 356 [handle writeData:[content dataUsingEncoding:NSUTF8StringEncoding]]; 341 357 [handle closeFile]; 342 358 343 core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.appendedToURL(\"%@\")", [ URL absoluteString]]);359 core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.appendedToURL(\"%@\")", [actualURL absoluteString]]); 344 360 } 345 361 -
trunk/Source/WebKit2/ChangeLog
r149919 r149923 1 2013-05-10 Brian J. Burg <burg@cs.washington.edu> 2 3 Web Inspector: Implement WK2 version of WebInspectorFrontendClient::save 4 https://bugs.webkit.org/show_bug.cgi?id=115564 5 6 Reviewed by Benjamin Poulain. 7 8 Implement InspectorFrontendHost's save() and append() methods for 9 Mac WebKit2. Add canSave() for all ports. 10 11 * UIProcess/WebInspectorProxy.cpp: 12 (WebKit::WebInspectorProxy::save): 13 (WebKit): 14 (WebKit::WebInspectorProxy::append): 15 * UIProcess/WebInspectorProxy.h: 16 (WebInspectorProxy): 17 * UIProcess/WebInspectorProxy.messages.in: 18 * UIProcess/efl/WebInspectorProxyEfl.cpp: 19 (WebKit::WebInspectorProxy::platformSave): 20 (WebKit): 21 (WebKit::WebInspectorProxy::platformAppend): 22 * UIProcess/gtk/WebInspectorProxyGtk.cpp: 23 (WebKit::WebInspectorProxy::platformSave): 24 (WebKit): 25 (WebKit::WebInspectorProxy::platformAppend): 26 * UIProcess/mac/WebInspectorProxyMac.mm: 27 (WebKit::WebInspectorProxy::platformSave): 28 (WebKit): 29 (WebKit::WebInspectorProxy::platformAppend): 30 * UIProcess/qt/WebInspectorProxyQt.cpp: 31 (WebKit::WebInspectorProxy::platformSave): 32 (WebKit): 33 (WebKit::WebInspectorProxy::platformAppend): 34 * WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp: 35 (WebKit::WebInspectorFrontendClient::canSave): 36 (WebKit): 37 (WebKit::WebInspectorFrontendClient::save): 38 (WebKit::WebInspectorFrontendClient::append): 39 * WebProcess/WebCoreSupport/WebInspectorFrontendClient.h: 40 (WebInspectorFrontendClient): 41 * WebProcess/WebPage/WebInspector.cpp: 42 (WebKit::WebInspector::save): 43 (WebKit): 44 (WebKit::WebInspector::append): 45 (WebKit::WebInspector::didSave): 46 (WebKit::WebInspector::didAppend): 47 * WebProcess/WebPage/WebInspector.h: 48 (WebInspector): 49 * WebProcess/WebPage/WebInspector.messages.in: 50 * WebProcess/WebPage/efl/WebInspectorEfl.cpp: 51 (WebKit::WebInspector::canSave): 52 (WebKit): 53 * WebProcess/WebPage/gtk/WebInspectorGtk.cpp: 54 (WebKit::WebInspector::canSave): 55 (WebKit): 56 * WebProcess/WebPage/mac/WebInspectorMac.mm: 57 (WebKit::WebInspector::canSave): 58 (WebKit): 59 * WebProcess/WebPage/qt/WebInspectorQt.cpp: 60 (WebKit::WebInspector::canSave): 61 (WebKit): 62 1 63 2013-05-10 Remy Demarest <rdemarest@apple.com> 2 64 -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
r149006 r149923 475 475 } 476 476 477 void WebInspectorProxy::save(const String& filename, const String& content, bool forceSaveAs) 478 { 479 platformSave(filename, content, forceSaveAs); 480 } 481 482 void WebInspectorProxy::append(const String& filename, const String& content) 483 { 484 platformAppend(filename, content); 485 } 486 477 487 bool WebInspectorProxy::canAttach() 478 488 { -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h
r149903 r149923 39 39 #if PLATFORM(MAC) 40 40 #include "WKGeometry.h" 41 #include <wtf/HashMap.h> 41 42 #include <wtf/RetainPtr.h> 42 43 43 44 OBJC_CLASS NSButton; 45 OBJC_CLASS NSURL; 44 46 OBJC_CLASS NSWindow; 45 47 OBJC_CLASS WKWebInspectorProxyObjCAdapter; … … 165 167 void platformSetAttachedWindowHeight(unsigned); 166 168 void platformSetAttachedWindowWidth(unsigned); 169 void platformSave(const String& filename, const String& content, bool forceSaveAs); 170 void platformAppend(const String& filename, const String& content); 171 167 172 168 173 // Called by WebInspectorProxy messages … … 172 177 void attachAvailabilityChanged(bool); 173 178 void inspectedURLChanged(const String&); 179 180 void save(const String& filename, const String& content, bool forceSaveAs); 181 void append(const String& filename, const String& content); 174 182 175 183 #if ENABLE(INSPECTOR_SERVER) … … 218 226 RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter; 219 227 String m_urlString; 228 HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap; 220 229 #elif PLATFORM(GTK) 221 230 WebInspectorClientGtk m_client; -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
r147004 r149923 29 29 InspectedURLChanged(WTF::String urlString) 30 30 31 Save(WTF::String filename, WTF::String content, bool forceSaveAs) 32 Append(WTF::String filename, WTF::String content) 33 31 34 AttachBottom() 32 35 AttachRight() -
trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp
r149902 r149923 215 215 } 216 216 217 void WebInspectorProxy::platformSave(const String&, const String&, bool) 218 { 219 notImplemented(); 220 } 221 222 void WebInspectorProxy::platformAppend(const String&, const String&) 223 { 224 notImplemented(); 225 } 226 217 227 void WebInspectorProxy::platformAttachAvailabilityChanged(bool) 218 228 { -
trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp
r148082 r149923 235 235 } 236 236 237 void WebInspectorProxy::platformSave(const String&, const String&, bool) 238 { 239 notImplemented(); 240 } 241 242 void WebInspectorProxy::platformAppend(const String&, const String&) 243 { 244 notImplemented(); 245 } 246 237 247 void WebInspectorProxy::platformAttachAvailabilityChanged(bool) 238 248 { -
trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
r149903 r149923 38 38 #import "WKURLCF.h" 39 39 #import "WKViewPrivate.h" 40 #import "WebInspectorMessages.h" 40 41 #import "WebPageGroup.h" 41 42 #import "WebPageProxy.h" … … 542 543 } 543 544 545 void WebInspectorProxy::platformSave(const String& suggestedURL, const String& content, bool forceSaveDialog) 546 { 547 ASSERT(!suggestedURL.isEmpty()); 548 549 NSURL *platformURL = m_suggestedToActualURLMap.get(suggestedURL).get(); 550 if (!platformURL) { 551 platformURL = [NSURL URLWithString:suggestedURL]; 552 // The user must confirm new filenames before we can save to them. 553 forceSaveDialog = true; 554 } 555 556 ASSERT(platformURL); 557 if (!platformURL) 558 return; 559 560 // Necessary for the block below. 561 String suggestedURLCopy = suggestedURL; 562 String contentCopy = content; 563 564 auto saveToURL = ^(NSURL *actualURL) { 565 ASSERT(actualURL); 566 567 m_suggestedToActualURLMap.set(suggestedURLCopy, actualURL); 568 [contentCopy writeToURL:actualURL atomically:YES encoding:NSUTF8StringEncoding error:NULL]; 569 m_page->process()->send(Messages::WebInspector::DidSave([actualURL absoluteString]), m_page->pageID()); 570 }; 571 572 if (!forceSaveDialog) { 573 saveToURL(platformURL); 574 return; 575 } 576 577 NSSavePanel *panel = [NSSavePanel savePanel]; 578 panel.nameFieldStringValue = platformURL.lastPathComponent; 579 panel.directoryURL = [platformURL URLByDeletingLastPathComponent]; 580 581 [panel beginSheetModalForWindow:m_inspectorWindow.get() completionHandler:^(NSInteger result) { 582 if (result == NSFileHandlingPanelCancelButton) 583 return; 584 ASSERT(result == NSFileHandlingPanelOKButton); 585 saveToURL(panel.URL); 586 }]; 587 } 588 589 void WebInspectorProxy::platformAppend(const String& suggestedURL, const String& content) 590 { 591 ASSERT(!suggestedURL.isEmpty()); 592 593 RetainPtr<NSURL> actualURL = m_suggestedToActualURLMap.get(suggestedURL); 594 // Do not append unless the user has already confirmed this filename in save(). 595 if (!actualURL) 596 return; 597 598 NSFileHandle *handle = [NSFileHandle fileHandleForWritingToURL:actualURL.get() error:NULL]; 599 [handle seekToEndOfFile]; 600 [handle writeData:[content dataUsingEncoding:NSUTF8StringEncoding]]; 601 [handle closeFile]; 602 603 m_page->process()->send(Messages::WebInspector::DidAppend([actualURL absoluteString]), m_page->pageID()); 604 } 605 544 606 void WebInspectorProxy::windowFrameDidChange() 545 607 { -
trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
r147004 r149923 108 108 } 109 109 110 void WebInspectorProxy::platformSave(const String&, const String&, bool) 111 { 112 notImplemented(); 113 } 114 115 void WebInspectorProxy::platformAppend(const String&, const String&) 116 { 117 notImplemented(); 118 } 119 110 120 String WebInspectorProxy::inspectorPageURL() const 111 121 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp
r147004 r149923 62 62 } 63 63 64 bool WebInspectorFrontendClient::canSave() 65 { 66 return m_page->inspector()->canSave(); 67 } 68 69 void WebInspectorFrontendClient::save(const String& filename, const String& content, bool forceSaveAs) 70 { 71 m_page->inspector()->save(filename, content, forceSaveAs); 72 } 73 74 void WebInspectorFrontendClient::append(const String& filename, const String& content) 75 { 76 m_page->inspector()->append(filename, content); 77 } 78 64 79 void WebInspectorFrontendClient::attachWindow(DockSide dockSide) 65 80 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h
r147004 r149923 45 45 virtual void closeWindow() OVERRIDE; 46 46 47 virtual bool canSave() OVERRIDE; 48 virtual void save(const String&, const String&, bool) OVERRIDE; 49 virtual void append(const String&, const String&) OVERRIDE; 50 47 51 virtual void attachWindow(DockSide) OVERRIDE; 48 52 virtual void detachWindow() OVERRIDE; -
trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
r147004 r149923 34 34 #include "WebPageCreationParameters.h" 35 35 #include "WebProcess.h" 36 #include <WebCore/Frame.h> 36 37 #include <WebCore/InspectorController.h> 37 38 #include <WebCore/InspectorFrontendChannel.h> 38 39 #include <WebCore/InspectorFrontendClient.h> 39 40 #include <WebCore/Page.h> 41 #include <WebCore/ScriptController.h> 42 #include <WebCore/ScriptValue.h> 43 #include <wtf/text/StringConcatenate.h> 40 44 41 45 using namespace WebCore; … … 118 122 } 119 123 124 void WebInspector::save(const String& filename, const String& content, bool forceSaveAs) 125 { 126 WebProcess::shared().connection()->send(Messages::WebInspectorProxy::Save(filename, content, forceSaveAs), m_page->pageID()); 127 } 128 129 void WebInspector::append(const String& filename, const String& content) 130 { 131 WebProcess::shared().connection()->send(Messages::WebInspectorProxy::Append(filename, content), m_page->pageID()); 132 } 133 120 134 void WebInspector::attachBottom() 121 135 { … … 152 166 { 153 167 m_page->corePage()->inspectorController()->close(); 168 } 169 170 void WebInspector::didSave(const String& url) 171 { 172 ASSERT(m_inspectorPage); 173 m_inspectorPage->corePage()->mainFrame()->script()->executeScript(makeString("InspectorFrontendAPI.savedURL(\"", url, "\")")); 174 } 175 176 void WebInspector::didAppend(const String& url) 177 { 178 ASSERT(m_inspectorPage); 179 m_inspectorPage->corePage()->mainFrame()->script()->executeScript(makeString("InspectorFrontendAPI.appendedToURL(\"", url, "\")")); 154 180 } 155 181 -
trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h
r147403 r149923 58 58 void close(); 59 59 60 void didSave(const String& url); 61 void didAppend(const String& url); 62 60 63 void attachedBottom(); 61 64 void attachedRight(); … … 94 97 void bringToFront(); 95 98 void inspectedURLChanged(const String&); 99 100 bool canSave() const; 101 void save(const String& filename, const String& content, bool forceSaveAs); 102 void append(const String& filename, const String& content); 96 103 97 104 void attachBottom(); -
trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in
r147004 r149923 29 29 AttachedRight() 30 30 Detached() 31 DidSave(WTF::String url) 32 DidAppend(WTF::String url) 31 33 ShowConsole() 32 34 ShowResources() -
trunk/Source/WebKit2/WebProcess/WebPage/efl/WebInspectorEfl.cpp
r140372 r149923 34 34 namespace WebKit { 35 35 36 bool WebInspector::canSave() const 37 { 38 return false; 39 } 40 36 41 String WebInspector::localizedStringsURL() const 37 42 { -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp
r144982 r149923 37 37 namespace WebKit { 38 38 39 bool WebInspector::canSave() const 40 { 41 return false; 42 } 43 39 44 String WebInspector::localizedStringsURL() const 40 45 { -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm
r140903 r149923 58 58 } 59 59 60 bool WebInspector::canSave() const 61 { 62 return true; 63 } 64 60 65 String WebInspector::localizedStringsURL() const 61 66 { -
trunk/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorQt.cpp
r95901 r149923 34 34 namespace WebKit { 35 35 36 bool WebInspector::canSave() const 37 { 38 return false; 39 } 40 36 41 String WebInspector::localizedStringsURL() const 37 42 {
Note: See TracChangeset
for help on using the changeset viewer.