Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to set default file name to write to using nwsaveas #1

Merged
merged 1 commit into from
Sep 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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