| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void FileSelectHelper::FileSelectedWithExtraInfo( | 134 void FileSelectHelper::FileSelectedWithExtraInfo( |
| 135 const ui::SelectedFileInfo& file, | 135 const ui::SelectedFileInfo& file, |
| 136 int index, | 136 int index, |
| 137 void* params) { | 137 void* params) { |
| 138 if (!render_view_host_) | 138 if (!render_view_host_) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 profile_->set_last_selected_directory(file.file_path.DirName()); | 141 profile_->set_last_selected_directory(file.file_path.DirName()); |
| 142 | 142 |
| 143 const base::FilePath& path = file.local_path; | 143 const base::FilePath& path = file.local_path; |
| 144 if (dialog_type_ == ui::SelectFileDialog::SELECT_FOLDER) { | 144 if (dialog_type_ == ui::SelectFileDialog::SELECT_UPLOAD_FOLDER) { |
| 145 StartNewEnumeration(path, kFileSelectEnumerationId, render_view_host_); | 145 StartNewEnumeration(path, kFileSelectEnumerationId, render_view_host_); |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 | 148 |
| 149 std::vector<ui::SelectedFileInfo> files; | 149 std::vector<ui::SelectedFileInfo> files; |
| 150 files.push_back(file); | 150 files.push_back(file); |
| 151 NotifyRenderViewHost(render_view_host_, files, dialog_type_); | 151 NotifyRenderViewHost(render_view_host_, files, dialog_type_); |
| 152 | 152 |
| 153 // No members should be accessed from here on. | 153 // No members should be accessed from here on. |
| 154 RunFileChooserEnd(); | 154 RunFileChooserEnd(); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 select_file_dialog_ = ui::SelectFileDialog::Create( | 387 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 388 this, new ChromeSelectFilePolicy(web_contents_)); | 388 this, new ChromeSelectFilePolicy(web_contents_)); |
| 389 | 389 |
| 390 switch (params.mode) { | 390 switch (params.mode) { |
| 391 case FileChooserParams::Open: | 391 case FileChooserParams::Open: |
| 392 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; | 392 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; |
| 393 break; | 393 break; |
| 394 case FileChooserParams::OpenMultiple: | 394 case FileChooserParams::OpenMultiple: |
| 395 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE; | 395 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE; |
| 396 break; | 396 break; |
| 397 case FileChooserParams::OpenFolder: | 397 case FileChooserParams::UploadFolder: |
| 398 dialog_type_ = ui::SelectFileDialog::SELECT_FOLDER; | 398 dialog_type_ = ui::SelectFileDialog::SELECT_UPLOAD_FOLDER; |
| 399 break; | 399 break; |
| 400 case FileChooserParams::Save: | 400 case FileChooserParams::Save: |
| 401 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; | 401 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; |
| 402 break; | 402 break; |
| 403 default: | 403 default: |
| 404 // Prevent warning. | 404 // Prevent warning. |
| 405 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; | 405 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; |
| 406 NOTREACHED(); | 406 NOTREACHED(); |
| 407 } | 407 } |
| 408 | 408 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // A 1 character accept type will always be invalid (either a "." in the case | 495 // A 1 character accept type will always be invalid (either a "." in the case |
| 496 // of an extension or a "/" in the case of a MIME type). | 496 // of an extension or a "/" in the case of a MIME type). |
| 497 std::string unused; | 497 std::string unused; |
| 498 if (accept_type.length() <= 1 || | 498 if (accept_type.length() <= 1 || |
| 499 StringToLowerASCII(accept_type) != accept_type || | 499 StringToLowerASCII(accept_type) != accept_type || |
| 500 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { | 500 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { |
| 501 return false; | 501 return false; |
| 502 } | 502 } |
| 503 return true; | 503 return true; |
| 504 } | 504 } |
| OLD | NEW |