| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 PassRefPtr<FileChooser> FileChooser::create(FileChooserClient* client, const Fil
eChooserSettings& settings) | 59 PassRefPtr<FileChooser> FileChooser::create(FileChooserClient* client, const Fil
eChooserSettings& settings) |
| 60 { | 60 { |
| 61 return adoptRef(new FileChooser(client, settings)); | 61 return adoptRef(new FileChooser(client, settings)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 FileChooser::~FileChooser() | 64 FileChooser::~FileChooser() |
| 65 { | 65 { |
| 66 } | 66 } |
| 67 | 67 |
| 68 void FileChooser::chooseFiles(const Vector<String>& filenames) | |
| 69 { | |
| 70 // FIXME: This is inelegant. We should not be looking at settings here. | |
| 71 if (m_settings.selectedFiles == filenames) | |
| 72 return; | |
| 73 | |
| 74 if (m_client) { | |
| 75 Vector<FileChooserFileInfo> files; | |
| 76 for (unsigned i = 0; i < filenames.size(); ++i) | |
| 77 files.append(FileChooserFileInfo(filenames[i])); | |
| 78 m_client->filesChosen(files); | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 void FileChooser::chooseFiles(const Vector<FileChooserFileInfo>& files) | 68 void FileChooser::chooseFiles(const Vector<FileChooserFileInfo>& files) |
| 83 { | 69 { |
| 84 // FIXME: This is inelegant. We should not be looking at settings here. | 70 // FIXME: This is inelegant. We should not be looking at settings here. |
| 85 Vector<String> paths; | 71 Vector<String> paths; |
| 86 for (unsigned i = 0; i < files.size(); ++i) | 72 for (unsigned i = 0; i < files.size(); ++i) |
| 87 paths.append(files[i].path); | 73 paths.append(files[i].path); |
| 88 if (m_settings.selectedFiles == paths) | 74 if (m_settings.selectedFiles == paths) |
| 89 return; | 75 return; |
| 90 | 76 |
| 91 if (m_client) | 77 if (m_client) |
| 92 m_client->filesChosen(files); | 78 m_client->filesChosen(files); |
| 93 } | 79 } |
| 94 | 80 |
| 95 Vector<String> FileChooserSettings::acceptTypes() const | 81 Vector<String> FileChooserSettings::acceptTypes() const |
| 96 { | 82 { |
| 97 Vector<String> acceptTypes; | 83 Vector<String> acceptTypes; |
| 98 acceptTypes.reserveCapacity(acceptMIMETypes.size() + acceptFileExtensions.si
ze()); | 84 acceptTypes.reserveCapacity(acceptMIMETypes.size() + acceptFileExtensions.si
ze()); |
| 99 acceptTypes.appendVector(acceptMIMETypes); | 85 acceptTypes.appendVector(acceptMIMETypes); |
| 100 acceptTypes.appendVector(acceptFileExtensions); | 86 acceptTypes.appendVector(acceptFileExtensions); |
| 101 return acceptTypes; | 87 return acceptTypes; |
| 102 } | 88 } |
| 103 | 89 |
| 104 } | 90 } |
| OLD | NEW |