Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: webkit/glue/chrome_client_impl.cc

Issue 18285: Adding support for multiple files in FileChooser (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 8
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "Cursor.h" 10 #include "Cursor.h"
(...skipping 25 matching lines...) Expand all
36 36
37 // Callback class that's given to the WebViewDelegate during a file choose 37 // Callback class that's given to the WebViewDelegate during a file choose
38 // operation. 38 // operation.
39 class WebFileChooserCallbackImpl : public WebFileChooserCallback { 39 class WebFileChooserCallbackImpl : public WebFileChooserCallback {
40 public: 40 public:
41 WebFileChooserCallbackImpl(PassRefPtr<WebCore::FileChooser> file_chooser) 41 WebFileChooserCallbackImpl(PassRefPtr<WebCore::FileChooser> file_chooser)
42 : file_chooser_(file_chooser) { 42 : file_chooser_(file_chooser) {
43 } 43 }
44 44
45 void OnFileChoose(const std::vector<std::wstring>& file_names) { 45 void OnFileChoose(const std::vector<std::wstring>& file_names) {
46 assert(file_names.size() <= 1);
47 if (file_names.empty()) { 46 if (file_names.empty()) {
48 file_chooser_->chooseFile(webkit_glue::StdWStringToString(L"")); 47 file_chooser_->chooseFile(WebCore::String(""));
48 } else if (file_names.size() == 1) {
49 file_chooser_->chooseFile(
50 webkit_glue::StdWStringToString(file_names.front()));
49 } else { 51 } else {
50 file_chooser_->chooseFile( 52 Vector<WebCore::String> paths;
51 webkit_glue::StdWStringToString(file_names.front().c_str())); 53 for (std::vector<std::wstring>::const_iterator filename =
54 file_names.begin(); filename != file_names.end(); ++filename) {
55 paths.append(webkit_glue::StdWStringToString(*filename));
56 }
57 file_chooser_->chooseFiles(paths);
52 } 58 }
53 } 59 }
54 60
55 private: 61 private:
56 RefPtr<WebCore::FileChooser> file_chooser_; 62 RefPtr<WebCore::FileChooser> file_chooser_;
57 DISALLOW_EVIL_CONSTRUCTORS(WebFileChooserCallbackImpl); 63 DISALLOW_EVIL_CONSTRUCTORS(WebFileChooserCallbackImpl);
58 }; 64 };
59 65
60 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webview) 66 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webview)
61 : webview_(webview), 67 : webview_(webview),
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 const WebCore::String& databaseName) { 457 const WebCore::String& databaseName) {
452 // TODO(tc): If we enable the storage API, we need to implement this function. 458 // TODO(tc): If we enable the storage API, we need to implement this function.
453 } 459 }
454 460
455 void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame, 461 void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame,
456 PassRefPtr<WebCore::FileChooser> fileChooser) { 462 PassRefPtr<WebCore::FileChooser> fileChooser) {
457 WebViewDelegate* delegate = webview_->delegate(); 463 WebViewDelegate* delegate = webview_->delegate();
458 if (!delegate) 464 if (!delegate)
459 return; 465 return;
460 466
467 bool multiple_files = fileChooser->allowsMultipleFiles();
468
461 std::wstring suggestion; 469 std::wstring suggestion;
462 if (fileChooser->filenames().size() > 0) 470 if (fileChooser->filenames().size() > 0)
463 suggestion = webkit_glue::StringToStdWString(fileChooser->filenames()[0]); 471 suggestion = webkit_glue::StringToStdWString(fileChooser->filenames()[0]);
464 472
465 WebFileChooserCallbackImpl* chooser = new WebFileChooserCallbackImpl(fileChoos er); 473 WebFileChooserCallbackImpl* chooser = new WebFileChooserCallbackImpl(fileChoos er);
466 delegate->RunFileChooser(false, std::wstring(), suggestion, 474 delegate->RunFileChooser(multiple_files, std::wstring(), suggestion,
467 std::wstring(), chooser); 475 std::wstring(), chooser);
468 } 476 }
469 477
470 void ChromeClientImpl::popupOpened(WebCore::FramelessScrollView* popup_view, 478 void ChromeClientImpl::popupOpened(WebCore::FramelessScrollView* popup_view,
471 const WebCore::IntRect& bounds, 479 const WebCore::IntRect& bounds,
472 bool activatable) { 480 bool activatable) {
473 WebViewDelegate* d = webview_->delegate(); 481 WebViewDelegate* d = webview_->delegate();
474 if (d) { 482 if (d) {
475 WebWidgetImpl* webwidget = 483 WebWidgetImpl* webwidget =
476 static_cast<WebWidgetImpl*>(d->CreatePopupWidget(webview_, 484 static_cast<WebWidgetImpl*>(d->CreatePopupWidget(webview_,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 WebViewDelegate* d = webview_->delegate(); 516 WebViewDelegate* d = webview_->delegate();
509 if (d) 517 if (d)
510 d->DisableSuddenTermination(); 518 d->DisableSuddenTermination();
511 } 519 }
512 520
513 void ChromeClientImpl::formStateDidChange(const WebCore::Node*) { 521 void ChromeClientImpl::formStateDidChange(const WebCore::Node*) {
514 WebViewDelegate* d = webview_->delegate(); 522 WebViewDelegate* d = webview_->delegate();
515 if (d) 523 if (d)
516 d->OnNavStateChanged(webview_); 524 d->OnNavStateChanged(webview_);
517 } 525 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698