OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return InputTypeNames::file; | 82 return InputTypeNames::file; |
83 } | 83 } |
84 | 84 |
85 FormControlState FileInputType::saveFormControlState() const | 85 FormControlState FileInputType::saveFormControlState() const |
86 { | 86 { |
87 if (m_fileList->isEmpty()) | 87 if (m_fileList->isEmpty()) |
88 return FormControlState(); | 88 return FormControlState(); |
89 FormControlState state; | 89 FormControlState state; |
90 unsigned numFiles = m_fileList->length(); | 90 unsigned numFiles = m_fileList->length(); |
91 for (unsigned i = 0; i < numFiles; ++i) { | 91 for (unsigned i = 0; i < numFiles; ++i) { |
92 state.append(m_fileList->item(i)->path()); | 92 if (m_fileList->item(i)->hasBackingFile()) { |
93 state.append(m_fileList->item(i)->name()); | 93 state.append(m_fileList->item(i)->path()); |
| 94 state.append(m_fileList->item(i)->name()); |
| 95 } |
| 96 // FIXME: handle Blob-backed File instances, see http://crbug.com/394948 |
94 } | 97 } |
95 return state; | 98 return state; |
96 } | 99 } |
97 | 100 |
98 void FileInputType::restoreFormControlState(const FormControlState& state) | 101 void FileInputType::restoreFormControlState(const FormControlState& state) |
99 { | 102 { |
100 if (state.valueSize() % 2) | 103 if (state.valueSize() % 2) |
101 return; | 104 return; |
102 filesChosen(filesFromFormControlState(state)); | 105 filesChosen(filesFromFormControlState(state)); |
103 } | 106 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 if (!UserGestureIndicator::processingUserGesture()) | 152 if (!UserGestureIndicator::processingUserGesture()) |
150 return; | 153 return; |
151 | 154 |
152 if (Chrome* chrome = this->chrome()) { | 155 if (Chrome* chrome = this->chrome()) { |
153 FileChooserSettings settings; | 156 FileChooserSettings settings; |
154 HTMLInputElement& input = element(); | 157 HTMLInputElement& input = element(); |
155 settings.allowsDirectoryUpload = input.fastHasAttribute(webkitdirectoryA
ttr); | 158 settings.allowsDirectoryUpload = input.fastHasAttribute(webkitdirectoryA
ttr); |
156 settings.allowsMultipleFiles = settings.allowsDirectoryUpload || input.f
astHasAttribute(multipleAttr); | 159 settings.allowsMultipleFiles = settings.allowsDirectoryUpload || input.f
astHasAttribute(multipleAttr); |
157 settings.acceptMIMETypes = input.acceptMIMETypes(); | 160 settings.acceptMIMETypes = input.acceptMIMETypes(); |
158 settings.acceptFileExtensions = input.acceptFileExtensions(); | 161 settings.acceptFileExtensions = input.acceptFileExtensions(); |
159 settings.selectedFiles = m_fileList->paths(); | 162 settings.selectedFiles = m_fileList->pathsForUserVisibleFiles(); |
160 settings.useMediaCapture = RuntimeEnabledFeatures::mediaCaptureEnabled()
&& input.isFileUpload() && input.fastHasAttribute(captureAttr); | 163 settings.useMediaCapture = RuntimeEnabledFeatures::mediaCaptureEnabled()
&& input.isFileUpload() && input.fastHasAttribute(captureAttr); |
161 chrome->runOpenPanel(input.document().frame(), newFileChooser(settings))
; | 164 chrome->runOpenPanel(input.document().frame(), newFileChooser(settings))
; |
162 } | 165 } |
163 event->setDefaultHandled(); | 166 event->setDefaultHandled(); |
164 } | 167 } |
165 | 168 |
166 RenderObject* FileInputType::createRenderer(RenderStyle*) const | 169 RenderObject* FileInputType::createRenderer(RenderStyle*) const |
167 { | 170 { |
168 return new RenderFileUploadControl(&element()); | 171 return new RenderFileUploadControl(&element()); |
169 } | 172 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 StringBuilder names; | 378 StringBuilder names; |
376 for (size_t i = 0; i < listSize; ++i) { | 379 for (size_t i = 0; i < listSize; ++i) { |
377 names.append(fileList->item(i)->name()); | 380 names.append(fileList->item(i)->name()); |
378 if (i != listSize - 1) | 381 if (i != listSize - 1) |
379 names.append('\n'); | 382 names.append('\n'); |
380 } | 383 } |
381 return names.toString(); | 384 return names.toString(); |
382 } | 385 } |
383 | 386 |
384 } // namespace blink | 387 } // namespace blink |
OLD | NEW |