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

Side by Side Diff: chrome/browser/file_select_helper.cc

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix win Created 8 years, 5 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
OLDNEW
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"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/platform_util.h" 15 #include "chrome/browser/platform_util.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_list.h" 18 #include "chrome/browser/ui/browser_list.h"
19 #include "chrome/browser/ui/chrome_select_file_policy.h"
19 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
21 #include "content/public/browser/notification_types.h" 22 #include "content/public/browser/notification_types.h"
22 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/render_widget_host_view.h" 24 #include "content/public/browser/render_widget_host_view.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/file_chooser_params.h" 26 #include "content/public/common/file_chooser_params.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "net/base/mime_util.h" 28 #include "net/base/mime_util.h"
28 #include "ui/base/dialogs/selected_file_info.h" 29 #include "ui/base/dialogs/selected_file_info.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 365
365 void FileSelectHelper::RunFileChooserOnUIThread( 366 void FileSelectHelper::RunFileChooserOnUIThread(
366 const FileChooserParams& params) { 367 const FileChooserParams& params) {
367 if (!render_view_host_ || !web_contents_) { 368 if (!render_view_host_ || !web_contents_) {
368 // If the renderer was destroyed before we started, just cancel the 369 // If the renderer was destroyed before we started, just cancel the
369 // operation. 370 // operation.
370 RunFileChooserEnd(); 371 RunFileChooserEnd();
371 return; 372 return;
372 } 373 }
373 374
374 if (!select_file_dialog_.get()) 375 select_file_dialog_ = SelectFileDialog::Create(
375 select_file_dialog_ = SelectFileDialog::Create(this); 376 this, new ChromeSelectFilePolicy(web_contents_));
376 377
377 switch (params.mode) { 378 switch (params.mode) {
378 case FileChooserParams::Open: 379 case FileChooserParams::Open:
379 dialog_type_ = SelectFileDialog::SELECT_OPEN_FILE; 380 dialog_type_ = SelectFileDialog::SELECT_OPEN_FILE;
380 break; 381 break;
381 case FileChooserParams::OpenMultiple: 382 case FileChooserParams::OpenMultiple:
382 dialog_type_ = SelectFileDialog::SELECT_OPEN_MULTI_FILE; 383 dialog_type_ = SelectFileDialog::SELECT_OPEN_MULTI_FILE;
383 break; 384 break;
384 case FileChooserParams::OpenFolder: 385 case FileChooserParams::OpenFolder:
385 dialog_type_ = SelectFileDialog::SELECT_FOLDER; 386 dialog_type_ = SelectFileDialog::SELECT_FOLDER;
(...skipping 12 matching lines...) Expand all
398 gfx::NativeWindow owning_window = 399 gfx::NativeWindow owning_window =
399 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); 400 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView());
400 401
401 select_file_dialog_->SelectFile( 402 select_file_dialog_->SelectFile(
402 dialog_type_, 403 dialog_type_,
403 params.title, 404 params.title,
404 default_file_name, 405 default_file_name,
405 select_file_types_.get(), 406 select_file_types_.get(),
406 select_file_types_.get() ? 1 : 0, // 1-based index. 407 select_file_types_.get() ? 1 : 0, // 1-based index.
407 FILE_PATH_LITERAL(""), 408 FILE_PATH_LITERAL(""),
408 web_contents_,
409 owning_window, 409 owning_window,
410 #if defined(OS_ANDROID) 410 #if defined(OS_ANDROID)
411 const_cast<content::FileChooserParams*>(&params)); 411 const_cast<content::FileChooserParams*>(&params));
412 #else 412 #else
413 NULL); 413 NULL);
414 #endif 414 #endif
415 415
416 select_file_types_.reset(); 416 select_file_types_.reset();
417 } 417 }
418 418
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // A 1 character accept type will always be invalid (either a "." in the case 473 // A 1 character accept type will always be invalid (either a "." in the case
474 // of an extension or a "/" in the case of a MIME type). 474 // of an extension or a "/" in the case of a MIME type).
475 std::string unused; 475 std::string unused;
476 if (accept_type.length() <= 1 || 476 if (accept_type.length() <= 1 ||
477 StringToLowerASCII(accept_type) != accept_type || 477 StringToLowerASCII(accept_type) != accept_type ||
478 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { 478 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) {
479 return false; 479 return false;
480 } 480 }
481 return true; 481 return true;
482 } 482 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/file_system/file_system_api.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698