Skip to content

Commit

Permalink
Merge pull request #1 from b1rdex/node
Browse files Browse the repository at this point in the history
Possibility to set default file name to write to using nwsaveas
  • Loading branch information
rogerwang committed Sep 5, 2013
2 parents 13e765c + a170369 commit 5c2a781
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Source/WebKit/chromium/src/ChromeClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,11 @@ void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileCh
params.directory = fileChooser->settings().directoryChooser || fileChooser->settings().allowsDirectoryUpload;
params.acceptTypes = fileChooser->settings().acceptTypes();
params.selectedFiles = fileChooser->settings().selectedFiles;
if (params.selectedFiles.size() > 0)
if (params.selectedFiles.size() > 0) {
params.initialValue = params.selectedFiles[0];
} else {
params.initialValue = fileChooser->settings().initialValue;
}
params.extractDirectory = fileChooser->settings().allowsDirectoryUpload;
params.saveAs = fileChooser->settings().saveAs;
#if ENABLE(MEDIA_CAPTURE)
Expand Down
1 change: 1 addition & 0 deletions Source/core/html/FileInputType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void FileInputType::handleDOMActivateEvent(Event* event)
settings.capture = input->capture();
#endif
settings.initialPath = input->nwworkingdir();
settings.initialValue = input->nwsaveas();
chrome->runOpenPanel(input->document()->frame(), newFileChooser(settings));
}
event->setDefaultHandled();
Expand Down
10 changes: 10 additions & 0 deletions Source/core/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,16 @@ void HTMLInputElement::setNwworkingdir(const String& value)
setAttribute(nwworkingdirAttr, value);
}

String HTMLInputElement::nwsaveas() const
{
return fastGetAttribute(nwsaveasAttr);
}

void HTMLInputElement::setNwsaveas(const String& value)
{
setAttribute(nwsaveasAttr, value);
}

bool HTMLInputElement::isInRequiredRadioButtonGroup()
{
ASSERT(isRadioButton());
Expand Down
3 changes: 3 additions & 0 deletions Source/core/html/HTMLInputElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ class HTMLInputElement : public HTMLTextFormControlElement {
String nwworkingdir() const;
void setNwworkingdir(const String& value);

String nwsaveas() const;
void setNwsaveas(const String& value);

static const int maximumLength;

unsigned height() const;
Expand Down
2 changes: 2 additions & 0 deletions Source/core/html/HTMLInputElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@

// See http://www.w3.org/TR/html-media-capture/
[Conditional=MEDIA_CAPTURE] attribute DOMString capture;

attribute DOMString nwworkingdir;
attribute DOMString nwsaveas;
};
1 change: 1 addition & 0 deletions Source/core/platform/FileChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct FileChooserSettings {
Vector<String> acceptTypes() const;

String initialPath;
String initialValue;
};

class FileChooserClient {
Expand Down

0 comments on commit 5c2a781

Please sign in to comment.